diff options
author | Steven Knight <knight@baldmt.com> | 2009-01-27 13:42:49 +0000 |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2009-01-27 13:42:49 +0000 |
commit | 8135e019630756c5ab7c09a3b9a2249f4fb7dca2 (patch) | |
tree | 5dfb7f589db0955bd41bcb4eff04b8ff4b7305c1 /test/sconsign | |
parent | 897e2c9276145a2be86e74c102dc0c8e86a14bf1 (diff) | |
download | scons-8135e019630756c5ab7c09a3b9a2249f4fb7dca2.tar.gz |
Handle executing tests in a directory whose path contains spaces,
or with a Python in a path that contains spaces, by refactoring
(again) how we execute the internal scripts.
Diffstat (limited to 'test/sconsign')
-rw-r--r-- | test/sconsign/script/SConsignFile.py | 98 | ||||
-rw-r--r-- | test/sconsign/script/Signatures.py | 8 | ||||
-rw-r--r-- | test/sconsign/script/no-SConsignFile.py | 9 |
3 files changed, 59 insertions, 56 deletions
diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 71c91cb1..89d562ac 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -35,19 +35,14 @@ import re import TestSCons import TestSConsign -python = TestSCons.python -python_dir, python_file = os.path.split(python) -_python_ = TestSCons._python_ - -python_re = re.escape(python) -python_dir_re = re.escape(python_dir) -python_file_re = re.escape(python_file) - test = TestSConsign.TestSConsign(match = TestSConsign.match_re) test.subdir('sub1', 'sub2') -test.write('fake_cc.py', r""" +fake_cc_py = test.workpath('fake_cc.py') +fake_link_py = test.workpath('fake_link.py') + +test.write(fake_cc_py, r"""#!/usr/bin/env python import os import re import string @@ -80,7 +75,7 @@ process(input, output) sys.exit(0) """) -test.write('fake_link.py', r""" +test.write(fake_link_py, r"""#!/usr/bin/env python import sys output = open(sys.argv[1], 'wb') @@ -93,6 +88,9 @@ output.write(input.read()) sys.exit(0) """) +test.chmod(fake_cc_py, 0755) +test.chmod(fake_link_py, 0755) + # 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. @@ -108,8 +106,8 @@ test.write(['SConstruct'], """\ SConsignFile() 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') + CCCOM = [[r'%(fake_cc_py)s', 'sub2', '$TARGET', '$SOURCE']], + LINKCOM = [[r'%(fake_link_py)s', '$TARGET', '$SOURCE']]) env1.PrependENVPath('PATHEXT', '.PY') env1.Program('sub1/hello.c') env2 = env1.Clone(CPPPATH = ['sub2']) @@ -147,29 +145,29 @@ sig_re = r'[0-9a-fA-F]{32}' test.run_sconsign(arguments = ".sconsign", stdout = r"""=== .: SConstruct: None \d+ \d+ -=== %(python_dir_re)s: -%(python_file_re)s: %(sig_re)s \d+ \d+ +fake_cc\.py: %(sig_re)s \d+ \d+ +fake_link\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_link\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_link\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] inc1.h: %(sig_re)s \d+ \d+ inc2.h: %(sig_re)s \d+ \d+ @@ -178,29 +176,29 @@ 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} -=== %(python_dir_re)s: -%(python_file_re)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} +fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} +fake_link\.py: {'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} - %(python_re)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} + fake_link\.py: {'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} - %(python_re)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} + fake_cc\.py: {'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} - %(python_re)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} + fake_link\.py: {'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} - %(python_re)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} + fake_cc\.py: {'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} @@ -211,8 +209,11 @@ SConstruct: csig: None timestamp: \d+ size: \d+ -=== %(python_dir_re)s: -%(python_file_re)s: +fake_cc\.py: + csig: %(sig_re)s + timestamp: \d+ + size: \d+ +fake_link\.py: csig: %(sig_re)s timestamp: \d+ size: \d+ @@ -230,7 +231,7 @@ hello.exe: csig: %(sig_re)s timestamp: \d+ size: \d+ - %(python_re)s: + fake_link\.py: csig: %(sig_re)s timestamp: \d+ size: \d+ @@ -244,7 +245,7 @@ hello.obj: csig: %(sig_re)s timestamp: \d+ size: \d+ - %(python_re)s: + fake_cc\.py: csig: %(sig_re)s timestamp: \d+ size: \d+ @@ -263,7 +264,7 @@ hello.exe: csig: %(sig_re)s timestamp: \d+ size: \d+ - %(python_re)s: + fake_link\.py: csig: %(sig_re)s timestamp: \d+ size: \d+ @@ -285,7 +286,7 @@ hello.obj: csig: %(sig_re)s timestamp: \d+ size: \d+ - %(python_re)s: + fake_cc\.py: csig: %(sig_re)s timestamp: \d+ size: \d+ @@ -306,8 +307,9 @@ test.run_sconsign(arguments = "-c -v .sconsign", stdout = r"""=== .: SConstruct: csig: None -=== %(python_dir_re)s: -%(python_file_re)s: +fake_cc\.py: + csig: %(sig_re)s +fake_link\.py: csig: %(sig_re)s === sub1: hello.c: @@ -333,8 +335,9 @@ test.run_sconsign(arguments = "-s -v .sconsign", stdout = r"""=== .: SConstruct: size: \d+ -=== %(python_dir_re)s: -%(python_file_re)s: +fake_cc\.py: + size: \d+ +fake_link\.py: size: \d+ === sub1: hello.c: @@ -360,8 +363,9 @@ test.run_sconsign(arguments = "-t -v .sconsign", stdout = r"""=== .: SConstruct: timestamp: \d+ -=== %(python_dir_re)s: -%(python_file_re)s: +fake_cc\.py: + timestamp: \d+ +fake_link\.py: timestamp: \d+ === sub1: hello.c: @@ -385,64 +389,58 @@ inc2.h: test.run_sconsign(arguments = "-e hello.obj .sconsign", stdout = r"""=== .: -=== %(python_dir_re)s: === sub1: hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] """ % locals(), stderr = r"""sconsign: no entry `hello\.obj' in `\.' -sconsign: no entry `hello\.obj' in `%(python_dir_re)s' """ % locals()) test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj .sconsign", stdout = r"""=== .: -=== %(python_dir_re)s: === sub1: hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] hello.exe: %(sig_re)s \d+ \d+ %(sub1_hello_obj)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_link\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] hello.exe: %(sig_re)s \d+ \d+ %(sub2_hello_obj)s: %(sig_re)s \d+ \d+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_link\.py: %(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+ - %(python_re)s: %(sig_re)s \d+ \d+ + fake_cc\.py: %(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 `%(python_dir_re)s' -sconsign: no entry `hello\.exe' in `%(python_dir_re)s' -sconsign: no entry `hello\.obj' in `%(python_dir_re)s' """ % locals()) #test.run_sconsign(arguments = "-i -v .sconsign", diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index 9fdf54e8..0b580554 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -114,8 +114,12 @@ SConsignFile(None) Decider('timestamp-newer') env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', - CCCOM = r'%(fake_cc_py)s sub2 $TARGET $SOURCE', - LINKCOM = r'%(fake_link_py)s $TARGET $SOURCE') + # Specify the command lines with lists-of-lists so + # finding the implicit dependencies works even with + # spaces in the fake_*_py path names. + CCCOM = [[r'%(fake_cc_py)s', 'sub2', '$TARGET', '$SOURCE']], + LINKCOM = [[r'%(fake_link_py)s', '$TARGET', '$SOURCE']]) +env1.PrependENVPath('PATHEXT', '.PY') env1.Program('sub1/hello.c') env2 = env1.Clone(CPPPATH = ['sub2']) env2.Program('sub2/hello.c') diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index dacc0114..9b819b9c 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -113,8 +113,11 @@ test.write(['SConstruct'], """ SConsignFile(None) env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj', - CCCOM = r'%(fake_cc_py)s sub2 $TARGET $SOURCE', - LINKCOM = r'%(fake_link_py)s $TARGET $SOURCE') + # Specify the command lines with lists-of-lists so + # finding the implicit dependencies works even with + # spaces in the fake_*_py path names. + CCCOM = [[r'%(fake_cc_py)s', 'sub2', '$TARGET', '$SOURCE']], + LINKCOM = [[r'%(fake_link_py)s', '$TARGET', '$SOURCE']]) env1.PrependENVPath('PATHEXT', '.PY') env1.Program('sub1/hello.c') env2 = env1.Clone(CPPPATH = ['sub2']) @@ -155,8 +158,6 @@ hello.obj: %(sig_re)s \d+ \d+ """ % locals() test.run_sconsign(arguments = "sub1/.sconsign", stdout=expect) -#test.run_sconsign(arguments = "sub1/.sconsign") -#print test.stdout() test.run_sconsign(arguments = "--raw sub1/.sconsign", stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1} |