summaryrefslogtreecommitdiffstats
path: root/test/sconsign/script/no-SConsignFile.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sconsign/script/no-SConsignFile.py')
-rw-r--r--test/sconsign/script/no-SConsignFile.py100
1 files changed, 56 insertions, 44 deletions
diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py
index 1fcfbfd..6aede19 100644
--- a/test/sconsign/script/no-SConsignFile.py
+++ b/test/sconsign/script/no-SConsignFile.py
@@ -29,16 +29,61 @@ Verify that the sconsign script works when using an individual
.sconsign file in each directory (SConsignFile(None)).
"""
+import TestSCons
import TestSConsign
-test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+_python_ = TestSCons._python_
-CC = test.detect('CC', norm=1)
-LINK = test.detect('LINK', norm=1)
-if LINK is None: LINK = CC
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
test.subdir('sub1', 'sub2')
+test.write('fake_cc.py', r"""
+import os.path
+import re
+import string
+import sys
+
+path = string.split(sys.argv[1])
+output = open(sys.argv[2], 'wb')
+input = open(sys.argv[3], 'rb')
+
+output.write('fake_cc.py: %s\n' % sys.argv)
+
+def find_file(f):
+ for dir in path:
+ p = dir + os.sep + f
+ if os.path.exists(p):
+ return open(p, 'rb')
+ return None
+
+def process(infp, outfp):
+ for line in infp.readlines():
+ m = re.match('#include <(.*)>', line)
+ if m:
+ file = m.group(1)
+ process(find_file(file), outfp)
+ else:
+ outfp.write(line)
+
+process(input, output)
+
+sys.exit(0)
+""")
+
+test.write('fake_link.py', r"""
+import sys
+
+output = open(sys.argv[1], 'wb')
+input = open(sys.argv[2], 'rb')
+
+output.write('fake_link.py: %s\n' % sys.argv)
+
+output.write(input.read())
+
+sys.exit(0)
+""")
+
# Note: We don't use os.path.join() representations of the file names
# in the expected output because paths in the .sconsign files are
# canonicalized to use / as the separator.
@@ -52,36 +97,23 @@ sub2_inc2_h = 'sub2/inc2.h'
test.write(['SConstruct'], """
SConsignFile(None)
-env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
+env1 = Environment(PROGSUFFIX = '.exe',
+ OBJSUFFIX = '.obj',
+ CCCOM = r'%(_python_)s fake_cc.py sub2 $TARGET $SOURCE',
+ LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCE')
env1.Program('sub1/hello.c')
env2 = env1.Clone(CPPPATH = ['sub2'])
env2.Program('sub2/hello.c')
-""")
+""" % locals())
test.write(['sub1', 'hello.c'], r"""\
-#include <stdio.h>
-#include <stdlib.h>
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("sub1/hello.c\n");
- exit (0);
-}
+sub1/hello.c
""")
test.write(['sub2', 'hello.c'], r"""\
-#include <stdio.h>
-#include <stdlib.h>
#include <inc1.h>
#include <inc2.h>
-int
-main(int argc, char *argv[])
-{
- argv[argc++] = "--";
- printf("sub2/goodbye.c\n");
- exit (0);
-}
+sub2/hello.c
""")
test.write(['sub2', 'inc1.h'], r"""\
@@ -99,11 +131,9 @@ sig_re = r'[0-9a-fA-F]{32}'
expect = r"""hello.c: %(sig_re)s \d+ \d+
hello.exe: %(sig_re)s \d+ \d+
%(sub1_hello_obj)s: %(sig_re)s \d+ \d+
- %(LINK)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals()
@@ -115,11 +145,9 @@ test.run_sconsign(arguments = "--raw sub1/.sconsign",
stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
- %(LINK)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sig_re)s \[.*\]
hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
- %(CC)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sig_re)s \[.*\]
""" % locals())
@@ -137,10 +165,6 @@ hello.exe:
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(LINK)s:
- csig: %(sig_re)s
- timestamp: \d+
- size: \d+
action: %(sig_re)s \[.*\]
hello.obj:
csig: %(sig_re)s
@@ -151,10 +175,6 @@ hello.obj:
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(CC)s:
- csig: %(sig_re)s
- timestamp: \d+
- size: \d+
action: %(sig_re)s \[.*\]
""" % locals())
@@ -188,22 +208,18 @@ hello.obj:
test.run_sconsign(arguments = "-e hello.obj sub1/.sconsign",
stdout = r"""hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())
test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj sub1/.sconsign",
stdout = r"""hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.exe: %(sig_re)s \d+ \d+
%(sub1_hello_obj)s: %(sig_re)s \d+ \d+
- %(LINK)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())
@@ -211,13 +227,11 @@ test.run_sconsign(arguments = "sub2/.sconsign",
stdout = r"""hello.c: %(sig_re)s \d+ \d+
hello.exe: %(sig_re)s \d+ \d+
%(sub2_hello_obj)s: %(sig_re)s \d+ \d+
- %(LINK)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub2_hello_c)s: %(sig_re)s \d+ \d+
%(sub2_inc1_h)s: %(sig_re)s \d+ \d+
%(sub2_inc2_h)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
inc1.h: %(sig_re)s \d+ \d+
inc2.h: %(sig_re)s \d+ \d+
@@ -240,11 +254,9 @@ test.run_sconsign(arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign",
%(sub2_hello_c)s: %(sig_re)s \d+ \d+
%(sub2_inc1_h)s: %(sig_re)s \d+ \d+
%(sub2_inc2_h)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(CC)s: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())