Better test infrastructure for cleaning (-c) messages. (Kevin Quick)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 21 Sep 2004 22:29:07 +0000 (22:29 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 21 Sep 2004 22:29:07 +0000 (22:29 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1093 fdb21ef1-2011-0410-befe-b5e4ea1792b1

etc/TestSCons.py
src/CHANGES.txt
test/option-c.py
test/option-n.py

index 0a5469b00618b3a966fe3005310b21f11ab9f242..64bb90d8e0231f61eaf14723fc5dfe403571adc4 100644 (file)
@@ -165,18 +165,20 @@ class TestSCons(TestCommon):
             return None
         return env.Detect([prog])
 
-    def wrap_stdout(self, build_str = "", read_str = "", error = 0):
+    def wrap_stdout(self, build_str = "", read_str = "", error = 0, cleaning = 0):
         """Wraps standard output string(s) in the normal
         "Reading ... done" and "Building ... done" strings
         """
+        cap,lc = [ ('Build','build'),
+                   ('Clean','clean') ][cleaning]
         if error:
-            term = "scons: building terminated because of errors.\n"
+            term = "scons: %sing terminated because of errors.\n" % lc
         else:
-            term = "scons: done building targets.\n"
+            term = "scons: done %sing targets.\n" % lc
         return "scons: Reading SConscript files ...\n" + \
                read_str + \
                "scons: done reading SConscript files.\n" + \
-               "scons: Building targets ...\n" + \
+               "scons: %sing targets ...\n" % cap + \
                build_str + \
                term
 
index 502ef2a220de5358d10586dafa13257d36c94e68..71c03dc0fc84392d8c23bfd7ded3308e544abc20 100644 (file)
@@ -135,6 +135,8 @@ RELEASE 0.97 - XXX
   - Catch incidents of bad builder creation (without an action) and
     supply meaningful error messages.
 
+  - Better test infrastructure for -c output.
+
   From Christoph Wiedemann:
 
   - Add an Environment.SetDefault() method that only sets values if
index 26d40ea8e7e3ef4d43f2203dff29303c9975991e..30ec6f8ebe07c8e6a783304ce7462725bb8ce3d8 100644 (file)
@@ -72,15 +72,8 @@ test.fail_test(test.read(test.workpath('foo2.xxx')) != "foo2.in\n")
 test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
 test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
 
-def wrap_clean_stdout(string):
-    return "scons: Reading SConscript files ...\n" + \
-           "scons: done reading SConscript files.\n" + \
-           "scons: Cleaning targets ...\n" + \
-           string + \
-           "scons: done cleaning targets.\n"
-
 test.run(arguments = '-c foo1.out',
-         stdout = wrap_clean_stdout("Removed foo1.out\n"))
+         stdout = test.wrap_stdout("Removed foo1.out\n", cleaning=1))
 
 test.fail_test(os.path.exists(test.workpath('foo1.out')))
 test.fail_test(not os.path.exists(test.workpath('foo2.xxx')))
@@ -88,7 +81,8 @@ test.fail_test(not os.path.exists(test.workpath('foo2.out')))
 test.fail_test(not os.path.exists(test.workpath('foo3.out')))
 
 test.run(arguments = '--clean foo2.out foo2.xxx',
-         stdout = wrap_clean_stdout("Removed foo2.xxx\nRemoved foo2.out\n"))
+         stdout = test.wrap_stdout("Removed foo2.xxx\nRemoved foo2.out\n",
+                                   cleaning=1))
 
 test.fail_test(os.path.exists(test.workpath('foo1.out')))
 test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
@@ -96,7 +90,7 @@ test.fail_test(os.path.exists(test.workpath('foo2.out')))
 test.fail_test(not os.path.exists(test.workpath('foo3.out')))
 
 test.run(arguments = '--remove foo3.out',
-         stdout = wrap_clean_stdout("Removed foo3.out\n"))
+         stdout = test.wrap_stdout("Removed foo3.out\n", cleaning=1))
 
 test.fail_test(os.path.exists(test.workpath('foo1.out')))
 test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
@@ -115,7 +109,7 @@ if hasattr(os, 'symlink'):
     test.fail_test(not os.path.islink(test.workpath('symlink2')))
 
 test.run(arguments = '-c foo2.xxx',
-         stdout = wrap_clean_stdout("Removed foo2.xxx\n"))
+         stdout = test.wrap_stdout("Removed foo2.xxx\n", cleaning=1))
 
 test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
 test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
@@ -134,11 +128,11 @@ if hasattr(os, 'symlink'):
 
 test.run(arguments = 'foo1.out foo2.out foo3.out')
 
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
 Removed foo2.xxx
 Removed foo2.out
 Removed foo3.out
-""")
+""", cleaning=1)
 
 test.run(arguments = '-c -n foo1.out foo2.out foo3.out', stdout = expect)
 
@@ -152,7 +146,7 @@ test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
 test.writable('.', 0)
 f = open(test.workpath('foo1.out'))
 test.run(arguments = '-c foo1.out',
-         stdout = wrap_clean_stdout("scons: Could not remove 'foo1.out': Permission denied\n"))
+         stdout = test.wrap_stdout("scons: Could not remove 'foo1.out': Permission denied\n", cleaning=1))
 test.fail_test(not os.path.exists(test.workpath('foo1.out')))
 f.close()
 test.writable('.', 1)
@@ -179,37 +173,40 @@ test.write(['subd', 'SConscript'], """
 Clean('.', 'foox.in')
 """)
 
-expect = wrap_clean_stdout("""Removed foo2.xxx
+expect = test.wrap_stdout("""Removed foo2.xxx
 Removed aux1.x
 Removed aux2.x
-""")
+""", cleaning=1)
 test.run(arguments = '-c foo2.xxx', stdout=expect)
 test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
 test.fail_test(os.path.exists(test.workpath('foo2.xxx')))
 test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
 test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
 
-expect = wrap_clean_stdout("Removed %s\n" % os.path.join('subd', 'foox.in'))
+expect = test.wrap_stdout("Removed %s\n" % os.path.join('subd', 'foox.in'),
+                          cleaning = 1)
 test.run(arguments = '-c subd', stdout=expect)
 test.fail_test(os.path.exists(test.workpath('foox.in')))
 
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
 Removed foo2.xxx
 Removed foo2.out
 Removed foo3.out
 Removed %s
 Removed %s
 Removed directory subd
-""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')))
+""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')),
+                          cleaning = 1)
 test.run(arguments = '-c -n .', stdout=expect)
 
-expect = wrap_clean_stdout("""Removed foo1.out
+expect = test.wrap_stdout("""Removed foo1.out
 Removed foo2.out
 Removed foo3.out
 Removed %s
 Removed %s
 Removed directory subd
-""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')))
+""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')),
+                          cleaning = 1)
 test.run(arguments = '-c .', stdout=expect)
 test.fail_test(os.path.exists(test.workpath('subdir', 'foon.in')))
 test.fail_test(os.path.exists(test.workpath('subdir')))
index 8730c8352c869ec2e118f9a13bef4f57a4e381ec..aa0b8f2ef3a620737a60b9c2f7aab204178903c0 100644 (file)
@@ -125,14 +125,7 @@ test.write('f1.out', "X1.out\n")
 test.run(arguments = '-n f1.out', stdout = expect)
 test.run(arguments = '-n f1.out', stdout = expect)
 
-def wrap_clean_stdout(string):
-    return "scons: Reading SConscript files ...\n" + \
-           "scons: done reading SConscript files.\n" + \
-           "scons: Cleaning targets ...\n" + \
-           string + \
-           "scons: done cleaning targets.\n"
-
-expect = wrap_clean_stdout("Removed f1.out\nRemoved f2.out\n")
+expect = test.wrap_stdout("Removed f1.out\nRemoved f2.out\n", cleaning=1)
 
 test.run(arguments = '-n -c ' + args, stdout = expect)