{"thread":{"id":"42121","subject":"[PATCH 1/2] git-p4 tests: cd to testdir before running python","startedAt":"2016-04-23T14:13:44Z","lastAt":"2016-04-26T07:27:30Z","messageCount":5,"participants":["Luke Diamand","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"284226","messageId":"1461420826-4416-1-git-send-email-luke@diamand.org","threadId":"42121","inReplyTo":null,"subject":"[PATCH 0/2] git-p4: support python3 in the tests","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-23T14:13:44Z","receivedAt":"2016-04-23T14:13:44Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"This patchset updates the git-p4 tests so that they work with\neither Python2 or Python3.\n\nNote that this does *not* fix git-p4 to work with Python3 - that's\na much bigger challenge.\n\nLuke Diamand (2):\n  git-p4 tests: cd to testdir before running python\n  git-p4 tests: work with python3 as well as python2\n\n t/lib-git-p4.sh            | 7 ++++---\n t/t9802-git-p4-filetype.sh | 6 +++---\n 2 files changed, 7 insertions(+), 6 deletions(-)\n\n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284224","messageId":"1461420826-4416-2-git-send-email-luke@diamand.org","threadId":"42121","inReplyTo":"1461420826-4416-1-git-send-email-luke@diamand.org","subject":"[PATCH 1/2] git-p4 tests: cd to testdir before running python","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-23T14:13:45Z","receivedAt":"2016-04-23T14:13:45Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"The python one-liner for getting the current time prints out\nerror messages if the current directory is deleted while it is\nrunning if using python3.\n\nAvoid these messages by switching back to the test directory\nbefore running python3, instead of remaining in the trash\ndirectory.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/lib-git-p4.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex f9ae1d7..77802fe 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -50,7 +50,7 @@ native_path() {\n # at runtime (e.g. via NTP). The 'clock_gettime(CLOCK_MONOTONIC)'\n # function could fix that but it is not in Python until 3.3.\n time_in_seconds() {\n-\tpython -c 'import time; print int(time.time())'\n+\t(cd \"$TEST_DIRECTORY\" && python -c 'import time; print(int(time.time()))')\n }\n \n # Try to pick a unique port: guess a large number, then hope\n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284225","messageId":"1461420826-4416-3-git-send-email-luke@diamand.org","threadId":"42121","inReplyTo":"1461420826-4416-1-git-send-email-luke@diamand.org","subject":"[PATCH 2/2] git-p4 tests: work with python3 as well as python2","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-23T14:13:46Z","receivedAt":"2016-04-23T14:13:46Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Update the git-p4 tests so that they work with both\nPython2 and Python3.\n\nWe have to be explicit about the difference between\nUnicode text strings (Python3 default) and raw binary\nstrings which will be exchanged with Perforce.\n\nAdditionally, print always takes braces in Python3.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/lib-git-p4.sh            | 5 +++--\n t/t9802-git-p4-filetype.sh | 6 +++---\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh\nindex 77802fe..b97d27c 100644\n--- a/t/lib-git-p4.sh\n+++ b/t/lib-git-p4.sh\n@@ -198,9 +198,10 @@ marshal_dump() {\n \tcat >\"$TRASH_DIRECTORY/marshal-dump.py\" <<-EOF &&\n \timport marshal\n \timport sys\n+\tinstream = getattr(sys.stdin, 'buffer', sys.stdin)\n \tfor i in range($line):\n-\t    d = marshal.load(sys.stdin)\n-\tprint d['$what']\n+\t    d = marshal.load(instream)\n+\tprint(d[b'$what'].decode('utf-8'))\n \tEOF\n \t\"$PYTHON_PATH\" \"$TRASH_DIRECTORY/marshal-dump.py\"\n }\ndiff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh\nindex 66d3fc9..eb9a8ed 100755\n--- a/t/t9802-git-p4-filetype.sh\n+++ b/t/t9802-git-p4-filetype.sh\n@@ -223,12 +223,12 @@ build_gendouble() {\n \timport sys\n \timport struct\n \n-\ts = struct.pack(\">LL18s\",\n+\ts = struct.pack(b\">LL18s\",\n \t\t\t0x00051607,  # AppleDouble\n \t\t\t0x00020000,  # version 2\n-\t\t\t\"\"           # pad to 26 bytes\n+\t\t\tb\"\"          # pad to 26 bytes\n \t)\n-\tsys.stdout.write(s)\n+\tgetattr(sys.stdout, 'buffer', sys.stdout).write(s)\n \tEOF\n }\n \n-- \n2.8.1.218.gd2cea43.dirty\n"},{"id":"284498","messageId":"xmqqzishibpz.fsf@gitster.mtv.corp.google.com","threadId":"42121","inReplyTo":"1461420826-4416-1-git-send-email-luke@diamand.org","subject":"Re: [PATCH 0/2] git-p4: support python3 in the tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-25T22:07:36Z","receivedAt":"2016-04-25T22:07:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> This patchset updates the git-p4 tests so that they work with\n> either Python2 or Python3.\n>\n> Note that this does *not* fix git-p4 to work with Python3 - that's\n> a much bigger challenge.\n\nWe use Python outside p4 tests (e.g. remote-svn test), and the way\nthey invoke the interpreter is to say \"$PYTHON_PATH\" and avoid\nsaying \"python\" which picks whatever random version of Python\ninterpreter happens to be the first on $PATH.  Shouldn't the tests\ntouched by this series be doing the same?\n\n\n>\n> Luke Diamand (2):\n>   git-p4 tests: cd to testdir before running python\n>   git-p4 tests: work with python3 as well as python2\n>\n>  t/lib-git-p4.sh            | 7 ++++---\n>  t/t9802-git-p4-filetype.sh | 6 +++---\n>  2 files changed, 7 insertions(+), 6 deletions(-)\n"},{"id":"284510","messageId":"CAE5ih7_MzKWG+=PDMW8a5uJ28uGGnvh-25-3b4bgnO3VdBiyLA@mail.gmail.com","threadId":"42121","inReplyTo":"xmqqzishibpz.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 0/2] git-p4: support python3 in the tests","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-04-26T07:27:30Z","receivedAt":"2016-04-26T07:27:30Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 25 April 2016 at 23:07, Junio C Hamano <gitster@pobox.com> wrote:\n> Luke Diamand <luke@diamand.org> writes:\n>\n>> This patchset updates the git-p4 tests so that they work with\n>> either Python2 or Python3.\n>>\n>> Note that this does *not* fix git-p4 to work with Python3 - that's\n>> a much bigger challenge.\n>\n> We use Python outside p4 tests (e.g. remote-svn test), and the way\n> they invoke the interpreter is to say \"$PYTHON_PATH\" and avoid\n> saying \"python\" which picks whatever random version of Python\n> interpreter happens to be the first on $PATH.  Shouldn't the tests\n> touched by this series be doing the same?\n\nYes, they should. I'll update them accordingly.\n\nBut the real reason for doing this is that at some point, git-p4 has\nto start working with python3, since python2 is going away (albeit not\nuntil 2020).\n\nLuke\n"}]}