summaryrefslogtreecommitdiff
path: root/test/Repository/SConscript.py
diff options
context:
space:
mode:
authorPaweł Tomulik <ptomulik@meil.pw.edu.pl>2016-05-11 02:17:30 +0200
committerPaweł Tomulik <ptomulik@meil.pw.edu.pl>2016-05-11 02:17:30 +0200
commit0aae695d33ccd209452b538eaa275da146046e1e (patch)
tree0f9a13d00fbe99b6ea0584302b8a171338e5f970 /test/Repository/SConscript.py
downloadscons-git-0aae695d33ccd209452b538eaa275da146046e1e.tar.gz
fixed issue with _xxxxxxVERSIONFLAGS
Diffstat (limited to 'test/Repository/SConscript.py')
-rw-r--r--test/Repository/SConscript.py131
1 files changed, 131 insertions, 0 deletions
diff --git a/test/Repository/SConscript.py b/test/Repository/SConscript.py
new file mode 100644
index 000000000..22956acdb
--- /dev/null
+++ b/test/Repository/SConscript.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test how we handle SConscript calls when using a Repository.
+"""
+
+import sys
+import TestSCons
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+else:
+ _exe = ''
+
+test = TestSCons.TestSCons()
+
+#
+test.subdir('work',
+ ['work', 'src'],
+ 'rep1',
+ ['rep1', 'src'],
+ 'rep2',
+ ['rep2', 'build'],
+ ['rep2', 'src'],
+ ['rep2', 'src', 'sub'])
+
+#
+workpath_rep1 = test.workpath('rep1')
+workpath_rep2 = test.workpath('rep2')
+
+#
+test.write(['work', 'SConstruct'], """
+Repository(r'%s')
+SConscript('src/SConscript')
+""" % workpath_rep1)
+
+test.write(['rep1', 'src', 'SConscript'], """\
+def cat(env, source, target):
+ target = str(target[0])
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(str(src), "rb").read())
+ f.close()
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in'])
+""")
+
+test.write(['rep1', 'src', 'aaa.in'], "rep1/src/aaa.in\n")
+test.write(['rep1', 'src', 'bbb.in'], "rep1/src/bbb.in\n")
+test.write(['rep1', 'src', 'ccc.in'], "rep1/src/ccc.in\n")
+
+# Make the rep1 non-writable,
+# so we'll detect if we try to write into it accidentally.
+test.writable('rep1', 0)
+
+test.run(chdir = 'work', arguments = ".")
+
+test.fail_test(test.read(['work', 'src', 'foo']) != """\
+rep1/src/aaa.in
+rep1/src/bbb.in
+rep1/src/ccc.in
+""")
+
+test.up_to_date(chdir = 'work', arguments = ".")
+
+#
+test.write(['rep2', 'build', 'SConstruct'], """
+env = Environment(REPOSITORY = r'%s')
+env.Repository('$REPOSITORY')
+SConscript('src/SConscript')
+""" % workpath_rep2)
+
+test.write(['rep2', 'src', 'SConscript'], """\
+def cat(env, source, target):
+ target = str(target[0])
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(str(src), "rb").read())
+ f.close()
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat(target = 'foo', source = ['aaa.in', 'bbb.in', 'ccc.in'])
+SConscript('sub/SConscript')
+""")
+
+test.write(['rep2', 'src', 'sub', 'SConscript'], """\
+""")
+
+test.write(['rep2', 'src', 'aaa.in'], "rep2/src/aaa.in\n")
+test.write(['rep2', 'src', 'bbb.in'], "rep2/src/bbb.in\n")
+test.write(['rep2', 'src', 'ccc.in'], "rep2/src/ccc.in\n")
+
+test.run(chdir = 'rep2/build', arguments = ".")
+
+test.fail_test(test.read(['rep2', 'build', 'src', 'foo']) != """\
+rep2/src/aaa.in
+rep2/src/bbb.in
+rep2/src/ccc.in
+""")
+
+#
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: