From: stevenknight Date: Wed, 12 Sep 2001 02:20:03 +0000 (+0000) Subject: Fixes for -f end cases. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d4d8e623acd23bf1035ad78c067219927acbec87;p=scons.git Fixes for -f end cases. git-svn-id: http://scons.tigris.org/svn/scons/trunk@45 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/scons.py b/src/scons.py index f515beaf..16fb0bf3 100644 --- a/src/scons.py +++ b/src/scons.py @@ -516,7 +516,15 @@ def main(): 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 diff --git a/test/errors.py b/test/errors.py index 04eac9e5..a4b05cc6 100644 --- a/test/errors.py +++ b/test/errors.py @@ -49,7 +49,7 @@ expect = r"""Traceback \((most recent call|innermost) last\): 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 diff --git a/test/option-f.py b/test/option-f.py index 4ea2ee9b..b9dbd75f 100644 --- a/test/option-f.py +++ b/test/option-f.py @@ -27,26 +27,45 @@ wpath = test.workpath() 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()