diff options
author | Dirk Baechle <dl9obn@darc.de> | 2014-09-28 10:27:01 (GMT) |
---|---|---|
committer | Dirk Baechle <dl9obn@darc.de> | 2014-09-28 10:27:01 (GMT) |
commit | 072430f48c21dfc9dfa0b26c6aa9a7b1d4ec3fc7 (patch) | |
tree | fe2335a95aad209cbf36ed71f4f6bc825efa4e3d /test/Interactive | |
parent | 03a83a3d4cb16181642bd85b72d70f26d79ee290 (diff) | |
download | SCons-072430f48c21dfc9dfa0b26c6aa9a7b1d4ec3fc7.zip SCons-072430f48c21dfc9dfa0b26c6aa9a7b1d4ec3fc7.tar.gz SCons-072430f48c21dfc9dfa0b26c6aa9a7b1d4ec3fc7.tar.bz2 |
- fix: made the test for Interactive/configure self-contained, such that it works on any platform
Diffstat (limited to 'test/Interactive')
-rw-r--r-- | test/Interactive/configure.py | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py index ceb1aea..1a92f6c 100644 --- a/test/Interactive/configure.py +++ b/test/Interactive/configure.py @@ -32,20 +32,43 @@ Also tests that "b" can be used as a synonym for "build". import TestSCons +_python_ = TestSCons._python_ + test = TestSCons.TestSCons() -test.write('SConstruct', """\ +test.write('mycc.py', r""" import sys +outfile = open(sys.argv[1], 'wb') +infile = open(sys.argv[2], 'rb') +for l in [l for l in infile.readlines() if l[:7] != '/*c++*/']: + outfile.write(l) +sys.exit(0) +""") -env = Environment() - -conf = Configure(env) -if not conf.CheckCXX(): - sys.exit(1) +test.write('SConstruct', """\ +env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE', + OBJSUFFIX='.obj') + +# Ensure that our 'compiler' works... +def CheckMyCC(context): + context.Message('Checking for MyCC compiler...') + result = context.TryBuild(context.env.Object, + 'int main(void) {return 0;}', + '.cpp') + context.Result(result) + return result + +conf = Configure(env, + custom_tests = {'CheckMyCC' : CheckMyCC}) + +if conf.CheckMyCC(): + pass # build succeeded +else: + Exit(1) conf.Finish() -env.Program('foo','foo.cpp') -""") +env.Object('foo.obj','foo.cpp') +""" % locals()) test.write('foo.cpp', """\ #include <stdio.h> @@ -60,11 +83,11 @@ int main (int argc, char *argv[]) scons = test.start(arguments = '-Q --interactive') # Initial build -scons.send("build foo\n") +scons.send("build foo.obj\n") -test.wait_for(test.workpath('foo')) +test.wait_for(test.workpath('foo.obj')) # Update without any changes -> no action -scons.send("build foo\n") +scons.send("build foo.obj\n") # Changing the source file test.write('foo.cpp', """\ #include <stdio.h> @@ -82,16 +105,14 @@ int main (int argc, char *argv[]) """) # Verify that "b" can be used as a synonym for the "build" command. -scons.send("b foo\n") +scons.send("b foo.obj\n") -scons.send("build foo\n") +scons.send("build foo.obj\n") expect_stdout = r"""scons>>> .*foo\.cpp.* -.*foo.* scons>>> .*foo\.cpp.* -.*foo.* -scons>>> scons: `foo' is up to date. -scons>>> scons: `foo' is up to date. +scons>>> scons: `foo.obj' is up to date. +scons>>> scons: `foo.obj' is up to date. scons>>>\s* """ |