Windows portability in tests. Replace overlooked import
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 17 Mar 2005 03:06:56 +0000 (03:06 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 17 Mar 2005 03:06:56 +0000 (03:06 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1255 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FSTests.py
src/engine/SCons/Platform/win32.py
test/QT/QT.py
test/import.py

index 1d7d926e50ca0c77ffcbd91b5d76461bca559632..613626bafacdf8c2bf9e553454f33c3f6a564fcc 100644 (file)
@@ -1212,20 +1212,25 @@ class DirTestCase(_tempdirTestCase):
         self.fs.BuildDir(bld, src, duplicate=0)
         self.fs.BuildDir(sub2, src, duplicate=0)
 
-        s = map(str, src.srcdir_list())
-        assert s == [], s
+        def check(result, expect):
+            result = map(str, result)
+            expect = map(os.path.normpath, expect)
+            assert result == expect, result
 
-        s = map(str, bld.srcdir_list())
-        assert s == ['src'], s
+        s = src.srcdir_list()
+        check(s, [])
 
-        s = map(str, sub1.srcdir_list())
-        assert s == ['src/sub'], s
+        s = bld.srcdir_list()
+        check(s, ['src'])
 
-        s = map(str, sub2.srcdir_list())
-        assert s == ['src', 'src/sub/sub'], s
+        s = sub1.srcdir_list()
+        check(s, ['src/sub'])
 
-        s = map(str, sub3.srcdir_list())
-        assert s == ['src/sub', 'src/sub/sub/sub'], s
+        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')
@@ -1234,20 +1239,20 @@ class DirTestCase(_tempdirTestCase):
         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 = b1.srcdir_list()
+        check(s, [])
 
-        s = map(str, b1_b2.srcdir_list())
-        assert s == ['src'], s
+        s = b1_b2.srcdir_list()
+        check(s, ['src'])
 
-        s = map(str, b1_b2_b1.srcdir_list())
-        assert s == ['src/b1'], s
+        s = b1_b2_b1.srcdir_list()
+        check(s, ['src/b1'])
 
-        s = map(str, b1_b2_b1_b2.srcdir_list())
-        assert s == [], s
+        s = b1_b2_b1_b2.srcdir_list()
+        check(s, [])
 
-        s = map(str, b1_b2_b1_b2_sub.srcdir_list())
-        assert s == [], s
+        s = b1_b2_b1_b2_sub.srcdir_list()
+        check(s, [])
 
     def test_srcdir_duplicate(self):
         """Test the Dir.srcdir_duplicate() method
@@ -1266,7 +1271,7 @@ class DirTestCase(_tempdirTestCase):
         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')
@@ -1281,7 +1286,7 @@ class DirTestCase(_tempdirTestCase):
         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):
@@ -1306,45 +1311,42 @@ class DirTestCase(_tempdirTestCase):
         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')
@@ -1367,40 +1369,32 @@ class DirTestCase(_tempdirTestCase):
         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):
index 382e5b8d233b6b255746e6f2c0b06aa78a9ecb1e..58e06dafc2dcd5eeb78c37b78a733370eefe3076 100644 (file)
@@ -36,6 +36,7 @@ import os
 import os.path
 import string
 import sys
+import tempfile
 
 from SCons.Platform.posix import exitvalmap
 from SCons.Platform import TempFileMunge
index 680784f5f079c76603dfadc721cf2b34d884b6da..a6580a6ddcdb29ffe9b3e07332e217c85288c383 100644 (file)
@@ -923,8 +923,20 @@ test.run(chdir='work12', arguments='-n noqtdir=1')
 # 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()
index 1aae7ce1bd94fbcdfa8ccc5f27084c2af75cc011..5bf2042e2f8a027faa536faf26c913b6f2840f4e 100644 (file)
@@ -140,13 +140,23 @@ scons: warning: Intel license dir was not found.  Tried using the INTEL_LICENSE_
 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
@@ -176,7 +186,7 @@ for tool in tools:
     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))