4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 import SCons
.Tool
.javac
30 def __init__(self
, val
) -> None:
33 def __str__(self
) -> str:
36 class pathoptTestCase(unittest
.TestCase
):
37 def assert_pathopt(self
, expect
, path
) -> None:
38 popt
= SCons
.Tool
.javac
.pathopt('-foopath', 'FOOPATH')
39 env
= {'FOOPATH': path
}
40 actual
= popt(None, None, env
, None)
41 self
.assertEqual(expect
, actual
)
43 def assert_pathopt_default(self
, expect
, path
, default
) -> None:
44 popt
= SCons
.Tool
.javac
.pathopt('-foopath', 'FOOPATH', default
='DPATH')
45 env
= {'FOOPATH': path
,
47 actual
= popt(None, None, env
, None)
48 self
.assertEqual(expect
, actual
)
50 def test_unset(self
) -> None:
51 self
.assert_pathopt([], None)
52 self
.assert_pathopt([], '')
54 def test_str(self
) -> None:
55 self
.assert_pathopt(['-foopath', '/foo/bar'],
58 def test_list_str(self
) -> None:
59 self
.assert_pathopt(['-foopath', '/foo%s/bar' % os
.pathsep
],
62 def test_uses_pathsep(self
) -> None:
66 self
.assert_pathopt(['-foopath', 'foo!bar'],
71 def test_node(self
) -> None:
72 self
.assert_pathopt(['-foopath', '/foo'],
75 def test_list_node(self
) -> None:
76 self
.assert_pathopt(['-foopath', os
.pathsep
.join(['/foo','/bar'])],
77 ['/foo', DummyNode('/bar')])
79 def test_default_str(self
) -> None:
80 self
.assert_pathopt_default(
81 ['-foopath', os
.pathsep
.join(['/foo','/bar','/baz'])],
85 def test_default_list(self
) -> None:
86 self
.assert_pathopt_default(
87 ['-foopath', os
.pathsep
.join(['/foo','/bar','/baz'])],
91 def test_default_unset(self
) -> None:
92 self
.assert_pathopt_default(
96 self
.assert_pathopt_default(
101 def test_list_within_list(self
) -> None:
102 self
.assert_pathopt(['-foopath', os
.pathsep
.join(['/foo','/bar'])],
106 if __name__
== "__main__":