Anonymous avatar Anonymous committed 8425c00

Error message if no SConstruct file.

Comments (0)

Files changed (4)

 	    print "STDERR ============"
 	    print self.stderr()
 	    raise TestFailed
-	if stdout and not self.match(self.stdout(), stdout):
+	if not stdout is None and not self.match(self.stdout(), stdout):
 	    print "Expected STDOUT =========="
 	    print stdout
 	    print "Actual STDOUT ============"
 		print "STDERR ==================="
 		print stderr
 	    raise TestFailed
-	if stderr and not self.match(self.stderr(), stderr):
+	if not stderr is None and not self.match(self.stderr(), stderr):
 	    print "Expected STDERR =========="
 	    print stderr
 	    print "Actual STDERR ============"

src/script/scons.py

     """Handle user errors. Print out a message and a description of the
     error, along with the line number and routine where it occured.
     """
-    print 'user error'
     etype, value, tb = sys.exc_info()
     while tb.tb_next is not None:
         tb = tb.tb_next
                 Scripts.append(file)
                 break
 
-    if local_help and not Scripts:
-	# They specified -h, but there's no SConstruct.  Give them
-	# the options usage before we try to read it and fail.
-	PrintUsage()
-	sys.exit(0)
+    if not Scripts:
+	if local_help:
+	    # There's no SConstruct, but they specified -h.  Give them
+	    # the options usage before we try to read it and fail.
+	    PrintUsage()
+	    sys.exit(0)
+	else:
+	    raise UserError, "No SConstruct file found."
 
     # XXX The commented-out code here adds any "scons" subdirs in anything
     # along sys.path to sys.path.  This was an attempt at setting up things

test/SConstruct.py

 
 test = TestSCons.TestSCons()
 
+test.run(stdout = "",
+	stderr = """
+SCons error: No SConstruct file found.
+File "\S+scons(\.py)?", line \d+, in main
+""")
+
 wpath = test.workpath()
 
 test.write('sconstruct', """
 a ! x
 """)
 
-test.run(arguments='-f SConstruct1', stderr = """  File "SConstruct1", line 2
+test.run(arguments='-f SConstruct1',
+	 stdout = "",
+	 stderr = """  File "SConstruct1", line 2
 
     a ! x
 
 test.write('SConstruct2', """
 raise UserError, 'Depends() require both sources and targets.'
 """)
-test.run(arguments='-f SConstruct2', stderr = """
+
+test.run(arguments='-f SConstruct2',
+	 stdout = "",
+	 stderr = """
 SCons error: Depends\(\) require both sources and targets.
 File "SConstruct2", line 2, in \?
 """)
 test.write('SConstruct3', """
 raise InternalError, 'error inside'
 """)
-test.run(arguments='-f SConstruct3', stderr = r"""Traceback \((most recent call|innermost) last\):
+
+test.run(arguments='-f SConstruct3',
+	 stdout = "other errors\n",
+	 stderr = r"""Traceback \((most recent call|innermost) last\):
   File ".*scons(\.py)?", line \d+, in \?
     main\(\)
   File ".*scons(\.py)?", line \d+, in main
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.