Commits

Greg Ward committed 26877f8

Add more tests for SCons.Tool.javac.pathopt; fix exposed bugs.
(Specifically, having a default path without setting the corresponding
construction variable did not work.)

  • Participants
  • Parent commits cf54d0b

Comments (0)

Files changed (2)

File src/engine/SCons/Tool/javac.py

         if path and not SCons.Util.is_List(path):
             path = [path]
         if self.default:
-            path = path + [ env[self.default] ]
+            default = env[self.default]
+            if default:
+                if not SCons.Util.is_List(default):
+                    default = [default]
+                path = path + default
         if path:
             return [self.opt, os.pathsep.join(map(str, path))]
             #return self.opt + " " + os.pathsep.join(path)

File src/engine/SCons/Tool/javacTests.py

         actual = popt(None, None, env, None)
         self.assertEquals(expect, actual)
 
+    def assert_pathopt_default(self, expect, path, default):
+        popt = SCons.Tool.javac.pathopt('-foopath', 'FOOPATH', default='DPATH')
+        env = {'FOOPATH': path,
+               'DPATH': default}
+        actual = popt(None, None, env, None)
+        self.assertEquals(expect, actual)
+
     def test_unset(self):
         self.assert_pathopt([], None)
         self.assert_pathopt([], '')
         self.assert_pathopt(['-foopath', '/foo:/bar'],
                             ['/foo', DummyNode('/bar')])
 
-    def test_default(self):
-        popt = SCons.Tool.javac.pathopt('-foopath', 'FOOPATH', default='DPATH')
-        env = {'FOOPATH': ['/foo', '/bar'],
-               'DPATH': '/baz'}
+    def test_default_str(self):
+        self.assert_pathopt_default(
+            ['-foopath', '/foo:/bar:/baz'],
+            ['/foo', '/bar'],
+            '/baz')
 
-        expect = ['-foopath', os.pathsep.join(['/foo', '/bar', '/baz'])]
-        actual = popt(None, None, env, None)
-        self.assertEquals(expect, actual)
+    def test_default_list(self):
+        self.assert_pathopt_default(
+            ['-foopath', '/foo:/bar:/baz'],
+            ['/foo', '/bar'],
+            ['/baz'])
+
+    def test_default_unset(self):
+        self.assert_pathopt_default(
+            ['-foopath', '/foo'],
+            '/foo',
+            None)
+        self.assert_pathopt_default(
+            ['-foopath', '/foo'],
+            '/foo',
+            '')
 
 if __name__ == "__main__":
     unittest.main()