summaryrefslogtreecommitdiffstats
path: root/test/sconsign/script/SConsignFile.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sconsign/script/SConsignFile.py')
-rw-r--r--test/sconsign/script/SConsignFile.py139
1 files changed, 59 insertions, 80 deletions
diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py
index 99845e3..54ecaaa 100644
--- a/test/sconsign/script/SConsignFile.py
+++ b/test/sconsign/script/SConsignFile.py
@@ -29,19 +29,61 @@ Verify that the sconsign script works with files generated when
using the signatures in an SConsignFile().
"""
-import os.path
-
+import TestSCons
import TestSConsign
-test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+_python_ = TestSCons._python_
-CC = test.detect('CC', norm=1)
-CC_dir, CC_file = os.path.split(CC)
-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.
@@ -55,27 +97,20 @@ sub2_inc2_h = 'sub2/inc2.h'
test.write(['SConstruct'], """\
SConsignFile()
-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);
-}
+test.write(['sub1', 'hello.c'], r"""
+sub1/hello.c
""")
-test.write(['sub2', 'hello.c'], r"""\
-#include <stdio.h>
-#include <stdlib.h>
+test.write(['sub2', 'hello.c'], r"""
#include <inc1.h>
#include <inc2.h>
int
@@ -102,29 +137,23 @@ sig_re = r'[0-9a-fA-F]{32}'
test.run_sconsign(arguments = ".sconsign",
stdout = r"""=== .:
SConstruct: None \d+ \d+
-=== %(CC_dir)s:
-%(CC_file)s: %(sig_re)s \d+ \d+
=== sub1:
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 \[.*\]
=== sub2:
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+
@@ -133,29 +162,23 @@ inc2.h: %(sig_re)s \d+ \d+
test.run_sconsign(arguments = "--raw .sconsign",
stdout = r"""=== .:
SConstruct: {'csig': None, 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
-=== %(CC_dir)s:
-%(CC_file)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
=== sub1:
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 \[.*\]
=== sub2:
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}
%(sub2_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}
%(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub2_inc2_h)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 \[.*\]
inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
@@ -166,11 +189,6 @@ SConstruct:
csig: None
timestamp: \d+
size: \d+
-=== %(CC_dir)s:
-%(CC_file)s:
- csig: %(sig_re)s
- timestamp: \d+
- size: \d+
=== sub1:
hello.c:
csig: %(sig_re)s
@@ -185,10 +203,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
@@ -199,10 +213,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 \[.*\]
=== sub2:
hello.c:
@@ -218,10 +228,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
@@ -240,10 +246,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 \[.*\]
inc1.h:
csig: %(sig_re)s
@@ -261,9 +263,6 @@ test.run_sconsign(arguments = "-c -v .sconsign",
stdout = r"""=== .:
SConstruct:
csig: None
-=== %(CC_dir)s:
-%(CC_file)s:
- csig: %(sig_re)s
=== sub1:
hello.c:
csig: %(sig_re)s
@@ -288,9 +287,6 @@ test.run_sconsign(arguments = "-s -v .sconsign",
stdout = r"""=== .:
SConstruct:
size: \d+
-=== %(CC_dir)s:
-%(CC_file)s:
- size: \d+
=== sub1:
hello.c:
size: \d+
@@ -315,9 +311,6 @@ test.run_sconsign(arguments = "-t -v .sconsign",
stdout = r"""=== .:
SConstruct:
timestamp: \d+
-=== %(CC_dir)s:
-%(CC_file)s:
- timestamp: \d+
=== sub1:
hello.c:
timestamp: \d+
@@ -340,64 +333,50 @@ inc2.h:
test.run_sconsign(arguments = "-e hello.obj .sconsign",
stdout = r"""=== .:
-=== %(CC_dir)s:
=== sub1:
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 \[.*\]
=== sub2:
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 \[.*\]
""" % locals(),
- stderr = r"""sconsign: no entry `hello.obj' in `\.'
-sconsign: no entry `hello.obj' in `%(CC_dir)s'
-""" % locals())
+ stderr = r"""sconsign: no entry `hello.obj' in `\.'
+""")
test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj .sconsign",
stdout = r"""=== .:
-=== %(CC_dir)s:
=== sub1:
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 \[.*\]
=== sub2:
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 \[.*\]
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 \[.*\]
""" % locals(),
stderr = r"""sconsign: no entry `hello.obj' in `\.'
sconsign: no entry `hello.exe' in `\.'
sconsign: no entry `hello.obj' in `\.'
-sconsign: no entry `hello.obj' in `%(CC_dir)s'
-sconsign: no entry `hello.exe' in `%(CC_dir)s'
-sconsign: no entry `hello.obj' in `%(CC_dir)s'
""" % locals())
#test.run_sconsign(arguments = "-i -v .sconsign",