Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / build / packaging / link_dependencies_test.py
blobd4159e41ef92e540ff5ad36d94f5959ca0f2dcf4
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 from link_dependencies import extract_inputs, library_deps
7 import unittest
10 class ExtractInputsTest(unittest.TestCase):
11 def test_empty(self):
12 self.assertListEqual([], extract_inputs(''))
13 query_result = '\n'.join([
14 'header',
15 ' input: link',
16 ' outputs: nothing',
17 'footer'
19 self.assertListEqual([], extract_inputs(query_result))
21 def test_one_input(self):
22 query_result = '\n'.join([
23 'header',
24 ' input: link',
25 ' foo',
26 ' outputs: link',
27 ' quxx',
28 'footer'
30 self.assertListEqual(['foo'], extract_inputs(query_result))
32 def test_many_inputs(self):
33 query_result = '\n'.join([
34 'header',
35 ' input: link',
36 ' foo',
37 ' bar',
38 ' baz',
39 ' outputs:',
40 ' quxx',
41 'footer'
43 self.assertListEqual(['foo', 'bar', 'baz'], extract_inputs(query_result))
45 def test_no_pipe_inputs(self):
46 query_result = '\n'.join([
47 'header',
48 ' input: link',
49 ' |foo',
50 ' bar',
51 ' |baz',
52 ' outputs:',
53 ' quxx',
54 'footer'
56 self.assertListEqual(['bar'], extract_inputs(query_result))
58 def test_prefix(self):
59 query_result = '\n'.join([
60 'header',
61 ' input: link',
62 ' bar',
63 ' outputs:',
64 'footer'
66 self.assertListEqual(['foo/bar'],
67 extract_inputs(query_result, 'foo/'))
70 class LibraryDepsTest(unittest.TestCase):
71 def mkquery(self, answers):
72 """Creates a query function for library_deps.
74 Creates a query function for library_deps that returns answers from the
75 supplied map.
76 """
77 return lambda target, unused_workdir, unused_prefix='': answers[target]
79 def test_empty(self):
80 self.assertEqual(set(), library_deps([], 'wd', self.mkquery({})))
82 def test_nonarch(self):
83 deps = ['abc.a', 'def.o', 'abc.a']
84 self.assertEqual({'wd/abc.a', 'wd/def.o'},
85 library_deps(deps, 'wd', self.mkquery({})))
87 def test_arch(self):
88 dep_map = {'abc': ['wd/def.a', 'wd/ghi.o']}
89 deps = ['abc', 'jkl.o']
90 self.assertEqual({'wd/def.a', 'wd/ghi.o', 'wd/jkl.o'},
91 library_deps(deps, 'wd', self.mkquery(dep_map)))
93 def test_arch_many(self):
94 dep_map = {'abc': ['wd/def.o', 'wd/ghi.a'],
95 'def': ['wd/def.o', 'wd/jkl.a']}
96 deps = ['abc', 'def', 'def.o']
97 self.assertEqual({'wd/def.o', 'wd/ghi.a', 'wd/jkl.a'},
98 library_deps(deps, 'wd', self.mkquery(dep_map)))
101 if __name__ == '__main__':
102 unittest.main()