Make the 'Do not know how to build' error message catch more cases. (Anthony Roach)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 16 Dec 2002 16:05:47 +0000 (16:05 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 16 Dec 2002 16:05:47 +0000 (16:05 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@524 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Script/__init__.py
test/SideEffect.py
test/nonexistent.py
test/option--U.py

index 38fa1a7ece733b863de4807460506ef465faf968..6edfe9d1613a69c6c0ec0488d29fcee0f11459ed 100644 (file)
@@ -22,9 +22,10 @@ RELEASE 0.10 - XXX
   - Convert the .sconsign file format from ASCII to a pickled Python
     data structure.
 
-  - Made consistent the format of error messages (now all start with
-    "scons: ***") and warning messages (now all start with "scons:
-    warning:").
+  - Error message cleanups:  Made consistent the format of error
+    messages (now all start with "scons: ***") and warning messages (now
+    all start with "scons: warning:").  Caught more cases with the "Do
+    not know how to build" error message.
 
 
 
index c22cd374dc304e9fc20ea6292a3072da89355794..ad1a6411ee406c602c928ac505f5a1c13423c6ad 100644 (file)
@@ -73,8 +73,9 @@ from SCons.Optik import OptionParser, SUPPRESS_HELP, OptionValueError
 class BuildTask(SCons.Taskmaster.Task):
     """An SCons build task."""
     def execute(self):
-        if self.targets[0].get_state() == SCons.Node.up_to_date:
-            if self.top:
+        t = self.targets[0]
+        if t.get_state() == SCons.Node.up_to_date:
+            if self.top and t.builder:
                 display('scons: "%s" is up to date.' % str(self.targets[0]))
         else:
             if print_time:
@@ -86,10 +87,31 @@ class BuildTask(SCons.Taskmaster.Task):
                 command_time = command_time+finish_time-start_time
                 print "Command execution time: %f seconds"%(finish_time-start_time)
 
+    def do_failed(self):
+        if ignore_errors:
+            SCons.Taskmaster.Task.executed(self)
+        elif keep_going_on_error:
+            SCons.Taskmaster.Task.fail_continue(self)
+            exit_status = 2
+        else:
+            SCons.Taskmaster.Task.fail_stop(self)
+            exit_status = 2
+            
     def executed(self):
-        SCons.Taskmaster.Task.executed(self)
-        if not self.targets[0].builder and self.top:
-            print "scons: Nothing to be done for `%s'." % str(self.targets[0])
+        t = self.targets[0]
+        if self.top and not t.builder and not t.side_effect:
+            if not t.exists():
+                sys.stderr.write("scons: *** Do not know how to make target `%s'." % t)
+                if not keep_going_on_error:
+                    sys.stderr.write("  Stop.")
+                sys.stderr.write("\n")
+                self.do_failed()
+            else:
+                print "scons: Nothing to be done for `%s'." % t
+                SCons.Taskmaster.Task.executed(self)
+        else:
+            SCons.Taskmaster.Task.executed(self)
+                
         # print the tree here instead of in execute() because
         # this method is serialized, but execute isn't:
         if print_tree and self.top:
@@ -119,15 +141,8 @@ class BuildTask(SCons.Taskmaster.Task):
             sys.stderr.write("scons: *** %s\n" % s)
         else:
             sys.stderr.write("scons: *** %s\n" % e)
-        
-        if ignore_errors:
-            SCons.Taskmaster.Task.executed(self)
-        elif keep_going_on_error:
-            SCons.Taskmaster.Task.fail_continue(self)
-            exit_status = 2
-        else:
-            SCons.Taskmaster.Task.fail_stop(self)
-            exit_status = 2
+
+        self.do_failed()
 
 class CleanTask(SCons.Taskmaster.Task):
     """An SCons clean task."""
@@ -782,21 +797,11 @@ def _main():
         if isinstance(x, SCons.Node.Node):
             node = x
         else:
-            try:
-                node = SCons.Node.Alias.default_ans.lookup(x)
-                if node is None:
-                    node = SCons.Node.FS.default_fs.Entry(x,
-                                                          directory = top,
-                                                          create = 0)
-            except UserError:
-                string = "scons: *** Do not know how to make target `%s'." % x
-                if not keep_going_on_error:
-                    sys.stderr.write(string + "  Stop.\n")
-                    sys.exit(2)
-                sys.stderr.write(string + "\n")
-                global exit_status
-                exit_status = 2
-                node = None
+            node = SCons.Node.Alias.default_ans.lookup(x)
+            if node is None:
+                node = SCons.Node.FS.default_fs.Entry(x,
+                                                      directory = top,
+                                                      create = 1)
         if top and not node.is_under(top):
             if isinstance(node, SCons.Node.FS.Dir) and top.is_under(node):
                 node = top
index 3f3b75d8d2e4a8bd2ecd19ea9c71d1a72b04efc9..29acb835f8b75dc34312ed1eafecc155966be489 100644 (file)
@@ -70,7 +70,6 @@ test.write('bar.in', 'bar.in 2 \n')
 test.run(arguments = 'log.txt', stdout=test.wrap_stdout("""\
 copy() < bar.in > bar.out
 copy() < blat.in > blat.out
-scons: Nothing to be done for `log.txt'.
 """))
 
 expect = """\
index 6219c1c6f45cfc0d7bb13c74c86d4dc12bf5cf3b..57bf5e13c7864a6de43fa56c56e5303e5c4c8f9b 100644 (file)
@@ -38,6 +38,8 @@ test.write('SConstruct', """
 env = Environment()
 env.Command("aaa.out", "aaa.in", "should never get executed")
 env.Command("bbb.out", "bbb.in", "should never get executed")
+File('xxx')
+Dir('ddd')
 """)
 
 test.run(arguments = 'foo',
@@ -46,7 +48,6 @@ test.run(arguments = 'foo',
 
 test.run(arguments = '-k foo/bar foo',
          stderr = """scons: *** Do not know how to make target `foo/bar'.
-scons: *** Do not know how to make target `foo'.
 """,
          status = 2)
 
@@ -60,4 +61,33 @@ scons: *** No Builder for target `aaa.in', needed by `aaa.out'.
 """,
          status = 2)
 
+test.run(arguments = '-k aaa.in bbb.in',
+         stderr = """scons: *** Do not know how to make target `aaa.in'.
+scons: *** Do not know how to make target `bbb.in'.
+""",
+         status = 2)
+
+
+test.run(arguments = 'xxx',
+         stderr = "scons: *** Do not know how to make target `xxx'.  Stop.\n",
+         status = 2)
+
+test.run(arguments = 'ddd')
+
+
+# Make sure that SCons doesn't print up-to-date messages for non-derived files that exist:
+test.write('SConstruct', """
+File('xxx')
+""")
+
+test.write('xxx', "xxx")
+
+test.run(arguments='xxx', stdout=test.wrap_stdout("""\
+scons: Nothing to be done for `xxx'.
+"""))
+         
+test.run(arguments='xxx', stdout=test.wrap_stdout("""\
+scons: Nothing to be done for `xxx'.
+"""))
+
 test.pass_test()
index 4e8b408bd10a76c241aa1689c6818298fb7aa919..d700267b425c17781033d358c36e6e834fcda1b1 100644 (file)
@@ -144,10 +144,11 @@ Default('.')
 test.run(chdir = 'sub4', arguments = '-U')
 
 test.write('SConstruct', """
-Default('no_a_target.in')
+Default('not_a_target.in')
 """)
 
-# The following should result in an error, but because of bug 642327, it doesn't:
-test.run(arguments = '-U')
+test.run(arguments = '-U', status=2, stderr="""\
+scons: *** Do not know how to make target `not_a_target.in'.  Stop.
+""")
 
 test.pass_test()