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
10 class ExtractInputsTest(unittest
.TestCase
):
12 self
.assertListEqual([], extract_inputs(''))
13 query_result
= '\n'.join([
19 self
.assertListEqual([], extract_inputs(query_result
))
21 def test_one_input(self
):
22 query_result
= '\n'.join([
30 self
.assertListEqual(['foo'], extract_inputs(query_result
))
32 def test_many_inputs(self
):
33 query_result
= '\n'.join([
43 self
.assertListEqual(['foo', 'bar', 'baz'], extract_inputs(query_result
))
45 def test_no_pipe_inputs(self
):
46 query_result
= '\n'.join([
56 self
.assertListEqual(['bar'], extract_inputs(query_result
))
58 def test_prefix(self
):
59 query_result
= '\n'.join([
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
77 return lambda target
, unused_workdir
, unused_prefix
='': answers
[target
]
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({})))
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__':