Commits

Anonymous committed d77731a

Windows portability in tests. Replace overlooked import

Comments (0)

Files changed (4)

src/engine/SCons/Node/FSTests.py

         self.fs.BuildDir(bld, src, duplicate=0)
         self.fs.BuildDir(sub2, src, duplicate=0)
 
-        s = map(str, src.srcdir_list())
-        assert s == [], s
-
-        s = map(str, bld.srcdir_list())
-        assert s == ['src'], s
-
-        s = map(str, sub1.srcdir_list())
-        assert s == ['src/sub'], s
-
-        s = map(str, sub2.srcdir_list())
-        assert s == ['src', 'src/sub/sub'], s
-
-        s = map(str, sub3.srcdir_list())
-        assert s == ['src/sub', 'src/sub/sub/sub'], s
+        def check(result, expect):
+            result = map(str, result)
+            expect = map(os.path.normpath, expect)
+            assert result == expect, result
+
+        s = src.srcdir_list()
+        check(s, [])
+
+        s = bld.srcdir_list()
+        check(s, ['src'])
+
+        s = sub1.srcdir_list()
+        check(s, ['src/sub'])
+
+        s = sub2.srcdir_list()
+        check(s, ['src', 'src/sub/sub'])
+
+        s = sub3.srcdir_list()
+        check(s, ['src/sub', 'src/sub/sub/sub'])
 
         self.fs.BuildDir('src/b1/b2', 'src')
         b1 = src.Dir('b1')
         b1_b2_b1_b2 = b1_b2_b1.Dir('b2')
         b1_b2_b1_b2_sub = b1_b2_b1_b2.Dir('sub')
 
-        s = map(str, b1.srcdir_list())
-        assert s == [], s
-
-        s = map(str, b1_b2.srcdir_list())
-        assert s == ['src'], s
-
-        s = map(str, b1_b2_b1.srcdir_list())
-        assert s == ['src/b1'], s
-
-        s = map(str, b1_b2_b1_b2.srcdir_list())
-        assert s == [], s
-
-        s = map(str, b1_b2_b1_b2_sub.srcdir_list())
-        assert s == [], s
+        s = b1.srcdir_list()
+        check(s, [])
+
+        s = b1_b2.srcdir_list()
+        check(s, ['src'])
+
+        s = b1_b2_b1.srcdir_list()
+        check(s, ['src/b1'])
+
+        s = b1_b2_b1_b2.srcdir_list()
+        check(s, [])
+
+        s = b1_b2_b1_b2_sub.srcdir_list()
+        check(s, [])
 
     def test_srcdir_duplicate(self):
         """Test the Dir.srcdir_duplicate() method
         assert not os.path.exists(test.workpath('bld0', 'does_not_exist'))
 
         n = bld0.srcdir_duplicate('exists', SCons.Node.FS.File)
-        assert str(n) == 'src0/exists', str(n)
+        assert str(n) == os.path.normpath('src0/exists'), str(n)
         assert not os.path.exists(test.workpath('bld0', 'exists'))
 
         test.subdir('src1')
         assert not os.path.exists(test.workpath('bld1', 'does_not_exist'))
 
         n = bld1.srcdir_duplicate('exists', SCons.Node.FS.File)
-        assert str(n) == 'bld1/exists', str(n)
+        assert str(n) == os.path.normpath('bld1/exists'), str(n)
         assert os.path.exists(test.workpath('bld1', 'exists'))
 
     def test_srcdir_find_file(self):
         exists = src0.File('exists-f')
         exists.exists = return_true
 
+        def check(result, expect):
+	    result = map(str, result)
+            expect = map(os.path.normpath, expect)
+            assert result == expect, result
+
         # First check from the source directory.
         n = src0.srcdir_find_file('does_not_exist')
         assert n == (None, None), n
 
         n = src0.srcdir_find_file('derived-f')
-        n = map(str, n)
-        assert n == ['src0/derived-f', 'src0'], n
+        check(n, ['src0/derived-f', 'src0'])
 
         n = src0.srcdir_find_file('pseudo-f')
-        n = map(str, n)
-        assert n == ['src0/pseudo-f', 'src0'], n
+        check(n, ['src0/pseudo-f', 'src0'])
 
         n = src0.srcdir_find_file('exists-f')
-        n = map(str, n)
-        assert n == ['src0/exists-f', 'src0'], n
+        check(n, ['src0/exists-f', 'src0'])
 
         n = src0.srcdir_find_file('on-disk-f1')
-        n = map(str, n)
-        assert n == ['src0/on-disk-f1', 'src0'], n
+        check(n, ['src0/on-disk-f1', 'src0'])
 
         # Now check from the build directory.
         n = bld0.srcdir_find_file('does_not_exist')
         assert n == (None, None), n
 
         n = bld0.srcdir_find_file('derived-f')
-        n = map(str, n)
-        assert n == ['src0/derived-f', 'bld0'], n
+        check(n, ['src0/derived-f', 'bld0'])
 
         n = bld0.srcdir_find_file('pseudo-f')
-        n = map(str, n)
-        assert n == ['src0/pseudo-f', 'bld0'], n
+        check(n, ['src0/pseudo-f', 'bld0'])
 
         n = bld0.srcdir_find_file('exists-f')
-        n = map(str, n)
-        assert n == ['src0/exists-f', 'bld0'], n
+        check(n, ['src0/exists-f', 'bld0'])
 
         n = bld0.srcdir_find_file('on-disk-f2')
-        n = map(str, n)
-        assert n == ['src0/on-disk-f2', 'bld0'], n
+        check(n, ['src0/on-disk-f2', 'bld0'])
 
 
         test.subdir('src1')
         assert n == (None, None), n
 
         n = src1.srcdir_find_file('derived-f')
-        n = map(str, n)
-        assert n == ['src1/derived-f', 'src1'], n
+        check(n, ['src1/derived-f', 'src1'])
 
         n = src1.srcdir_find_file('pseudo-f')
-        n = map(str, n)
-        assert n == ['src1/pseudo-f', 'src1'], n
+        check(n, ['src1/pseudo-f', 'src1'])
 
         n = src1.srcdir_find_file('exists-f')
-        n = map(str, n)
-        assert n == ['src1/exists-f', 'src1'], n
+        check(n, ['src1/exists-f', 'src1'])
 
         n = src1.srcdir_find_file('on-disk-f1')
-        n = map(str, n)
-        assert n == ['src1/on-disk-f1', 'src1'], n
+        check(n, ['src1/on-disk-f1', 'src1'])
 
         # Now check from the build directory.
         n = bld1.srcdir_find_file('does_not_exist')
         assert n == (None, None), n
 
         n = bld1.srcdir_find_file('derived-f')
-        n = map(str, n)
-        assert n == ['bld1/derived-f', 'src1'], n
+        check(n, ['bld1/derived-f', 'src1'])
 
         n = bld1.srcdir_find_file('pseudo-f')
-        n = map(str, n)
-        assert n == ['bld1/pseudo-f', 'src1'], n
+        check(n, ['bld1/pseudo-f', 'src1'])
 
         n = bld1.srcdir_find_file('exists-f')
-        n = map(str, n)
-        assert n == ['bld1/exists-f', 'src1'], n
+        check(n, ['bld1/exists-f', 'src1'])
 
         n = bld1.srcdir_find_file('on-disk-f2')
-        n = map(str, n)
-        assert n == ['bld1/on-disk-f2', 'bld1'], n
+        check(n, ['bld1/on-disk-f2', 'bld1'])
 
 class EntryTestCase(unittest.TestCase):
     def runTest(self):

src/engine/SCons/Platform/win32.py

 import os.path
 import string
 import sys
+import tempfile
 
 from SCons.Platform.posix import exitvalmap
 from SCons.Platform import TempFileMunge
 # Consequently, we need to just wipe out its value as follows>
 os.environ['QTDIR'] = ''
 test.run(chdir='work12', stderr=None, arguments='-n noqtdir=1')
-test.fail_test(not test.match_re(test.stderr(), r"""
+
+moc = test.where_is('moc')
+if moc:
+    import os.path
+    expect = """
+scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\)
+File "SConstruct", line \d+, in \?
+""" % os.path.dirname(os.path.dirname(moc))
+else:
+    expect = """
 scons: warning: Could not detect qt, using empty QTDIR
-""" + TestSCons.file_expr))
+File "SConstruct", line \d+, in \?
+"""
+
+test.fail_test(not test.match_re(test.stderr(), expect))
 
 test.pass_test()
 File "SConstruct", line 1, in ?
 """
 
+moc = test.where_is('moc')
+if moc:
+    import os.path
+    qt_err = """
+scons: warning: Could not detect qt, using moc executable as a hint (QTDIR=%s)
+File "SConstruct", line 1, in ?
+""" % os.path.dirname(os.path.dirname(moc))
+else:
+    qt_err = """
+scons: warning: Could not detect qt, using empty QTDIR
+File "SConstruct", line 1, in ?
+"""
+
 error_output = {
     'icl' : intel_license_warning,
     'intelc' : intel_license_warning,
-    'qt' : """
-scons: warning: Could not detect qt, using empty QTDIR
-File "SConstruct", line 1, in ?
-""",
+    'qt' : qt_err,
 }
 
 # An SConstruct for importing Tool names that have illegal characters
     if stderr != '' and stderr != error_output.get(tool, ''):
         print "Failed importing '%s', stderr:" % tool
         print stderr
-        failures.append[tool]
+        failures.append(tool)
 
 test.fail_test(len(failures))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.