Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The LUCI Authors. All rights reserved. | 2 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 # pylint: disable=R0201 | 6 # pylint: disable=R0201 |
| 7 | 7 |
| 8 import StringIO | 8 import StringIO |
| 9 import base64 | 9 import base64 |
| 10 import contextlib | 10 import contextlib |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 | 768 |
| 769 | 769 |
| 770 # Like RunIsolatedTestRun, but ensures that specific output files | 770 # Like RunIsolatedTestRun, but ensures that specific output files |
| 771 # (as opposed to anything in $(ISOLATED_OUTDIR)) are returned. | 771 # (as opposed to anything in $(ISOLATED_OUTDIR)) are returned. |
| 772 class RunIsolatedTestOutputFiles(RunIsolatedTestBase): | 772 class RunIsolatedTestOutputFiles(RunIsolatedTestBase): |
| 773 def _run_test(self, isolated, command): | 773 def _run_test(self, isolated, command): |
| 774 # Starts a full isolate server mock and have run_tha_test() uploads results | 774 # Starts a full isolate server mock and have run_tha_test() uploads results |
| 775 # back after the task completed. | 775 # back after the task completed. |
| 776 server = isolateserver_mock.MockIsolateServer() | 776 server = isolateserver_mock.MockIsolateServer() |
| 777 try: | 777 try: |
| 778 # Output two files. If we're on Linux, we'll try to make one of them a | |
| 779 # symlink to ensure that we correctly follow symlinks. Note that this only | |
| 780 # tests file symlinks, not directory symlinks. | |
| 781 # TODO(aludwin): follow directory symlinks | |
| 778 script = ( | 782 script = ( |
| 779 'import sys\n' | 783 'import sys\n' |
| 784 'import os\n' | |
|
M-A Ruel
2017/06/09 20:16:22
OMG it's not sorted.
aludwin
2017/06/12 12:59:11
Done.
| |
| 780 'open(sys.argv[1], "w").write("bar")\n' | 785 'open(sys.argv[1], "w").write("bar")\n' |
| 781 'open(sys.argv[2], "w").write("baz")\n') | 786 'if sys.platform.startswith("linux"):\n' |
| 787 ' realpath = os.path.join(os.getcwd(), "contents_of_symlink")\n' | |
|
M-A Ruel
2017/06/09 20:16:22
realpath = os.path.abspath("contents_of_symlink")
aludwin
2017/06/12 12:59:11
Fixed. Because "sys.argv[2]" can be in another dir
| |
| 788 ' open(realpath, "w").write("baz")\n' | |
| 789 ' os.symlink(realpath, sys.argv[2])\n' | |
| 790 'else:\n' | |
| 791 ' open(sys.argv[2], "w").write("baz")\n') | |
| 782 script_hash = isolateserver_mock.hash_content(script) | 792 script_hash = isolateserver_mock.hash_content(script) |
| 783 isolated['files']['cmd.py'] = { | 793 isolated['files']['cmd.py'] = { |
| 784 'h': script_hash, | 794 'h': script_hash, |
| 785 'm': 0700, | 795 'm': 0700, |
| 786 's': len(script), | 796 's': len(script), |
| 787 } | 797 } |
| 788 if sys.platform == 'win32': | 798 if sys.platform == 'win32': |
| 789 isolated['files']['cmd.py'].pop('m') | 799 isolated['files']['cmd.py'].pop('m') |
| 790 isolated_data = json_dumps(isolated) | 800 isolated_data = json_dumps(isolated) |
| 791 isolated_hash = isolateserver_mock.hash_content(isolated_data) | 801 isolated_hash = isolateserver_mock.hash_content(isolated_data) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 self.assertEqual(expected, actual) | 1005 self.assertEqual(expected, actual) |
| 996 | 1006 |
| 997 | 1007 |
| 998 if __name__ == '__main__': | 1008 if __name__ == '__main__': |
| 999 fix_encoding.fix_encoding() | 1009 fix_encoding.fix_encoding() |
| 1000 if '-v' in sys.argv: | 1010 if '-v' in sys.argv: |
| 1001 unittest.TestCase.maxDiff = None | 1011 unittest.TestCase.maxDiff = None |
| 1002 logging.basicConfig( | 1012 logging.basicConfig( |
| 1003 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) | 1013 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) |
| 1004 unittest.main() | 1014 unittest.main() |
| OLD | NEW |