X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Ftools%2Fswarming_client%2Ftests%2Fisolateserver_test.py;h=dba06ef569141475bc1a5ef454a8d79ed20cc5c7;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=e8e8f1dec9e9b074c6e876ab4e6d2001ec587f22;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/tools/swarming_client/tests/isolateserver_test.py b/src/tools/swarming_client/tests/isolateserver_test.py index e8e8f1d..dba06ef 100755 --- a/src/tools/swarming_client/tests/isolateserver_test.py +++ b/src/tools/swarming_client/tests/isolateserver_test.py @@ -25,6 +25,7 @@ sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party')) from depot_tools import auto_stub import isolateserver +import test_utils from utils import threading_utils @@ -1031,14 +1032,13 @@ class TestArchive(TestCase): finally: os.chdir(old_cwd) - def test_archive_directory(self): + def help_test_archive(self, cmd_line_prefix): old_cwd = os.getcwd() try: os.chdir(ROOT_DIR) self.mock(isolateserver, 'get_storage', get_storage) p = os.path.join(TEST_DIR, 'isolateserver') - isolateserver.main( - ['archive', '--isolate-server', 'https://localhost:1', p]) + isolateserver.main(cmd_line_prefix + [p]) # TODO(maruel): The problem here is that the test depends on the file mode # of the files in this directory. # Fix is to copy the files in a temporary directory with known file modes. @@ -1051,10 +1051,59 @@ class TestArchive(TestCase): finally: os.chdir(old_cwd) + def test_archive_directory(self): + self.help_test_archive(['archive', '--isolate-server', + 'https://localhost:1']) + + def test_archive_directory_envvar(self): + with test_utils.EnvVars({'ISOLATE_SERVER': 'https://localhost:1'}): + self.help_test_archive(['archive']) + + +class OptionsTest(unittest.TestCase): + def test_isolate_server(self): + data = [ + (['-I', 'http://foo.com/'], 'http://foo.com'), + (['-I', 'https://foo.com/'], 'https://foo.com'), + (['-I', 'https://foo.com'], 'https://foo.com'), + (['-I', 'https://foo.com/a'], 'https://foo.com/a'), + (['-I', 'https://foo.com/a/'], 'https://foo.com/a'), + (['-I', 'https://foo.com:8080/a/'], 'https://foo.com:8080/a'), + (['-I', 'foo.com'], 'https://foo.com'), + (['-I', 'foo.com:8080'], 'https://foo.com:8080'), + (['-I', 'foo.com/'], 'https://foo.com'), + (['-I', 'foo.com/a/'], 'https://foo.com/a'), + ] + for value, expected in data: + parser = isolateserver.OptionParserIsolateServer() + isolateserver.add_isolate_server_options(parser, False) + options, _ = parser.parse_args(value) + isolateserver.process_isolate_server_options(parser, options) + self.assertEqual(expected, options.isolate_server) + + def test_indir(self): + data = [ + (['-I', 'http://foo.com/'], ('http://foo.com', None)), + (['--indir', ROOT_DIR], ('', ROOT_DIR)), + ] + for value, (expected_isolate_server, expected_indir) in data: + parser = isolateserver.OptionParserIsolateServer() + isolateserver.add_isolate_server_options(parser, True) + options, _ = parser.parse_args(value) + isolateserver.process_isolate_server_options(parser, options) + self.assertEqual(expected_isolate_server, options.isolate_server) + self.assertEqual(expected_indir, options.indir) + + +def clear_env_vars(): + for e in ('ISOLATE_DEBUG', 'ISOLATE_SERVER'): + os.environ.pop(e, None) + if __name__ == '__main__': if '-v' in sys.argv: unittest.TestCase.maxDiff = None logging.basicConfig( level=(logging.DEBUG if '-v' in sys.argv else logging.ERROR)) + clear_env_vars() unittest.main()