Commits

Anonymous committed 96f0e9c

Fixes for -f end cases.

  • Participants
  • Parent commits aec2f94

Comments (0)

Files changed (3)

 
     while Scripts:
         file, Scripts = Scripts[0], Scripts[1:]
-        execfile(file)
+	if file == "-":
+	    exec sys.stdin
+	else:
+            try:
+		f = open(file, "r")
+	    except IOError, s:
+		sys.stderr.write("Ignoring missing script '%s'\n" % file)
+	    else:
+		exec f 
 
     if local_help:
 	# They specified -h, but there was no Help() inside the
   File "%s", line \d+, in \?
     main\(\)
   File "%s", line \d+, in main
-    execfile\(file\)
+    exec f
   File "SConstruct3", line \d+, in \?
     raise InternalError, 'error inside'
 InternalError: error inside
 
 test.run(chdir = '.', arguments = '-f SConscript')
 test.fail_test(test.stdout() != ("SConscript %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '-f ' + subdir_BuildThis)
 test.fail_test(test.stdout() != ("subdir/BuildThis %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--file=SConscript')
 test.fail_test(test.stdout() != ("SConscript %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--file=' + subdir_BuildThis)
 test.fail_test(test.stdout() != ("subdir/BuildThis %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--makefile=SConscript')
 test.fail_test(test.stdout() != ("SConscript %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--makefile=' + subdir_BuildThis)
 test.fail_test(test.stdout() != ("subdir/BuildThis %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--sconstruct=SConscript')
 test.fail_test(test.stdout() != ("SConscript %s\n" % wpath))
+test.fail_test(test.stderr() != "")
 
 test.run(chdir = '.', arguments = '--sconstruct=' + subdir_BuildThis)
 test.fail_test(test.stdout() != ("subdir/BuildThis %s\n" % wpath))
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '-f -', stdin = """
+import os
+print "STDIN " + os.getcwd()
+""")
+test.fail_test(test.stdout() != ("STDIN %s\n" % wpath))
+test.fail_test(test.stderr() != "")
+
+test.run(chdir = '.', arguments = '-f no_such_file')
+test.fail_test(test.stdout() != "")
+test.fail_test(test.stderr() != "Ignoring missing script 'no_such_file'\n")
 
 test.pass_test()