def testParseDepsOs(self): result = deps_parser.ParseDEPSContent('', keys=['deps_os']) self.assertEqual(1, len(result)) self.assertEqual({}, result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" vars = { 'cr_repo': 'https://cr.repo', 'a': '1', } deps_os = { 'win': { 'depA': Var('cr_repo') + '/a.git' + '@' + Var('a'), }, 'unix': { 'depA': None, } }"""), keys=['deps_os']) expected_deps_os = { 'win': { 'depA': 'https://cr.repo/a.git@1' }, 'unix': { 'depA': None } } self.assertEqual(1, len(result)) self.assertEqual(expected_deps_os, result[0])
def testParseHooks(self): result = deps_parser.ParseDEPSContent('', keys=['hooks']) self.assertEqual(1, len(result)) self.assertEqual([], result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" hooks = [ { # testing 'name': 'testing', 'pattern': '.', 'action': [ 'python', 'src/test.py', ], }, ]"""), keys=['hooks']) expected_hooks = [ { 'name': 'testing', 'pattern': '.', 'action': [ 'python', 'src/test.py', ], }, ] self.assertEqual(1, len(result)) self.assertEqual(expected_hooks, result[0])
def testBuildspecDEPSContentParsing(self): """Tests buildspec format parsing.""" result = deps_parser.ParseDEPSContent('', keys=['deps']) self.assertEqual(1, len(result)) self.assertEqual({}, result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" vars = { 'cr_repo': 'https://cr.repo', 'chrome_git': 'https://chrome', 'revision': '1', } deps = { 'depA': { 'url': '{cr_repo}/a.git@{revision}', }, 'depB': { 'url': '{chrome_git}/a.git@123' }, }"""), keys=['deps']) expected_deps = { 'depA': 'https://cr.repo/a.git@1', 'depB': 'https://chrome/a.git@123', } self.assertEqual(1, len(result)) self.assertEqual(expected_deps, result[0])
def testParseSkipChildIncludes(self): result = deps_parser.ParseDEPSContent('', keys=['skip_child_includes']) self.assertEqual(1, len(result)) self.assertEqual([], result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" skip_child_includes = [ 'breakpad', ]"""), keys=['skip_child_includes']) expected_skip_child_includes = ['breakpad'] self.assertEqual(1, len(result)) self.assertEqual(expected_skip_child_includes, result[0])
def testParseIncludeRules(self): result = deps_parser.ParseDEPSContent('', keys=['include_rules']) self.assertEqual(1, len(result)) self.assertEqual([], result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" include_rules = [ '+base', ]"""), keys=['include_rules']) expected_include_rules = ['+base'] self.assertEqual(1, len(result)) self.assertEqual(expected_include_rules, result[0])
def testParseAllowedHosts(self): result = deps_parser.ParseDEPSContent('', keys=['allowed_hosts']) self.assertEqual(1, len(result)) self.assertEqual([], result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" allowed_hosts = [ 'host1', 'host2', ]"""), keys=['allowed_hosts']) expected_allowed_hosts = ['host1', 'host2'] self.assertEqual(1, len(result)) self.assertEqual(expected_allowed_hosts, result[0])
def testParseVars(self): result = deps_parser.ParseDEPSContent('', keys=['vars']) self.assertEqual(1, len(result)) self.assertEqual({}, result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" vars = { 'a': '1', 'b': '2', }"""), keys=['vars']) expected_vars = {'a': '1', 'b': '2'} self.assertEqual(1, len(result)) self.assertEqual(expected_vars, result[0])
def testParseDeps(self): result = deps_parser.ParseDEPSContent('', keys=['deps']) self.assertEqual(1, len(result)) self.assertEqual({}, result[0]) result = deps_parser.ParseDEPSContent(textwrap.dedent(""" vars = { 'cr_repo': 'https://cr.repo', 'a': '1', } deps = { 'depA': Var('cr_repo') + '/a.git' + '@' + Var('a'), 'src-internal': { 'url': 'https://cr-internal_repo@1234', 'condition': 'checkout_src_internal', }, 'src/dep': { 'url': '{cr_repo}/dep.git', 'revision': 'deadbeef', }, 'a-cipd-package': { 'packages': [ { 'version': 'version:1.2.3-cr0', 'package': 'some/package' } ], 'dep_type': 'cipd', 'condition': 'checkout_android' } }"""), keys=['deps']) expected_deps = { 'depA': 'https://cr.repo/a.git@1', 'src-internal': 'https://cr-internal_repo@1234', 'src/dep': 'https://cr.repo/dep.git@deadbeef', } self.assertEqual(1, len(result)) self.assertEqual(expected_deps, result[0])