diff options
Diffstat (limited to 'test')
122 files changed, 3378 insertions, 391 deletions
diff --git a/test/Actions/addpost-link.py b/test/Actions/addpost-link.py index a148051..04cd68d 100644 --- a/test/Actions/addpost-link.py +++ b/test/Actions/addpost-link.py @@ -54,7 +54,7 @@ myprog = env.Program('test1.c', OBJSUFFIX = '.obj', PROGSUFFIX = '.exe') if ARGUMENTS['case']=='2': - AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].abspath)) + AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath())) """ % locals()) test.write('test1.c', """\ diff --git a/test/compat/any.py b/test/Builder/different-actions.py index 3c03807..33a1363 100644 --- a/test/compat/any.py +++ b/test/Builder/different-actions.py @@ -25,34 +25,27 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Verify that we can use the any() function (in any supported Python -version we happen to be testing). - -This test can be retired at some point in the distant future when Python -2.5 becomes the minimum version supported by SCons. +Verify that two builders in two environments with different +actions generate an error. """ import TestSCons -test = TestSCons.TestSCons() +test = TestSCons.TestSCons(match=TestSCons.match_re) test.write('SConstruct', """\ -print any([True, False]) and "YES" or "NO" -print any([1]) and "YES" or "NO" -SConscript('SConscript') -""") +e1 = Environment() +e2 = Environment() -test.write('SConscript', """\ -print any([0, False]) and "YES" or "NO" +e1.Command('out.txt', [], 'echo 1 > $TARGET') +e2.Command('out.txt', [], 'echo 2 > $TARGET') """) -expect = """\ -YES -YES -NO -""" +expect = TestSCons.re_escape(""" +scons: *** Two environments with different actions were specified for the same target: out.txt +""") + TestSCons.file_expr -test.run(arguments = '-Q -q', stdout = expect) +test.run(arguments='out.txt', status=2, stderr=expect) test.pass_test() diff --git a/test/CC/CCVERSION.py b/test/CC/CCVERSION.py index ac28e38..f785ddc 100644 --- a/test/CC/CCVERSION.py +++ b/test/CC/CCVERSION.py @@ -33,7 +33,8 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() - +if sys.platform == 'win32': + test.skip_test('CCVERSION not set with MSVC, skipping test.') test.write("versioned.py", """import os diff --git a/test/CPPDEFINES/pkg-config.py b/test/CPPDEFINES/pkg-config.py index 0656900..1b308d3 100644 --- a/test/CPPDEFINES/pkg-config.py +++ b/test/CPPDEFINES/pkg-config.py @@ -32,7 +32,8 @@ import TestSCons test = TestSCons.TestSCons() -if not test.where_is('pkg-config'): +pkg_config_path = test.where_is('pkg-config') +if not pkg_config_path: test.skip_test("Could not find 'pkg-config' in system PATH, skipping test.\n") test.write('bug.pc', """\ @@ -58,7 +59,7 @@ test.write('SConstruct', """\ # http://scons.tigris.org/issues/show_bug.cgi?id=2671 # Passing test cases env_1 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) -env_1.ParseConfig('PKG_CONFIG_PATH=. pkg-config --cflags bug') +env_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') print env_1.subst('$_CPPDEFFLAGS') env_2 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) @@ -67,7 +68,7 @@ print env_2.subst('$_CPPDEFFLAGS') # Failing test cases env_3 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) -env_3.ParseConfig('PKG_CONFIG_PATH=. pkg-config --cflags bug') +env_3.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') print env_3.subst('$_CPPDEFFLAGS') env_4 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) @@ -76,10 +77,10 @@ print env_4.subst('$_CPPDEFFLAGS') # http://scons.tigris.org/issues/show_bug.cgi?id=1738 env_1738_1 = Environment(tools=['default']) -env_1738_1.ParseConfig('PKG_CONFIG_PATH=. pkg-config --cflags --libs bug') +env_1738_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags --libs bug') env_1738_1.Append(CPPDEFINES={'value' : '1'}) print env_1738_1.subst('$_CPPDEFFLAGS') -""") +"""%locals() ) expect_print_output="""\ -DDEBUG=1 -DTEST -DSOMETHING -DVARIABLE=2 diff --git a/test/CXX/CXXVERSION.py b/test/CXX/CXXVERSION.py index 8433aa6..6017001 100644 --- a/test/CXX/CXXVERSION.py +++ b/test/CXX/CXXVERSION.py @@ -33,6 +33,8 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() +if sys.platform == 'win32': + test.skip_test('CXXVERSION not set with MSVC, skipping test.') test.write("versioned.py", diff --git a/test/CacheDir/NoCache.py b/test/CacheDir/NoCache.py index 7e9b540..b035b44 100644 --- a/test/CacheDir/NoCache.py +++ b/test/CacheDir/NoCache.py @@ -45,7 +45,7 @@ CacheDir(r'%s') g = '%s' def ActionWithUndeclaredInputs(target,source,env): - open(target[0].abspath,'w').write(g) + open(target[0].get_abspath(),'w').write(g) Command('foo_cached', [], ActionWithUndeclaredInputs) NoCache(Command('foo_notcached', [], ActionWithUndeclaredInputs)) diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index f79ea0d..687ba48 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -180,7 +180,7 @@ scons: Configure: Display of random string ... scons: Configure: \(cached\) a random string scons: Configure: Display of empty string ... -scons: Configure: \(cached\). +scons: Configure: \(cached\) * scons: Configure: Display of dictionary ... scons: Configure: \(cached\) yes diff --git a/test/Copy-Symlinks.py b/test/Copy-Symlinks.py index f8f92d7..2b8b824 100644 --- a/test/Copy-Symlinks.py +++ b/test/Copy-Symlinks.py @@ -38,6 +38,9 @@ SCons.Defaults.DefaultEnvironment( tools = [] ) test = TestSCons.TestSCons() +if not hasattr(os, 'symlink'): + test.skip_test('No os.symlink() method, no symlinks to test.\n') + filelinkToCopy = 'filelinkToCopy' fileToLink = 'file.in' fileContents = 'stuff n things\n' @@ -47,21 +50,24 @@ treeToLink = 'tree' treelinkToCopy = 'treelinkToCopy' badToLink = 'None' # do not write this item badlinkToCopy = 'badlinkToCopy' +relToLink = os.path.join( treeToLink, fileToLink ) +rellinkToCopy = 'relLinkToCopy' -try: - test.symlink( fileToLink, filelinkToCopy ) - test.symlink( dirToLink, dirlinkToCopy ) - test.symlink( treeToLink, treelinkToCopy ) - test.symlink( badToLink, badlinkToCopy ) -except: - test.no_result() +test.symlink( fileToLink, filelinkToCopy ) +test.symlink( dirToLink, dirlinkToCopy ) +test.symlink( treeToLink, treelinkToCopy ) +test.symlink( badToLink, badlinkToCopy ) +test.symlink( relToLink, rellinkToCopy ) test.write( fileToLink, fileContents ) test.subdir( dirToLink ) test.subdir( treeToLink ) -test.write( os.path.join( treeToLink, fileToLink ), fileContents ) +test.write( relToLink, fileContents ) + +sconstructPath = 'SConstruct' +sconscriptPath = os.path.join( treeToLink, 'SConscript' ) -test.write('SConstruct', +test.write( sconstructPath, """\ import SCons.Defaults SCons.Defaults.DefaultEnvironment( tools = [] ) @@ -81,17 +87,32 @@ Execute( Copy( 'L6', '%(treelinkToCopy)s', True ) ) Execute( Copy( 'Fails', '%(badlinkToCopy)s', False ) ) Execute( Copy( 'L7', '%(badlinkToCopy)s' ) ) Execute( Copy( 'L8', '%(badlinkToCopy)s', True ) ) + +SConscript( '%(sconscriptPath)s' ) """ % locals() ) -test.must_exist( 'SConstruct' ) +relLinkCopyPath = os.path.join( '..', rellinkToCopy ) + +test.write( sconscriptPath, +"""\ +Execute( Copy( 'F2', '%(relLinkCopyPath)s', False ) ) +Execute( Copy( 'L9', '%(relLinkCopyPath)s' ) ) +Execute( Copy( 'L10', '%(relLinkCopyPath)s', True ) ) +""" +% locals() +) + +test.must_exist( sconstructPath ) +test.must_exist( sconscriptPath ) test.must_exist( fileToLink ) test.must_exist( filelinkToCopy ) test.must_exist( dirlinkToCopy ) test.must_exist( treelinkToCopy ) test.must_not_exist( badToLink ) test.must_exist( badlinkToCopy ) +test.must_exist( rellinkToCopy ) expectStdout = test.wrap_stdout( read_str = @@ -105,9 +126,12 @@ Copy("L4", "%(dirlinkToCopy)s") Copy("T1", "%(treelinkToCopy)s") Copy("L5", "%(treelinkToCopy)s") Copy("L6", "%(treelinkToCopy)s") -Copy("Fails", "badlinkToCopy") +Copy("Fails", "%(badlinkToCopy)s") Copy("L7", "%(badlinkToCopy)s") Copy("L8", "%(badlinkToCopy)s") +Copy("F2", "%(relLinkCopyPath)s") +Copy("L9", "%(relLinkCopyPath)s") +Copy("L10", "%(relLinkCopyPath)s") ''' % locals(), build_str = '''\ @@ -117,13 +141,18 @@ scons: `.' is up to date. expectStderr = \ '''\ -scons: *** None: No such file or directory -''' +scons: *** %s: No such file or directory +''' % os.path.join( os.getcwd(), badToLink ) test.run( stdout = expectStdout, stderr = expectStderr, status = None ) +F2 = os.path.join( treeToLink, 'F2' ) +L9 = os.path.join( treeToLink, 'L9' ) +L10 = os.path.join( treeToLink, 'L10' ) + test.must_exist('D1') test.must_exist('F1') +test.must_exist( F2 ) test.must_exist('L2') test.must_exist('L3') test.must_exist('L4') @@ -131,17 +160,21 @@ test.must_exist('L5') test.must_exist('L6') test.must_exist('L7') test.must_exist('L8') +test.must_exist( L9 ) +test.must_exist( L10 ) test.must_exist('T1') test.must_not_exist( 'Fails' ) test.must_match( fileToLink, fileContents ) test.must_match( 'F1', fileContents ) +test.must_match( F2 , fileContents ) test.must_match( 'L1', fileContents ) test.must_match( 'L2', fileContents ) test.must_match( os.path.join( treeToLink, fileToLink ), fileContents ) test.fail_test( condition=os.path.islink('D1') ) test.fail_test( condition=os.path.islink('F1') ) +test.fail_test( condition=os.path.islink( F2 ) ) test.fail_test( condition=os.path.islink('T1') ) test.fail_test( condition=(not os.path.isdir('D1')) ) test.fail_test( condition=(not os.path.isfile('F1')) ) @@ -154,8 +187,12 @@ test.fail_test( condition=(not os.path.islink('L5')) ) test.fail_test( condition=(not os.path.islink('L6')) ) test.fail_test( condition=(not os.path.islink('L7')) ) test.fail_test( condition=(not os.path.islink('L8')) ) +test.fail_test( condition=(not os.path.islink( L9 )) ) +test.fail_test( condition=(not os.path.islink( L10 )) ) test.fail_test( condition=(os.path.exists('L7')) ) test.fail_test( condition=(os.path.exists('L8')) ) +test.fail_test( condition=(os.path.exists( L9 )) ) +test.fail_test( condition=(os.path.exists( L10 )) ) test.fail_test( condition=(os.readlink(filelinkToCopy) != os.readlink('L1')) ) test.fail_test( condition=(os.readlink(filelinkToCopy) != os.readlink('L2')) ) test.fail_test( condition=(os.readlink(dirlinkToCopy) != os.readlink('L3')) ) @@ -164,6 +201,8 @@ test.fail_test( condition=(os.readlink(treelinkToCopy) != os.readlink('L5')) ) test.fail_test( condition=(os.readlink(treelinkToCopy) != os.readlink('L6')) ) test.fail_test( condition=(os.readlink(badlinkToCopy) != os.readlink('L7')) ) test.fail_test( condition=(os.readlink(badlinkToCopy) != os.readlink('L8')) ) +test.fail_test( condition=(os.readlink(rellinkToCopy) != os.readlink( L9 )) ) +test.fail_test( condition=(os.readlink(rellinkToCopy) != os.readlink( L10 )) ) test.pass_test() diff --git a/test/D/CoreScanner/Common/common.py b/test/D/CoreScanner/Common/common.py index 657e83e..1d2fde0 100644 --- a/test/D/CoreScanner/Common/common.py +++ b/test/D/CoreScanner/Common/common.py @@ -44,7 +44,7 @@ def testForTool(tool): _obj = TestSCons._obj if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('Image') test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) diff --git a/test/D/CoreScanner/Image/SConstruct_template b/test/D/CoreScanner/Image/SConstruct_template index a128c67..e91343b 100644 --- a/test/D/CoreScanner/Image/SConstruct_template +++ b/test/D/CoreScanner/Image/SConstruct_template @@ -3,7 +3,6 @@ import os environment = Environment( - ENV=os.environ, tools=['link', '{}']) environment.Program('test1.d') environment.Program('test2.d') diff --git a/test/D/DMD.py b/test/D/DMD.py index 1bde380..2d9333a 100644 --- a/test/D/DMD.py +++ b/test/D/DMD.py @@ -28,16 +28,20 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys +from os.path import abspath, dirname, join +sys.path.append(join(dirname(abspath(__file__)), 'Support')) +from executablesSearch import isExecutableOfToolAvailable + _exe = TestSCons._exe test = TestSCons.TestSCons() -dmd = test.where_is('dmd') -if not dmd: +if not isExecutableOfToolAvailable(test, 'dmd'): test.skip_test("Could not find 'dmd'; skipping test.\n") test.write('SConstruct', """\ import os -env = Environment(ENV=os.environ) +env = Environment() if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/DMD2.py b/test/D/DMD2.py index cc8ab93..84ceb51 100644 --- a/test/D/DMD2.py +++ b/test/D/DMD2.py @@ -28,15 +28,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys +from os.path import abspath, dirname, join +sys.path.append(join(dirname(abspath(__file__)), 'Support')) +from executablesSearch import isExecutableOfToolAvailable + _exe = TestSCons._exe test = TestSCons.TestSCons() -if not test.where_is('dmd') and not test.where_is('gdmd'): - test.skip_test("Could not find 'dmd' or 'gdmd', skipping test.\n") +if not isExecutableOfToolAvailable(test, 'dmd'): + test.skip_test("Could not find 'dmd'; skipping test.\n") test.write('SConstruct', """\ import os -env = Environment(tools=['link', 'dmd'], ENV=os.environ) +env = Environment(tools=['link', 'dmd']) +env['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/DMD2_Alt.py b/test/D/DMD2_Alt.py index fbe2f2b..3bd58b4 100644 --- a/test/D/DMD2_Alt.py +++ b/test/D/DMD2_Alt.py @@ -28,15 +28,21 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons +import sys +from os.path import abspath, dirname, join +sys.path.append(join(dirname(abspath(__file__)), 'Support')) +from executablesSearch import isExecutableOfToolAvailable + _exe = TestSCons._exe test = TestSCons.TestSCons() -if not test.where_is('dmd') and not test.where_is('gdmd'): - test.skip_test("Could not find 'dmd' or 'gdmd', skipping test.\n") +if not isExecutableOfToolAvailable(test, 'dmd'): + test.skip_test("Could not find 'dmd'; skipping test.\n") test.write('SConstruct', """\ import os -env = Environment(tools=['dmd', 'link'], ENV=os.environ) +env = Environment(tools=['dmd', 'link']) +env['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/GDC.py b/test/D/GDC.py index e24ec43..b548b94 100644 --- a/test/D/GDC.py +++ b/test/D/GDC.py @@ -36,7 +36,7 @@ if not test.where_is('gdc'): test.write('SConstruct', """\ import os -env = Environment(tools=['link', 'gdc'], ENV=os.environ) +env = Environment(tools=['link', 'gdc']) if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/GDC_Alt.py b/test/D/GDC_Alt.py index cac7949..27159ee 100644 --- a/test/D/GDC_Alt.py +++ b/test/D/GDC_Alt.py @@ -36,7 +36,7 @@ if not test.where_is('gdc'): test.write('SConstruct', """\ import os -env = Environment(tools=['gdc', 'link'], ENV=os.environ) +env = Environment(tools=['gdc', 'link']) if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/HSTeoh/ArLibIssue/SConstruct_template b/test/D/HSTeoh/ArLibIssue/SConstruct_template index 81f81f5..b17847a 100644 --- a/test/D/HSTeoh/ArLibIssue/SConstruct_template +++ b/test/D/HSTeoh/ArLibIssue/SConstruct_template @@ -1,3 +1,6 @@ env = Environment({}) +import os +env['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + env.StaticLibrary('mylib', ['a.d', 'b.d']) diff --git a/test/D/HSTeoh/Common/arLibIssue.py b/test/D/HSTeoh/Common/arLibIssue.py index fe5902b..9bca3d8 100644 --- a/test/D/HSTeoh/Common/arLibIssue.py +++ b/test/D/HSTeoh/Common/arLibIssue.py @@ -43,10 +43,10 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('ArLibIssue') - test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "ar"]'.format(tool))) + test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "ar"]'.format(tool))) test.run() diff --git a/test/D/HSTeoh/Common/libCompileOptions.py b/test/D/HSTeoh/Common/libCompileOptions.py index dd95fc8..4a21c45 100644 --- a/test/D/HSTeoh/Common/libCompileOptions.py +++ b/test/D/HSTeoh/Common/libCompileOptions.py @@ -43,10 +43,10 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('LibCompileOptions') - test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link", "ar"]'.format(tool))) + test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "link", "ar"]'.format(tool))) test.run() diff --git a/test/D/HSTeoh/Common/linkingProblem.py b/test/D/HSTeoh/Common/linkingProblem.py index 59b409f..b526ad7 100644 --- a/test/D/HSTeoh/Common/linkingProblem.py +++ b/test/D/HSTeoh/Common/linkingProblem.py @@ -29,7 +29,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons -from os.path import abspath, dirname +from os.path import abspath, dirname, exists import sys sys.path.insert(1, abspath(dirname(__file__) + '/../../Support')) @@ -41,7 +41,10 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) + + if not exists('/usr/include/ncurses.h'): + test.skip_test("ncurses not apparently installed, skip this test.") test.dir_fixture('LinkingProblem') test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) diff --git a/test/D/HSTeoh/Common/singleStringCannotBeMultipleOptions.py b/test/D/HSTeoh/Common/singleStringCannotBeMultipleOptions.py index 4dabf7b..4716f1c 100644 --- a/test/D/HSTeoh/Common/singleStringCannotBeMultipleOptions.py +++ b/test/D/HSTeoh/Common/singleStringCannotBeMultipleOptions.py @@ -42,7 +42,7 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('SingleStringCannotBeMultipleOptions') test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) @@ -55,6 +55,10 @@ def testForTool(tool): 'ldc': ".*Unknown command line argument '-m64 -O'.*", }[tool] + from SCons.Environment import Base + if tool == 'dmd' and Base()['DC'] == 'gdmd': + result = ".*unrecognized command line option '-m64 -O'.*" + test.fail_test(not test.match_re_dotall(test.stderr(), result)) test.pass_test() diff --git a/test/D/HSTeoh/LibCompileOptions/SConstruct_template b/test/D/HSTeoh/LibCompileOptions/SConstruct_template index 7031f5c..1489624 100644 --- a/test/D/HSTeoh/LibCompileOptions/SConstruct_template +++ b/test/D/HSTeoh/LibCompileOptions/SConstruct_template @@ -1,5 +1,8 @@ env = Environment({}) +import os +env['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + env.Library('mylib', 'mylib.d') prog_env = env.Clone( diff --git a/test/D/HSTeoh/LinkingProblem/SConstruct_template b/test/D/HSTeoh/LinkingProblem/SConstruct_template index 6815cdf..2c53b54 100644 --- a/test/D/HSTeoh/LinkingProblem/SConstruct_template +++ b/test/D/HSTeoh/LinkingProblem/SConstruct_template @@ -3,10 +3,11 @@ import os environment = Environment( - ENV=os.environ, - tools = ['cc', 'link' , '{}'], + tools = ['cc', '{}', 'link'], LIBS = ['ncurses']) +environment['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + environment.Object('ncurs_impl.o', 'ncurs_impl.c') environment.Program('prog', Split(""" diff --git a/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template b/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template index 89c603b..118a7b2 100644 --- a/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template +++ b/test/D/HSTeoh/SingleStringCannotBeMultipleOptions/SConstruct_template @@ -3,7 +3,6 @@ import os environment = Environment( - ENV=os.environ, tools=['link', '{}'], # It might be thought that a single string can contain multiple options space separated. Actually this # is deemed to be a single option, so leads to an error. diff --git a/test/D/HelloWorld/CompileAndLinkOneStep/Common/common.py b/test/D/HelloWorld/CompileAndLinkOneStep/Common/common.py index 618041b..e757d47 100644 --- a/test/D/HelloWorld/CompileAndLinkOneStep/Common/common.py +++ b/test/D/HelloWorld/CompileAndLinkOneStep/Common/common.py @@ -41,7 +41,7 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('Image') test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) diff --git a/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template b/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template index c688ab7..e2e7439 100644 --- a/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template +++ b/test/D/HelloWorld/CompileAndLinkOneStep/Image/SConstruct_template @@ -3,7 +3,6 @@ import os environment = Environment( - ENV=os.environ, tools=['link', '{}']) environment.Program('helloWorld.d') diff --git a/test/D/HelloWorld/CompileThenLinkTwoSteps/Common/common.py b/test/D/HelloWorld/CompileThenLinkTwoSteps/Common/common.py index 618041b..e757d47 100644 --- a/test/D/HelloWorld/CompileThenLinkTwoSteps/Common/common.py +++ b/test/D/HelloWorld/CompileThenLinkTwoSteps/Common/common.py @@ -41,7 +41,7 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('Image') test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) diff --git a/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template b/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template index 425970a..b38a9f0 100644 --- a/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template +++ b/test/D/HelloWorld/CompileThenLinkTwoSteps/Image/SConstruct_template @@ -3,7 +3,6 @@ import os environment = Environment( - ENV=os.environ, tools=['link', '{}']) objects = environment.Object('helloWorld.d') diff --git a/test/D/Issues/2939_Ariovistus/Common/correctLinkOptions.py b/test/D/Issues/2939_Ariovistus/Common/correctLinkOptions.py index 3b178b9..1b42580 100644 --- a/test/D/Issues/2939_Ariovistus/Common/correctLinkOptions.py +++ b/test/D/Issues/2939_Ariovistus/Common/correctLinkOptions.py @@ -43,14 +43,28 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('Project') - test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link"]'.format(tool))) + test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "link"]'.format(tool))) test.run() - for f in ('libstuff.so', 'stuff.os', 'test1', 'test1.o', 'test2', 'test2.o'): + platform = Base()['PLATFORM'] + + if platform == 'posix': + libraryname = 'libstuff.so' + filename = 'stuff.os' + elif platform == 'darwin': + libraryname = 'libstuff.dylib' + filename = 'stuff.os' + elif platform == 'win32': + libraryname = 'stuff.dll' + filename = 'stuff.obj' + else: + test.fail_test('No information about platform: ' + platform) + + for f in (libraryname, filename, 'test1', 'test1.o', 'test2', 'test2.o'): test.must_exist(test.workpath(join('test', 'test1', f))) test.pass_test() diff --git a/test/D/Issues/2939_Ariovistus/Project/SConstruct_template b/test/D/Issues/2939_Ariovistus/Project/SConstruct_template index 55f02aa..c78ba96 100644 --- a/test/D/Issues/2939_Ariovistus/Project/SConstruct_template +++ b/test/D/Issues/2939_Ariovistus/Project/SConstruct_template @@ -2,6 +2,9 @@ from os.path import join environment = Environment({}) +import os +environment['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + Export('environment') environment.SConscript([ diff --git a/test/D/Issues/2940_Ariovistus/Common/correctLinkOptions.py b/test/D/Issues/2940_Ariovistus/Common/correctLinkOptions.py index 3b178b9..8060add 100644 --- a/test/D/Issues/2940_Ariovistus/Common/correctLinkOptions.py +++ b/test/D/Issues/2940_Ariovistus/Common/correctLinkOptions.py @@ -43,14 +43,30 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) + + platform = Base()['PLATFORM'] + if platform == 'posix': + libraryname = 'libstuff.so' + filename = 'stuff.os' + elif platform == 'darwin': + libraryname = 'libstuff.dylib' + filename = 'stuff.os' + # As at 2014-09-14, DMD 2.066, LDC master head, and GDC 4.9.1 do not support + # shared libraries on OSX. + test.skip_test('Dynamic libraries not yet supported on OSX.\n') + elif platform == 'win32': + libraryname = 'stuff.dll' + filename = 'stuff.obj' + else: + test.fail_test('No information about platform: ' + platform) test.dir_fixture('Project') - test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{}", "link"]'.format(tool))) + test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "link"]'.format(tool))) test.run() - for f in ('libstuff.so', 'stuff.os', 'test1', 'test1.o', 'test2', 'test2.o'): + for f in (libraryname, filename, 'test1', 'test1.o', 'test2', 'test2.o'): test.must_exist(test.workpath(join('test', 'test1', f))) test.pass_test() diff --git a/test/D/Issues/2940_Ariovistus/Project/SConstruct_template b/test/D/Issues/2940_Ariovistus/Project/SConstruct_template index 55f02aa..c78ba96 100644 --- a/test/D/Issues/2940_Ariovistus/Project/SConstruct_template +++ b/test/D/Issues/2940_Ariovistus/Project/SConstruct_template @@ -2,6 +2,9 @@ from os.path import join environment = Environment({}) +import os +environment['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + Export('environment') environment.SConscript([ diff --git a/test/D/Issues/2944/D_changed_DFLAGS_not_rebuilding.py b/test/D/Issues/2944/D_changed_DFLAGS_not_rebuilding.py new file mode 100644 index 0000000..1d9854f --- /dev/null +++ b/test/D/Issues/2944/D_changed_DFLAGS_not_rebuilding.py @@ -0,0 +1,23 @@ +# Test to check for issue reported in tigris bug 2994 +# http://scons.tigris.org/issues/show_bug.cgi?id=2994 +# + +import TestSCons + +test = TestSCons.TestSCons() + +dmd_present = test.detect_tool('dmd', prog='dmd') +ldc_present = test.detect_tool('ldc',prog='ldc2') +gdc_present = test.detect_tool('gdc',prog='gdc') + +if not (dmd_present or ldc_present or gdc_present): + test.skip_test("Could not load dmd ldc or gdc Tool; skipping test(s).\n") + + +test.dir_fixture('image') +test.run() +test.fail_test('main.o' not in test.stdout()) +test.run(arguments='change=1') +test.fail_test('is up to date' in test.stdout()) + +test.pass_test() diff --git a/test/D/Issues/2944/image/SConstruct b/test/D/Issues/2944/image/SConstruct new file mode 100644 index 0000000..2c7deee --- /dev/null +++ b/test/D/Issues/2944/image/SConstruct @@ -0,0 +1,11 @@ +# -*- codig:utf-8; -*- + +env=Environment() + +change = ARGUMENTS.get('change', 0) +if int(change): + env.Append(DFLAGS = '-d') + +env.Program('proj', ['main.d']) + + diff --git a/test/D/Issues/2944/image/main.d b/test/D/Issues/2944/image/main.d new file mode 100644 index 0000000..f0aa23a --- /dev/null +++ b/test/D/Issues/2944/image/main.d @@ -0,0 +1,11 @@ +/* This program prints a + hello world message + to the console. */ + +import std.stdio; + +void main() +{ + writeln("Hello, World!"); +} + diff --git a/test/D/LDC.py b/test/D/LDC.py index 94acf1c..19070a5 100644 --- a/test/D/LDC.py +++ b/test/D/LDC.py @@ -43,7 +43,7 @@ if not isExecutableOfToolAvailable(test, 'ldc'): test.write('SConstruct', """\ import os -env = Environment(tools=['link', 'ldc'], ENV=os.environ) +env = Environment(tools=['link', 'ldc']) if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/LDC_Alt.py b/test/D/LDC_Alt.py index 571b8f0..bca7dd6 100644 --- a/test/D/LDC_Alt.py +++ b/test/D/LDC_Alt.py @@ -43,7 +43,7 @@ if not isExecutableOfToolAvailable(test, 'ldc'): test.write('SConstruct', """\ import os -env = Environment(tools=['ldc', 'link'], ENV=os.environ) +env = Environment(tools=['ldc', 'link']) if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj' # trick DMD env.Program('foo', 'foo.d') """) diff --git a/test/D/MixedDAndC/Common/common.py b/test/D/MixedDAndC/Common/common.py index 66c738f..852e2e2 100644 --- a/test/D/MixedDAndC/Common/common.py +++ b/test/D/MixedDAndC/Common/common.py @@ -30,6 +30,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSCons from os.path import abspath, dirname +from platform import architecture import sys sys.path.insert(1, abspath(dirname(__file__) + '/../../Support')) @@ -41,10 +42,20 @@ def testForTool(tool): test = TestSCons.TestSCons() if not isExecutableOfToolAvailable(test, tool) : - test.skip_test("Required executable for tool '{}' not found, skipping test.\n".format(tool)) + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) test.dir_fixture('Image') +# There was an issue with Russel mentioned but couldn't remember the details +# Which drove him to add the following logic. For now removing until +# we can determine what that issue is and if there's not a better +# way to handle the corner case +# if architecture()[0] == '32bit': +# test.run(status=2) +# test.fail_test('64-bit mode not compiled in' not in test.stderr()) +# else: +# test.run() + test.run() test.pass_test() diff --git a/test/D/MixedDAndC/Image/SConstruct b/test/D/MixedDAndC/Image/SConstruct index 47870d7..176c4d3 100644 --- a/test/D/MixedDAndC/Image/SConstruct +++ b/test/D/MixedDAndC/Image/SConstruct @@ -3,8 +3,10 @@ import os environment = Environment( - ENV=os.environ, - DFLAGS=['-m64', '-O']) +) +# CFLAGS=['-m64'], +# DLINKFLAGS=['-m64'], +# DFLAGS=['-m64', '-O']) environment.Program('proj', [ 'proj.d', diff --git a/test/D/Scanner.py b/test/D/Scanner.py index 48af057..b005adf 100644 --- a/test/D/Scanner.py +++ b/test/D/Scanner.py @@ -31,12 +31,16 @@ a single statement. import TestSCons +import sys +from os.path import abspath, dirname, join +sys.path.append(join(dirname(abspath(__file__)), 'Support')) +from executablesSearch import isExecutableOfToolAvailable + test = TestSCons.TestSCons() _obj = TestSCons._obj -dmd = test.where_is('dmd') -if not dmd: +if not isExecutableOfToolAvailable(test, 'dmd'): test.skip_test("Could not find 'dmd'; skipping test.\n") test.subdir(['p']) diff --git a/test/D/SharedObjects/Common/__init__.py b/test/D/SharedObjects/Common/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/D/SharedObjects/Common/__init__.py diff --git a/test/D/SharedObjects/Common/common.py b/test/D/SharedObjects/Common/common.py new file mode 100644 index 0000000..e81cf5b --- /dev/null +++ b/test/D/SharedObjects/Common/common.py @@ -0,0 +1,89 @@ +""" +Support functions for all the tests. +""" + +# +# __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__" + +import TestSCons + +from SCons.Environment import Base + +from os.path import abspath, dirname + +import sys +sys.path.insert(1, abspath(dirname(__file__) + '/../../Support')) + +from executablesSearch import isExecutableOfToolAvailable + +def testForTool(tool): + + test = TestSCons.TestSCons() + + if not isExecutableOfToolAvailable(test, tool) : + test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) + + if tool == 'gdc': + test.skip_test('gdc does not, as at version 4.9.1, support shared libraries.\n') + + if tool == 'dmd' and Base()['DC'] == 'gdmd': + test.skip_test('gdmd does not recognize the -shared option so cannot support linking of shared objects.\n') + + platform = Base()['PLATFORM'] + if platform == 'posix': + filename = 'code.o' + libraryname = 'libanswer.so' + elif platform == 'darwin': + filename = 'code.o' + libraryname = 'libanswer.dylib' + # As at 2014-09-14, DMD 2.066, LDC master head, and GDC 4.9.1 do not support + # shared libraries on OSX. + test.skip_test('Dynamic libraries not yet supported on OSX.\n') + elif platform == 'win32': + filename = 'code.obj' + libraryname = 'answer.dll' + else: + test.fail_test() + + test.dir_fixture('Image') + test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool)) + + if tool == 'dmd': + # The gdmd executable in Debian Unstable as at 2012-05-12, version 4.6.3 puts out messages on stderr + # that cause inappropriate failure of the tests, so simply ignore them. + test.run(stderr=None) + else: + test.run() + + test.must_exist(test.workpath(filename)) + test.must_exist(test.workpath(libraryname)) + + test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/SharedObjects/Common/sconstest.skip b/test/D/SharedObjects/Common/sconstest.skip new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/D/SharedObjects/Common/sconstest.skip diff --git a/test/D/SharedObjects/Image/SConstruct_template b/test/D/SharedObjects/Image/SConstruct_template new file mode 100644 index 0000000..cae8713 --- /dev/null +++ b/test/D/SharedObjects/Image/SConstruct_template @@ -0,0 +1,10 @@ +# -*- mode:python; coding:utf-8; -*- + +import os + +environment = Environment( + tools=['{}', 'link']) + +environment['ENV']['HOME'] = os.environ['HOME'] # Hack for gdmd + +environment.SharedLibrary('answer', 'code.d') diff --git a/test/D/SharedObjects/Image/code.d b/test/D/SharedObjects/Image/code.d new file mode 100644 index 0000000..0d9d1d7 --- /dev/null +++ b/test/D/SharedObjects/Image/code.d @@ -0,0 +1,3 @@ +int returnTheAnswer() { + return 42; +} diff --git a/test/D/SharedObjects/sconstest-dmd.py b/test/D/SharedObjects/sconstest-dmd.py new file mode 100644 index 0000000..df6ddeb --- /dev/null +++ b/test/D/SharedObjects/sconstest-dmd.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing using the dmd tool. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('dmd') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/SharedObjects/sconstest-gdc.py b/test/D/SharedObjects/sconstest-gdc.py new file mode 100644 index 0000000..43bb8eb --- /dev/null +++ b/test/D/SharedObjects/sconstest-gdc.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing using the gcd tool. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('gdc') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/SharedObjects/sconstest-ldc.py b/test/D/SharedObjects/sconstest-ldc.py new file mode 100644 index 0000000..f61efbc --- /dev/null +++ b/test/D/SharedObjects/sconstest-ldc.py @@ -0,0 +1,37 @@ +""" +Test compiling and executing using the ldc tool. +""" + +# +# __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__" + +from Common.common import testForTool +testForTool('ldc') + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/D/Support/executablesSearch.py b/test/D/Support/executablesSearch.py index e0487f6..17d9990 100755 --- a/test/D/Support/executablesSearch.py +++ b/test/D/Support/executablesSearch.py @@ -29,39 +29,60 @@ Support functions for all the tests. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +if __name__ == '__main__': + import sys + import os.path + sys.path.append(os.path.abspath('../../../src/engine')) + +from SCons.Environment import Base + +path = Base()['ENV']['PATH'] + def isExecutableOfToolAvailable(test, tool): for executable in { 'dmd': ['dmd', 'gdmd'], 'gdc': ['gdc'], - 'ldc': ['ldc2', 'ldc']}[tool]: - if test.where_is(executable): + 'ldc': ['ldc2', 'ldc'], + }[tool]: + if test.where_is(executable, path): return True return False + if __name__ == '__main__': import unittest - import sys - import os.path sys.path.append(os.path.abspath('../../../QMTest')) - sys.path.append(os.path.abspath('../../../src/engine')) + import TestSCons class VariousTests(unittest.TestCase): + ''' + These tests are somewhat self referential in that + isExecutableOfToolAvailable uses where_is to do most of it's + work and we use the same function in the tests. + ''' def setUp(self): self.test = TestSCons.TestSCons() + + def tearDown(self): + self.test = None + def test_None_tool(self): self.assertRaises(KeyError, isExecutableOfToolAvailable, self.test, None) + def test_dmd_tool(self): self.assertEqual( - self.test.where_is('dmd') is not None or self.test.where_is('gdmd') is not None, + self.test.where_is('dmd', path) is not None or self.test.where_is('gdmd', path) is not None, isExecutableOfToolAvailable(self.test, 'dmd')) + def test_gdc_tool(self): self.assertEqual( - self.test.where_is('gdc') is not None, + self.test.where_is('gdc', path) is not None, isExecutableOfToolAvailable(self.test, 'gdc')) + def test_ldc_tool(self): self.assertEqual( - self.test.where_is('ldc2') is not None or self.test.where_is('ldc') is not None, + self.test.where_is('ldc2', path) is not None or self.test.where_is('ldc', path) is not None, isExecutableOfToolAvailable(self.test, 'ldc')) unittest.main() diff --git a/test/Docbook/basedir/htmlchunked/htmlchunked.py b/test/Docbook/basedir/htmlchunked/htmlchunked.py index cf5f3d1..f97555b 100644 --- a/test/Docbook/basedir/htmlchunked/htmlchunked.py +++ b/test/Docbook/basedir/htmlchunked/htmlchunked.py @@ -38,6 +38,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basedir/htmlhelp/htmlhelp.py b/test/Docbook/basedir/htmlhelp/htmlhelp.py index 22bbd72..17aba09 100644 --- a/test/Docbook/basedir/htmlhelp/htmlhelp.py +++ b/test/Docbook/basedir/htmlhelp/htmlhelp.py @@ -38,6 +38,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basedir/slideshtml/slideshtml.py b/test/Docbook/basedir/slideshtml/slideshtml.py index a2375e4..a89edcd 100644 --- a/test/Docbook/basedir/slideshtml/slideshtml.py +++ b/test/Docbook/basedir/slideshtml/slideshtml.py @@ -39,6 +39,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/epub/epub.py b/test/Docbook/basic/epub/epub.py index 19e08a0..0a317b6 100644 --- a/test/Docbook/basic/epub/epub.py +++ b/test/Docbook/basic/epub/epub.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/html/html.py b/test/Docbook/basic/html/html.py index 0cb4fb6..acf38a3 100644 --- a/test/Docbook/basic/html/html.py +++ b/test/Docbook/basic/html/html.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/htmlchunked/htmlchunked.py b/test/Docbook/basic/htmlchunked/htmlchunked.py index 46cc8dc..74b8c7a 100644 --- a/test/Docbook/basic/htmlchunked/htmlchunked.py +++ b/test/Docbook/basic/htmlchunked/htmlchunked.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/htmlhelp/htmlhelp.py b/test/Docbook/basic/htmlhelp/htmlhelp.py index 9b00bbd..080ec60 100644 --- a/test/Docbook/basic/htmlhelp/htmlhelp.py +++ b/test/Docbook/basic/htmlhelp/htmlhelp.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/man/man.py b/test/Docbook/basic/man/man.py index c1f164d..d9b16b3 100644 --- a/test/Docbook/basic/man/man.py +++ b/test/Docbook/basic/man/man.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/slideshtml/slideshtml.py b/test/Docbook/basic/slideshtml/slideshtml.py index 37c2be0..8251b3e 100644 --- a/test/Docbook/basic/slideshtml/slideshtml.py +++ b/test/Docbook/basic/slideshtml/slideshtml.py @@ -39,6 +39,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/basic/xinclude/xinclude.py b/test/Docbook/basic/xinclude/xinclude.py index 2d87713..302c777 100644 --- a/test/Docbook/basic/xinclude/xinclude.py +++ b/test/Docbook/basic/xinclude/xinclude.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/dependencies/xinclude/xinclude.py b/test/Docbook/dependencies/xinclude/xinclude.py index 84d9ce7..115163c 100644 --- a/test/Docbook/dependencies/xinclude/xinclude.py +++ b/test/Docbook/dependencies/xinclude/xinclude.py @@ -32,6 +32,7 @@ test = TestSCons.TestSCons() try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/rootname/htmlchunked/htmlchunked.py b/test/Docbook/rootname/htmlchunked/htmlchunked.py index 8ab91d2..65b50ef 100644 --- a/test/Docbook/rootname/htmlchunked/htmlchunked.py +++ b/test/Docbook/rootname/htmlchunked/htmlchunked.py @@ -38,6 +38,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/rootname/htmlhelp/htmlhelp.py b/test/Docbook/rootname/htmlhelp/htmlhelp.py index ee37e1a..9d0b076 100644 --- a/test/Docbook/rootname/htmlhelp/htmlhelp.py +++ b/test/Docbook/rootname/htmlhelp/htmlhelp.py @@ -38,6 +38,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/Docbook/rootname/slideshtml/slideshtml.py b/test/Docbook/rootname/slideshtml/slideshtml.py index 4d55035..399764b 100644 --- a/test/Docbook/rootname/slideshtml/slideshtml.py +++ b/test/Docbook/rootname/slideshtml/slideshtml.py @@ -39,6 +39,7 @@ if not (sys.platform.startswith('linux') and try: import libxml2 + import libxslt except: try: import lxml diff --git a/test/FindSourceFiles.py b/test/FindSourceFiles.py index 3ba542b..88b9d7e 100644 --- a/test/FindSourceFiles.py +++ b/test/FindSourceFiles.py @@ -28,12 +28,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Test Environment's FindSourceFiles method. """ +import sys import TestSCons test = TestSCons.TestSCons() package_format = "src_tarbz2" -if not test.where_is('tar'): +if not test.where_is('tar') or sys.platform == 'win32': if not test.where_is('zip'): test.skip_test("neither 'tar' nor 'zip' found; skipping test\n") package_format = "src_zip" diff --git a/test/Fortran/F08.py b/test/Fortran/F08.py new file mode 100644 index 0000000..35df37c --- /dev/null +++ b/test/Fortran/F08.py @@ -0,0 +1,151 @@ +#!/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__" + +import TestSCons + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +length = len(comment) +opts, args = getopt.getopt(sys.argv[2:], 'co:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:length] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F08 = r'%(_python_)s myfortran.py f08', + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f08') +env.Program(target = 'test10', source = 'test10.F08') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") +test.write('test09.f08', "This is a .f08 file.\n#link\n#f08\n") +test.write('test10.F08', "This is a .F08 file.\n#link\n#f08\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f08 file.\n") +test.must_match('test10' + _exe, "This is a .F08 file.\n") + + +fc = 'f08' +g08 = test.detect_tool(fc) + +if g08: + + test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +foo = Environment(F08 = '%(fc)s') +f08 = foo.Dictionary('F08') +bar = foo.Clone(F08 = r'%(_python_)s wrapper.py ' + f08) +foo.Program(target = 'foo', source = 'foo.f08') +bar.Program(target = 'bar', source = 'bar.f08') +""" % locals()) + + test.write('foo.f08', r""" + PROGRAM FOO + PRINT *,'foo.f08' + ENDPROGRAM FOO +""") + + test.write('bar.f08', r""" + PROGRAM BAR + PRINT *,'bar.f08' + ENDPROGRAM BAR +""") + + + test.run(arguments = 'foo' + _exe, stderr = None) + + test.run(program = test.workpath('foo'), stdout = " foo.f08\n") + + test.must_not_exist('wrapper.out') + + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) + + test.run(program = test.workpath('bar'), stdout = " bar.f08\n") + + test.must_match('wrapper.out', "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/F08COM.py b/test/Fortran/F08COM.py new file mode 100644 index 0000000..783a163 --- /dev/null +++ b/test/Fortran/F08COM.py @@ -0,0 +1,98 @@ +#!/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__" + +import TestSCons + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import sys +comment = '#' + sys.argv[1] +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F08COM = r'%(_python_)s myfortran.py f08 $TARGET $SOURCES', + F08PPCOM = r'%(_python_)s myfortran.py f08pp $TARGET $SOURCES', + FORTRANCOM = r'%(_python_)s myfortran.py fortran $TARGET $SOURCES', + FORTRANPPCOM = r'%(_python_)s myfortran.py fortranpp $TARGET $SOURCES') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f08') +env.Program(target = 'test10', source = 'test10.F08') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") +test.write('test09.f08', "This is a .f08 file.\n#link\n#f08\n") +test.write('test10.F08', "This is a .F08 file.\n#link\n#f08pp\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f08 file.\n") +test.must_match('test10' + _exe, "This is a .F08 file.\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/F08COMSTR.py b/test/Fortran/F08COMSTR.py new file mode 100644 index 0000000..65bf32c --- /dev/null +++ b/test/Fortran/F08COMSTR.py @@ -0,0 +1,78 @@ +#!/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__" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + + + +test.write('myfc.py', r""" +import sys +fline = '#'+sys.argv[1]+'\n' +outfile = open(sys.argv[2], 'wb') +infile = open(sys.argv[3], 'rb') +for l in [l for l in infile.readlines() if l != fline]: + outfile.write(l) +sys.exit(0) +""") + +if not TestSCons.case_sensitive_suffixes('.f','.F'): + f08pp = 'f08' +else: + f08pp = 'f08pp' + + +test.write('SConstruct', """ +env = Environment(F08COM = r'%(_python_)s myfc.py f08 $TARGET $SOURCES', + F08COMSTR = 'Building f08 $TARGET from $SOURCES', + F08PPCOM = r'%(_python_)s myfc.py f08pp $TARGET $SOURCES', + F08PPCOMSTR = 'Building f08pp $TARGET from $SOURCES', + OBJSUFFIX='.obj') +env.Object(source = 'test01.f08') +env.Object(source = 'test02.F08') +""" % locals()) + +test.write('test01.f08', "A .f08 file.\n#f08\n") +test.write('test02.F08', "A .F08 file.\n#%s\n" % f08pp) + +test.run(stdout = test.wrap_stdout("""\ +Building f08 test01.obj from test01.f08 +Building %(f08pp)s test02.obj from test02.F08 +""" % locals())) + +test.must_match('test01.obj', "A .f08 file.\n") +test.must_match('test02.obj', "A .F08 file.\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/F08FILESUFFIXES.py b/test/Fortran/F08FILESUFFIXES.py new file mode 100644 index 0000000..8463403 --- /dev/null +++ b/test/Fortran/F08FILESUFFIXES.py @@ -0,0 +1,101 @@ +#!/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__" + +import TestSCons + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], 'co:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test default file suffix: .f90/.F90 for F90 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F08 = r'%(_python_)s myfortran.py f08', + FORTRAN = r'%(_python_)s myfortran.py fortran') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f08') +env.Program(target = 'test10', source = 'test10.F08') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortranpp\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortranpp\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortranpp\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortranpp\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortranpp\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortranpp\n") +test.write('test09.f08', "This is a .f08 file.\n#link\n#f08\n") +test.write('test10.F08', "This is a .F08 file.\n#link\n#f08pp\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .for file.\n") +test.must_match('test04' + _exe, "This is a .FOR file.\n") +test.must_match('test05' + _exe, "This is a .ftn file.\n") +test.must_match('test06' + _exe, "This is a .FTN file.\n") +test.must_match('test07' + _exe, "This is a .fpp file.\n") +test.must_match('test08' + _exe, "This is a .FPP file.\n") +test.must_match('test09' + _exe, "This is a .f08 file.\n") +test.must_match('test10' + _exe, "This is a .F08 file.\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/F08FILESUFFIXES2.py b/test/Fortran/F08FILESUFFIXES2.py new file mode 100644 index 0000000..39bba44 --- /dev/null +++ b/test/Fortran/F08FILESUFFIXES2.py @@ -0,0 +1,91 @@ +#!/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__" + +import TestSCons + +from common import write_fake_link + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], 'co:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + +# Test non-default file suffix: .f/.F for F08 +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F77 = r'%(_python_)s myfortran.py f77', + F08 = r'%(_python_)s myfortran.py f08', + F08FILESUFFIXES = ['.f', '.F', '.f08', '.F08'], + tools = ['default', 'f08']) +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.f08') +env.Program(target = 'test04', source = 'test04.F08') +env.Program(target = 'test05', source = 'test05.f77') +env.Program(target = 'test06', source = 'test06.F77') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#f08\n") +test.write('test02.F', "This is a .F file.\n#link\n#f08\n") +test.write('test03.f08', "This is a .f08 file.\n#link\n#f08\n") +test.write('test04.F08', "This is a .F08 file.\n#link\n#f08\n") +test.write('test05.f77', "This is a .f77 file.\n#link\n#f77\n") +test.write('test06.F77', "This is a .F77 file.\n#link\n#f77\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, "This is a .f file.\n") +test.must_match('test02' + _exe, "This is a .F file.\n") +test.must_match('test03' + _exe, "This is a .f08 file.\n") +test.must_match('test04' + _exe, "This is a .F08 file.\n") +test.must_match('test05' + _exe, "This is a .f77 file.\n") +test.must_match('test06' + _exe, "This is a .F77 file.\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/F08FLAGS.py b/test/Fortran/F08FLAGS.py new file mode 100644 index 0000000..866ea2c --- /dev/null +++ b/test/Fortran/F08FLAGS.py @@ -0,0 +1,158 @@ +#!/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__" + +import TestSCons + +from common import write_fake_link + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() +_exe = TestSCons._exe + +write_fake_link(test) + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], 'co:xy') +optstring = '' +for opt, arg in opts: + if opt == '-o': out = arg + else: optstring = optstring + ' ' + opt +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +outfile.write(optstring + "\n") +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(LINK = r'%(_python_)s mylink.py', + LINKFLAGS = [], + F08 = r'%(_python_)s myfortran.py g08', + F08FLAGS = '-x', + FORTRAN = r'%(_python_)s myfortran.py fortran', + FORTRANFLAGS = '-y') +env.Program(target = 'test01', source = 'test01.f') +env.Program(target = 'test02', source = 'test02.F') +env.Program(target = 'test03', source = 'test03.for') +env.Program(target = 'test04', source = 'test04.FOR') +env.Program(target = 'test05', source = 'test05.ftn') +env.Program(target = 'test06', source = 'test06.FTN') +env.Program(target = 'test07', source = 'test07.fpp') +env.Program(target = 'test08', source = 'test08.FPP') +env.Program(target = 'test09', source = 'test09.f08') +env.Program(target = 'test10', source = 'test10.F08') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#link\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#link\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#link\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#link\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#link\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#link\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#link\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#link\n#fortran\n") +test.write('test09.f08', "This is a .f08 file.\n#link\n#g08\n") +test.write('test10.F08', "This is a .F08 file.\n#link\n#g08\n") + +test.run(arguments = '.', stderr = None) + +test.must_match('test01' + _exe, " -c -y\nThis is a .f file.\n") +test.must_match('test02' + _exe, " -c -y\nThis is a .F file.\n") +test.must_match('test03' + _exe, " -c -y\nThis is a .for file.\n") +test.must_match('test04' + _exe, " -c -y\nThis is a .FOR file.\n") +test.must_match('test05' + _exe, " -c -y\nThis is a .ftn file.\n") +test.must_match('test06' + _exe, " -c -y\nThis is a .FTN file.\n") +test.must_match('test07' + _exe, " -c -y\nThis is a .fpp file.\n") +test.must_match('test08' + _exe, " -c -y\nThis is a .FPP file.\n") +test.must_match('test09' + _exe, " -c -x\nThis is a .f08 file.\n") +test.must_match('test10' + _exe, " -c -x\nThis is a .F08 file.\n") + + +fc = 'f08' +g08 = test.detect_tool(fc) + + +if g08: + + test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +foo = Environment(F08 = '%(fc)s') +f08 = foo.Dictionary('F08') +bar = foo.Clone(F08 = r'%(_python_)s wrapper.py ' + f08, F08FLAGS = '-Ix') +foo.Program(target = 'foo', source = 'foo.f08') +bar.Program(target = 'bar', source = 'bar.f08') +""" % locals()) + + test.write('foo.f08', r""" + PROGRAM FOO + PRINT *,'foo.f08' + ENDPROGRAM FOO +""") + + test.write('bar.f08', r""" + PROGRAM BAR + PRINT *,'bar.f08' + ENDPROGRAM FOO +""") + + + test.run(arguments = 'foo' + _exe, stderr = None) + + test.run(program = test.workpath('foo'), stdout = " foo.f08\n") + + test.must_not_exist('wrapper.out') + + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar' + _exe, stderr = None) + else: + test.run(arguments = 'bar' + _exe) + + test.run(program = test.workpath('bar'), stdout = " bar.f08\n") + + test.must_match('wrapper.out', "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Fortran/FORTRANSUFFIXES.py b/test/Fortran/FORTRANSUFFIXES.py index 583b71b..9673e6f 100644 --- a/test/Fortran/FORTRANSUFFIXES.py +++ b/test/Fortran/FORTRANSUFFIXES.py @@ -56,51 +56,51 @@ env = Environment(FORTRANPATH = ['.'], env.Append(FORTRANSUFFIXES = ['.x']) env.Object(target = 'test1', source = 'test1.f') env.InstallAs('test1_f', 'test1.f') -env.InstallAs('test1_h', 'test1.h') env.InstallAs('test1_x', 'test1.x') +env.InstallAs('test2_f', 'test2.f') """ % locals()) test.write('test1.f', """\ test1.f 1 - INCLUDE 'test1.h' + INCLUDE 'test2.f' INCLUDE 'test1.x' """) -test.write('test1.h', """\ - test1.h 1 - INCLUDE 'foo.h' +test.write('test2.f', """\ + test2.f 1 + INCLUDE 'foo.f' """) test.write('test1.x', """\ test1.x 1 - INCLUDE 'foo.h' + INCLUDE 'foo.f' """) -test.write('foo.h', """\ - foo.h 1 +test.write('foo.f', """\ + foo.f 1 """) expect = test.wrap_stdout("""\ %(_python_)s myfc.py test1.o test1.f Install file: "test1.f" as "test1_f" -Install file: "test1.h" as "test1_h" Install file: "test1.x" as "test1_x" +Install file: "test2.f" as "test2_f" """ % locals()) test.run(arguments='.', stdout=expect) test.must_match('test1.o', """\ test1.f 1 - test1.h 1 - foo.h 1 + test2.f 1 + foo.f 1 test1.x 1 - foo.h 1 + foo.f 1 """) test.up_to_date(arguments='.') -test.write('foo.h', """\ - foo.h 2 +test.write('foo.f', """\ + foo.f 2 """) expect = test.wrap_stdout("""\ @@ -111,17 +111,17 @@ test.run(arguments='.', stdout=expect) test.must_match('test1.o', """\ test1.f 1 - test1.h 1 - foo.h 2 + test2.f 1 + foo.f 2 test1.x 1 - foo.h 2 + foo.f 2 """) test.up_to_date(arguments='.') test.write('test1.x', """\ test1.x 2 - INCLUDE 'foo.h' + INCLUDE 'foo.f' """) expect = test.wrap_stdout("""\ @@ -133,32 +133,32 @@ test.run(arguments='.', stdout=expect) test.must_match('test1.o', """\ test1.f 1 - test1.h 1 - foo.h 2 + test2.f 1 + foo.f 2 test1.x 2 - foo.h 2 + foo.f 2 """) test.up_to_date(arguments='.') -test.write('test1.h', """\ - test1.h 2 - INCLUDE 'foo.h' +test.write('test2.f', """\ + test2.f 2 + INCLUDE 'foo.f' """) expect = test.wrap_stdout("""\ %(_python_)s myfc.py test1.o test1.f -Install file: "test1.h" as "test1_h" +Install file: "test2.f" as "test2_f" """ % locals()) test.run(arguments='.', stdout=expect) test.must_match('test1.o', """\ test1.f 1 - test1.h 2 - foo.h 2 + test2.f 2 + foo.f 2 test1.x 2 - foo.h 2 + foo.f 2 """) test.up_to_date(arguments='.') diff --git a/test/Fortran/SHF08.py b/test/Fortran/SHF08.py new file mode 100644 index 0000000..85f2bcd --- /dev/null +++ b/test/Fortran/SHF08.py @@ -0,0 +1,144 @@ +#!/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__" + +import TestSCons + +_python_ = TestSCons._python_ +_obj = TestSCons._shobj +obj_ = TestSCons.shobj_ + +test = TestSCons.TestSCons() + + + +test.write('myfortran.py', r""" +import getopt +import sys +comment = '#' + sys.argv[1] +opts, args = getopt.getopt(sys.argv[2:], 'cf:o:K:') +for opt, arg in opts: + if opt == '-o': out = arg +infile = open(args[0], 'rb') +outfile = open(out, 'wb') +for l in infile.readlines(): + if l[:len(comment)] != comment: + outfile.write(l) +sys.exit(0) +""") + + + +test.write('SConstruct', """ +env = Environment(SHF08 = r'%(_python_)s myfortran.py g08', + SHFORTRAN = r'%(_python_)s myfortran.py fortran') +env.SharedObject(target = 'test01', source = 'test01.f') +env.SharedObject(target = 'test02', source = 'test02.F') +env.SharedObject(target = 'test03', source = 'test03.for') +env.SharedObject(target = 'test04', source = 'test04.FOR') +env.SharedObject(target = 'test05', source = 'test05.ftn') +env.SharedObject(target = 'test06', source = 'test06.FTN') +env.SharedObject(target = 'test07', source = 'test07.fpp') +env.SharedObject(target = 'test08', source = 'test08.FPP') +env.SharedObject(target = 'test09', source = 'test09.f08') +env.SharedObject(target = 'test10', source = 'test10.F08') +""" % locals()) + +test.write('test01.f', "This is a .f file.\n#fortran\n") +test.write('test02.F', "This is a .F file.\n#fortran\n") +test.write('test03.for', "This is a .for file.\n#fortran\n") +test.write('test04.FOR', "This is a .FOR file.\n#fortran\n") +test.write('test05.ftn', "This is a .ftn file.\n#fortran\n") +test.write('test06.FTN', "This is a .FTN file.\n#fortran\n") +test.write('test07.fpp', "This is a .fpp file.\n#fortran\n") +test.write('test08.FPP', "This is a .FPP file.\n#fortran\n") +test.write('test09.f08', "This is a .f08 file.\n#g08\n") +test.write('test10.F08', "This is a .F08 file.\n#g08\n") + +test.run(arguments = '.', stderr = None) + +test.must_match(obj_ + 'test01' + _obj, "This is a .f file.\n") +test.must_match(obj_ + 'test02' + _obj, "This is a .F file.\n") +test.must_match(obj_ + 'test03' + _obj, "This is a .for file.\n") +test.must_match(obj_ + 'test04' + _obj, "This is a .FOR file.\n") +test.must_match(obj_ + 'test05' + _obj, "This is a .ftn file.\n") +test.must_match(obj_ + 'test06' + _obj, "This is a .FTN file.\n") +test.must_match(obj_ + 'test07' + _obj, "This is a .fpp file.\n") +test.must_match(obj_ + 'test08' + _obj, "This is a .FPP file.\n") +test.must_match(obj_ + 'test09' + _obj, "This is a .f08 file.\n") +test.must_match(obj_ + 'test10' + _obj, "This is a .F08 file.\n") + +fc = 'f08' +g08 = test.detect_tool(fc) + +if g08: + + test.write("wrapper.py", +"""import os +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(" ".join(sys.argv[1:])) +""" % test.workpath('wrapper.out').replace('\\', '\\\\')) + + test.write('SConstruct', """ +foo = Environment(SHF08 = '%(fc)s') +shf08 = foo.Dictionary('SHF08') +bar = foo.Clone(SHF08 = r'%(_python_)s wrapper.py ' + shf08) +foo.SharedObject(target = 'foo/foo', source = 'foo.f08') +bar.SharedObject(target = 'bar/bar', source = 'bar.f08') +""" % locals()) + + test.write('foo.f08', r""" + PROGRAM FOO + PRINT *,'foo.f08' + ENDPROGRAM FOO +""") + + test.write('bar.f08', r""" + PROGRAM BAR + PRINT *,'bar.f08' + ENDPROGRAM BAR +""") + + + test.run(arguments = 'foo', stderr = None) + + test.must_not_exist('wrapper.out') + + import sys + if sys.platform[:5] == 'sunos': + test.run(arguments = 'bar', stderr = None) + else: + test.run(arguments = 'bar') + + test.must_match('wrapper.out', "wrapper.py\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/Repository.py b/test/Glob/Repository.py index 0a2e326..22a7f88 100644 --- a/test/Glob/Repository.py +++ b/test/Glob/Repository.py @@ -75,7 +75,7 @@ test.write(['repository', 'src', 'SConscript'], """ Import("env") env.Build('xxx.out', Glob('x*.in')) env.Build('yyy.out', Glob('yy?.in')) -env.Build('zzz.out', sorted(Glob('*/zzz.in'), key=lambda t: t.abspath)) +env.Build('zzz.out', sorted(Glob('*/zzz.in'), key=lambda t: t.get_abspath())) """) test.write(['repository', 'src', 'xxx.in'], "repository/src/xxx.in\n") diff --git a/test/Glob/VariantDir.py b/test/Glob/VariantDir.py index 175e5b9..c9c1d07 100644 --- a/test/Glob/VariantDir.py +++ b/test/Glob/VariantDir.py @@ -34,6 +34,7 @@ import TestSCons test = TestSCons.TestSCons() test.subdir('src') +test.subdir('src/sub1') test.write('SConstruct', """\ VariantDir('var1', 'src') @@ -41,6 +42,9 @@ VariantDir('var2', 'src') SConscript('var1/SConscript') SConscript('var2/SConscript') +SConscript('var1/sub1/SConscript') +SConscript('var2/sub1/SConscript') +SConscript('src/sub1/SConscript', src_dir = 'src', variant_dir = 'var3', duplicate=0) """) test.write(['src', 'SConscript'], """\ @@ -55,16 +59,46 @@ def concatenate(target, source, env): env['BUILDERS']['Concatenate'] = Builder(action=concatenate) env.Concatenate('f.out', sorted(Glob('f*.in'), key=lambda t: t.name)) +env.Concatenate('fex.out', sorted(Glob('f*.in', exclude = 'f1.in'), key=lambda t: t.name)) +""") + +test.write(['src', 'sub1', 'SConscript'], """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('f.out', sorted(Glob('f*.in'), key=lambda t: t.name)) +env.Concatenate('fex.out', sorted(Glob('f*.in', exclude = 'f1.in'), key=lambda t: t.name)) """) test.write(['src', 'f1.in'], "src/f1.in\n") test.write(['src', 'f2.in'], "src/f2.in\n") test.write(['src', 'f3.in'], "src/f3.in\n") +test.write(['src', 'sub1', 'f1.in'], "src/sub1/f1.in\n") +test.write(['src', 'sub1', 'f2.in'], "src/sub1/f2.in\n") +test.write(['src', 'sub1', 'f3.in'], "src/sub1/f3.in\n") + test.run(arguments = '.') test.must_match(['var1', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") test.must_match(['var2', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") +test.must_match(['var1', 'fex.out'], "src/f2.in\nsrc/f3.in\n") +test.must_match(['var2', 'fex.out'], "src/f2.in\nsrc/f3.in\n") + +test.must_match(['var1', 'sub1', 'f.out'], "src/sub1/f1.in\nsrc/sub1/f2.in\nsrc/sub1/f3.in\n") +test.must_match(['var2', 'sub1', 'f.out'], "src/sub1/f1.in\nsrc/sub1/f2.in\nsrc/sub1/f3.in\n") +test.must_match(['var1', 'sub1', 'fex.out'], "src/sub1/f2.in\nsrc/sub1/f3.in\n") +test.must_match(['var2', 'sub1', 'fex.out'], "src/sub1/f2.in\nsrc/sub1/f3.in\n") + +test.must_match(['var3', 'sub1', 'f.out'], "src/sub1/f1.in\nsrc/sub1/f2.in\nsrc/sub1/f3.in\n") +test.must_match(['var3', 'sub1', 'fex.out'], "src/sub1/f2.in\nsrc/sub1/f3.in\n") test.pass_test() diff --git a/test/Glob/exclude.py b/test/Glob/exclude.py new file mode 100644 index 0000000..fe93b82 --- /dev/null +++ b/test/Glob/exclude.py @@ -0,0 +1,86 @@ +#!/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__" + +""" +Verify the "exclude" parameter usage of the Glob() function. + - with or without subdir + - with or without returning strings + - a file in a subdir is not excluded by a pattern without this subdir +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('fa.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , strings=False), key=lambda t: t.get_internal_path())) +env.Concatenate('fb.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , strings=True))) +env.Concatenate('fc.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=False), key=lambda t: t.get_internal_path())) +env.Concatenate('fd.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=True))) +env.Concatenate('fe.out', sorted(Glob('f*.in', exclude='f1.in' , strings=True))) +env.Concatenate('ff.out', sorted(Glob('f*.in', exclude='other' , strings=True))) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") +test.write('f5.in', "f5.in\n") + +test.subdir('d1', 'd2') +test.write(['d1', 'f1.in'], "d1/f1.in\n") +test.write(['d1', 'f2.in'], "d1/f2.in\n") +test.write(['d1', 'f3.in'], "d1/f3.in\n") +test.write(['d2', 'f1.in'], "d2/f1.in\n") +test.write(['d2', 'f2.in'], "d2/f2.in\n") +test.write(['d2', 'f3.in'], "d2/f3.in\n") + +test.run(arguments = '.') + +test.must_match('fa.out', "f1.in\nf3.in\nf5.in\n") +test.must_match('fb.out', "f1.in\nf3.in\nf5.in\n") +test.must_match('fc.out', "d1/f2.in\nd1/f3.in\nd2/f2.in\nd2/f3.in\n") +test.must_match('fd.out', "d1/f2.in\nd1/f3.in\nd2/f2.in\nd2/f3.in\n") +test.must_match('fe.out', "f2.in\nf3.in\nf4.in\nf5.in\n") +test.must_match('ff.out', "f1.in\nf2.in\nf3.in\nf4.in\nf5.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Help.py b/test/Help.py index 747fe59..693fd28 100644 --- a/test/Help.py +++ b/test/Help.py @@ -82,6 +82,69 @@ Use scons -H for help about command-line options. test.run(arguments = '-h', stdout = expect) +# Bug #2831 - append flag to Help doesn't wipe out addoptions and variables used together +test.write('SConstruct', r""" + +AddOption('--debugging', + dest='debugging', + action='store_true', + default=False, + metavar='BDEBUGGING', + help='Compile with debugging symbols') + +vars = Variables() +vars.Add(ListVariable('buildmod', 'List of modules to build', 'none', + ['python'])) + +env = Environment() + +Help(vars.GenerateHelpText(env),append=True) +""") + +expect = ".*--debugging.*Compile with debugging symbols.*buildmod: List of modules to build.*" + +test.run(arguments = '-h', stdout = expect, match=TestSCons.match_re_dotall) + + +# Bug 2831 +# This test checks to verify that append=False doesn't include anything +# but the expected help for the specified Variable() + +test.write('SConstruct', r""" + +AddOption('--debugging', + dest='debugging', + action='store_true', + default=False, + metavar='BDEBUGGING', + help='Compile with debugging symbols') + +vars = Variables() +vars.Add(ListVariable('buildmod', 'List of modules to build', 'none', + ['python'])) + +env = Environment() + +Help(vars.GenerateHelpText(env),append=False) +""") + +expect = """\ +scons: Reading SConscript files ... +scons: done reading SConscript files. + +buildmod: List of modules to build + (all|none|comma-separated list of names) + allowed names: python + default: none + actual: None + +Use scons -H for help about command-line options. +""" + +test.run(arguments = '-h', stdout = expect) + + + test.pass_test() # Local Variables: diff --git a/test/IDL/IDLSUFFIXES.py b/test/IDL/IDLSUFFIXES.py index f71ceba..0a9a50c 100644 --- a/test/IDL/IDLSUFFIXES.py +++ b/test/IDL/IDLSUFFIXES.py @@ -60,11 +60,6 @@ test.up_to_date(arguments='.') test.write('foo.h', "foo.h 2\n") -test.run(arguments='.', stdout=test.wrap_stdout("""\ -Install file: "foo.idl" as "foo_idl" -Install file: "foo.x" as "foo_x" -""")) - test.up_to_date(arguments='.') test.pass_test() diff --git a/test/Install/wrap-by-attribute.py b/test/Install/wrap-by-attribute.py index 912551e..02513af 100644 --- a/test/Install/wrap-by-attribute.py +++ b/test/Install/wrap-by-attribute.py @@ -58,10 +58,10 @@ env.SconsInternalInstallFunc = env.Install env.SconsInternalInstallAsFunc = env.InstallAs def InstallWithDestDir(dir, source): - abspath = os.path.splitdrive(env.Dir(dir).abspath)[1] + abspath = os.path.splitdrive(env.Dir(dir).get_abspath())[1] return env.SconsInternalInstallFunc('$DESTDIR'+abspath, source) def InstallAsWithDestDir(target, source): - abspath = os.path.splitdrive(env.File(target).abspath)[1] + abspath = os.path.splitdrive(env.File(target).get_abspath())[1] return env.SconsInternalInstallAsFunc('$DESTDIR'+abspath, source) # Add the wrappers directly as attributes. diff --git a/test/Interactive/configure.py b/test/Interactive/configure.py new file mode 100644 index 0000000..1a92f6c --- /dev/null +++ b/test/Interactive/configure.py @@ -0,0 +1,127 @@ +#!/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__" + +""" +Verify basic operation of the --interactive command line option to build +a target, while using a Configure context within the environment. + +Also tests that "b" can be used as a synonym for "build". +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +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) +""") + +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.Object('foo.obj','foo.cpp') +""" % locals()) + +test.write('foo.cpp', """\ +#include <stdio.h> + +int main (int argc, char *argv[]) +{ + printf("Hello, World!"); + return 0; +} +""") + + +scons = test.start(arguments = '-Q --interactive') +# Initial build +scons.send("build foo.obj\n") + +test.wait_for(test.workpath('foo.obj')) +# Update without any changes -> no action +scons.send("build foo.obj\n") +# Changing the source file +test.write('foo.cpp', """\ +#include <stdio.h> + +void foo() +{ + ; +} + +int main (int argc, char *argv[]) +{ + printf("Hello, World!"); + return 0; +} +""") + +# Verify that "b" can be used as a synonym for the "build" command. +scons.send("b foo.obj\n") + +scons.send("build foo.obj\n") + +expect_stdout = r"""scons>>> .*foo\.cpp.* +scons>>> .*foo\.cpp.* +scons>>> scons: `foo.obj' is up to date. +scons>>> scons: `foo.obj' is up to date. +scons>>>\s* +""" + +test.finish(scons, stdout = expect_stdout, match=TestSCons.match_re) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Interactive/variant_dir.py b/test/Interactive/variant_dir.py index f36bd0a..7f2c42f 100644 --- a/test/Interactive/variant_dir.py +++ b/test/Interactive/variant_dir.py @@ -41,10 +41,10 @@ marker_2 = test.workpath('markers', '2') test.write(['work', 'SConstruct'], """\ # build the plugin binaries -basepath = str(Dir('#').abspath) +basepath = str(Dir('#').get_abspath()) env = Environment() env.Append(BASEPATH=basepath) -env.Append(ENV = {'BASEPATH' : str(Dir('#').abspath)}) +env.Append(ENV = {'BASEPATH' : str(Dir('#').get_abspath())}) SConscript( 'sub1/SConscript', variant_dir = 'build', duplicate=False, diff --git a/test/Java/DerivedSourceTest.py b/test/Java/DerivedSourceTest.py index c749cf3..7f80595 100644 --- a/test/Java/DerivedSourceTest.py +++ b/test/Java/DerivedSourceTest.py @@ -45,14 +45,14 @@ SCons.Defaults.DefaultEnvironment(tools = []) test = TestSCons.TestSCons() -# No result if tools not available -test.no_result( condition=(test.where_is( 'javac' ) is None) ) -test.no_result( condition=(test.where_is( 'jar' ) is None) ) - # This test is known to fail as of July 2014; see Tigris issue 1771 and issue 2931. # Once the underlying issue is corrected, this test should be re-enabled. test.skip_test('Skipping derived-source test until issue 1771 is fixed.\n') +# No result if tools not available +test.no_result( condition=(test.where_is( 'javac' ) is None) ) +test.no_result( condition=(test.where_is( 'jar' ) is None) ) + test.write( ['Sample.java'], """ diff --git a/test/LEX/live.py b/test/LEX/live.py index f50b06f..e4b4dfb 100644 --- a/test/LEX/live.py +++ b/test/LEX/live.py @@ -68,6 +68,7 @@ yywrap() return 1; } +int main() { yylex(); diff --git a/test/LINK/SHLIBVERSIONFLAGS.py b/test/LINK/SHLIBVERSIONFLAGS.py new file mode 100644 index 0000000..d8fd2e6 --- /dev/null +++ b/test/LINK/SHLIBVERSIONFLAGS.py @@ -0,0 +1,59 @@ +#!/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__" + +import os +import re + +import TestSCons +import SCons.Platform +import SCons.Defaults + +linkers = [ 'gnulink', 'cyglink', 'sunlink' ] + +foo_c_src = "void foo() {}\n" + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +test = TestSCons.TestSCons() +test.write('foo.c', foo_c_src) +test.write('SConstruct', "SharedLibrary('foo','foo.c',SHLIBVERSION='1.2.3')\n") + +if 'gnulink' in tool_list: + test.run(stdout = r".+ -Wl,-Bsymbolic -Wl,-soname=libfoo.so.1( .+)+", match = TestSCons.match_re_dotall) + test.run(arguments = ['-c']) +elif 'sunlink' in tool_list: + test.run(stdout = r".+ -h libfoo.so.1( .+)+", match = TestSCons.match_re_dotall) + test.run(arguments = ['-c']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/VersionedLib-VariantDir.py b/test/LINK/VersionedLib-VariantDir.py new file mode 100644 index 0000000..0a631b0 --- /dev/null +++ b/test/LINK/VersionedLib-VariantDir.py @@ -0,0 +1,168 @@ +#!/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__" + +""" +Ensure that SharedLibrary builder with SHLIBVERSION set works with VariantDir. +""" + +import TestSCons +import os +import sys + +import SCons.Platform +import SCons.Defaults + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +test = TestSCons.TestSCons() + +test.subdir(['src']) +test.subdir(['src','lib']) +test.subdir(['src','bin']) + +test.write(['src','lib','foo.c'], """ +#if _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } +""") + +test.write(['src','bin','main.c'], """ +#if _WIN32 +__declspec(dllimport) +#endif +int foo(); +int main() +{ + return foo(); +} +""") + +test.write('SConstruct', """ +env = Environment() +variant = { 'variant_dir' : 'build', + 'src_dir' : 'src', + 'duplicate' : 0, + 'exports' : { 'env' : env } } +SConscript('src/lib/SConscript', **variant) +SConscript('src/bin/SConscript', **variant) +""") + +test.write(['src','lib','SConscript'], """ +Import('env') +env.SharedLibrary('foo', 'foo.c', SHLIBVERSION = '0.1.2') +""" ) + +test.write(['src','bin','SConscript'], """ +Import('env') +env.Program('main.c', LIBS=['foo'], LIBPATH=['../lib']) +""") + +test.run(arguments = ['--tree=all']) + +if platform == 'cygwin' or platform == 'win32': + # PATH is used to search for *.dll libraries on windows + path = os.environ.get('PATH','') + if path: path = path + os.pathsep + path = path + test.workpath('build/lib') + os.environ['PATH'] = path + +if os.name == 'posix': + os.environ['LD_LIBRARY_PATH'] = test.workpath('build/lib') +if sys.platform.find('irix') != -1: + os.environ['LD_LIBRARYN32_PATH'] = test.workpath('build/lib') + +test.run(program = test.workpath('build/bin/main')) + +if 'gnulink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + ] + obj = 'foo.os' +elif 'applelink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.dylib', + 'libfoo.0.1.2.dylib', + ] + obj = 'foo.os' +elif 'cyglink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'cygfoo-0-1-2.dll', + 'libfoo-0-1-2.dll.a', + 'libfoo.dll.a', + ] + obj = 'foo.os' +elif 'mslink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'foo.dll', + 'foo.lib', + ] + obj = 'foo.obj' +elif 'sunlink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + ] + obj = 'so_foo.os' +else: + # All (?) the files we expect will get created in the current directory + files= [ + 'libfoo.so', + ] + obj = 'foo.os' + +test.must_exist([ 'build', 'lib', obj ]) +for f in files: + test.must_exist([ 'build', 'lib', f ]) + +test.run(arguments = ['-c']) + +test.must_not_exist([ 'build', 'lib', obj ]) +for f in files: + test.must_not_exist([ 'build', 'lib', f ]) + +test.must_exist(['src', 'lib', 'foo.c']) +test.must_exist(['SConstruct']) +test.must_exist(['src', 'lib', 'SConscript']) +test.must_exist(['src', 'bin', 'SConscript']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/VersionedLib-j2.py b/test/LINK/VersionedLib-j2.py new file mode 100644 index 0000000..249b54f --- /dev/null +++ b/test/LINK/VersionedLib-j2.py @@ -0,0 +1,146 @@ +#!/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__" + +""" +Ensure that SharedLibrary builder works with SHLIBVERSION and -j2. +This is regression test for: +http://article.gmane.org/gmane.comp.programming.tools.scons.user/27049 +""" + +import TestSCons +import os +import sys + +import SCons.Platform +import SCons.Defaults + +test = TestSCons.TestSCons() + +test.write('foo.c', """ +#if _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } +""") + + +test.write('main.c', """ +#if _WIN32 +__declspec(dllimport) +#endif +int foo(); +int main() { return foo(); } +""") + +test.write('SConstruct', """ +env = Environment() +env.AppendUnique(LIBPATH = ['.']) +env.Program('main.c', LIBS = ['foo']) +env.SharedLibrary('foo', 'foo.c', SHLIBVERSION = '0.1.2') +""") + +test.run(arguments = ['-j 2', '--tree=all']) + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +if platform == 'cygwin': + # PATH is used to search for *.dll librarier (cygfoo-0-2-1.dll in our case) + path = os.environ.get('PATH','') + if path: path = path + os.pathsep + path = path + test.workpath('.') + os.environ['PATH'] = path + +if os.name == 'posix': + os.environ['LD_LIBRARY_PATH'] = test.workpath('.') +if sys.platform.find('irix') != -1: + os.environ['LD_LIBRARYN32_PATH'] = test.workpath('.') + +test.run(program = test.workpath('main')) + +test.run(arguments = ['-c']) + +platform = SCons.Platform.platform_default() + +if 'gnulink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + 'foo.os', + ] +elif 'applelink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.dylib', + 'libfoo.0.1.2.dylib', + 'foo.os', + ] +elif 'cyglink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'cygfoo-0-1-2.dll', + 'libfoo-0-1-2.dll.a', + 'libfoo.dll.a', + 'foo.os', + ] +elif 'mslink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'foo.dll', + 'foo.lib', + 'foo.obj', + ] +elif 'sunlink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + 'so_foo.os', + ] +else: + # All (?) the files we expect will get created in the current directory + files= [ + 'libfoo.so', + 'foo.os'] + +for f in files: + test.must_not_exist([ f]) + +test.must_exist(['main.c']) +test.must_exist(['foo.c']) +test.must_exist(['SConstruct']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/VersionedLib-subdir.py b/test/LINK/VersionedLib-subdir.py new file mode 100644 index 0000000..a2e141b --- /dev/null +++ b/test/LINK/VersionedLib-subdir.py @@ -0,0 +1,160 @@ +#!/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__" + +""" +Ensure that SharedLibrary builder with SHLIBVERSION='0.1.2' can build its target +in a subdirectory containing .so.0.1.2 in name. + +This is regression test for issue mentioned in: +http://thread.gmane.org/gmane.comp.programming.tools.scons.user/27081 +""" + +import TestSCons +import os +import sys + +import SCons.Platform +import SCons.Defaults + +test = TestSCons.TestSCons() + +test.write('foo.c', """ +#if _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } +""") + +test.write('main.c', """ +#if _WIN32 +__declspec(dllimport) +#endif +int foo(); +int main() +{ + return foo(); +} +""") + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +if 'applelink' in tool_list: + subdir = 'blah.0.1.2.dylib.blah' +elif 'cyglink' in tool_list: + subdir = 'blah-0-1-2.dll.a.blah' +else: + subdir = 'blah.so.0.1.2.blah' + +test.write('SConstruct', """ +env = Environment() +env.AppendUnique(LIBPATH = [ '%s' ]) +env.SharedLibrary('%s/foo', 'foo.c', SHLIBVERSION = '0.1.2') +env.Program('main.c', LIBS=['foo']) +""" % (subdir,subdir)) + +test.run(arguments = ['--tree=all']) + +if platform == 'cygwin' or platform == 'win32': + # PATH is used to search for *.dll libraries on windows + path = os.environ.get('PATH','') + if path: path = path + os.pathsep + path = path + test.workpath(subdir) + os.environ['PATH'] = path + +if os.name == 'posix': + os.environ['LD_LIBRARY_PATH'] = subdir +if sys.platform.find('irix') != -1: + os.environ['LD_LIBRARYN32_PATH'] = subdir + +test.run(program = test.workpath('main')) + +if 'gnulink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + ] + obj = 'foo.os' +elif 'applelink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.dylib', + 'libfoo.0.1.2.dylib', + ] + obj = 'foo.os' +elif 'cyglink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'cygfoo-0-1-2.dll', + 'libfoo-0-1-2.dll.a', + 'libfoo.dll.a', + ] + obj = 'foo.os' +elif 'mslink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'foo.dll', + 'foo.lib', + ] + obj = 'foo.obj' +elif 'sunlink' in tool_list: + # All (?) the files we expect will get created in the current directory + files = [ + 'libfoo.so', + 'libfoo.so.0', + 'libfoo.so.0.1.2', + ] + obj = 'so_foo.os' +else: + # All (?) the files we expect will get created in the current directory + files= [ + 'libfoo.so', + ] + obj = 'foo.os' + +test.must_exist([ obj ]) +for f in files: + test.must_exist([ subdir, f ]) + +test.run(arguments = ['-c']) + +test.must_not_exist([ obj ]) +for f in files: + test.must_not_exist([ subdir, f ]) + +test.must_exist(['foo.c']) +test.must_exist(['SConstruct']) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index a2345d6..3f4a912 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -29,131 +29,253 @@ import sys import TestSCons
import SCons.Platform
+import SCons.Defaults
-_exe = TestSCons._exe
+env = SCons.Defaults.DefaultEnvironment()
+platform = SCons.Platform.platform_default()
+tool_list = SCons.Platform.DefaultToolList(platform, env)
-test = TestSCons.TestSCons()
+if 'gnulink' in tool_list:
+ test_plan = [
+ {
+ 'libversion' : '2',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
+ },
+ ]
+elif 'applelink' in tool_list:
+ # All (?) the files we expect will get created in the current directory
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ],
+ 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ],
+ 'symlinks' : [],
+ },
+ ]
+elif 'cyglink' in tool_list:
+ test_plan = [
+ {
+ 'libversion' : '2',
+ 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ],
+ 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ],
+ 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ],
+ },
+ ]
+elif 'mslink' in tool_list:
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'test.dll', 'test.lib', 'test.obj' ],
+ 'instfiles' : [ 'test.dll', 'test.lib' ],
+ 'symlinks' : [],
+ },
+ ]
+elif 'sunlink' in tool_list:
+ test_plan = [
+ {
+ 'libversion' : '2',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
+ },
+ {
+ 'libversion' : '2.5',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
+ },
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
+ },
+ {
+ 'libversion' : '2.5.4.7.8',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
+ },
+ {
+ 'libversion' : 'aabf114f',
+ 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
+ },
+ {
+ 'libversion' : '2.dfffa11',
+ 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ],
+ 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
+ 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
+ },
+ ]
+else:
+ test_plan = [
+ {
+ 'libversion' : '2.5.4',
+ 'files' : [ 'libtest.so', 'test.os' ],
+ 'instfiles' : [ ],
+ },
+ ]
-test.write('SConstruct', """\
-import os
-env = Environment()
-objs = env.SharedObject('test.c')
-mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '2.5.4')
-env.Program(source=['testapp.c',mylib])
-env.Program(target=['testapp2'],source=['testapp.c','libtest.dylib'])
-instnode = env.InstallVersionedLib("#/installtest",mylib)
-env.Default(instnode)
-""")
+test_c_src = """\
+#if _WIN32
+__declspec(dllexport)
+#endif
+int testlib(int n) { return n+1 ; }
+"""
-test.write('test.c', """\
+test_c_src2 = """\
#if _WIN32
__declspec(dllexport)
#endif
-int testlib(int n)
-{
-return n+1 ;
-}
-""")
+int testlib(int n) { return n+11 ; }
+"""
-test.write('testapp.c', """\
+testapp_c_src = """\
+#if _WIN32
+__declspec(dllimport)
+#endif
+int testlib(int n);
#include <stdio.h>
int main(int argc, char **argv)
{
int itest ;
itest = testlib(2) ;
-printf("results: testlib(2) = %d\n",itest) ;
+printf("results: testlib(2) = %d\\n",itest) ;
return 0 ;
}
-""")
+"""
-platform = SCons.Platform.platform_default()
+for t in test_plan:
+ test = TestSCons.TestSCons()
-test.run()
+ libversion = t['libversion']
+ files = t['files']
+ symlinks = t['symlinks']
+ instfiles = t['instfiles']
-if platform == 'posix':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'libtest.so',
- 'libtest.so.2',
- 'libtest.so.2.5.4',
- ]
-elif platform == 'darwin':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'libtest.dylib',
- 'libtest.2.5.4.dylib',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'libtest.dylib',
- 'libtest.2.5.4.dylib',
- ]
-elif platform == 'cygwin':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'cygtest-2-5-4.dll',
- 'libtest-2-5-4.dll.a',
- 'test.os',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'cygtest-2-5-4.dll',
- 'libtest-2-5-4.dll.a',
- ]
-elif platform == 'win32':
- # All (?) the files we expect will get created in the current directory
- files = [
- 'test.dll',
- 'test.lib',
- 'test.obj',
- ]
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = [
- 'test.dll',
- 'test.lib',
- ]
-else:
- # All (?) the files we expect will get created in the current directory
- files= [
- 'libtest.so',
- 'test.os']
- # All (?) the files we expect will get created in the 'installtest' directory
- instfiles = []
-
-for f in files:
- test.must_exist([ f])
-for f in instfiles:
- test.must_exist(['installtest', f])
-
-# modify test.c and make sure it can recompile when links already exist
-test.write('test.c', """\
-#if _WIN32
-__declspec(dllexport)
-#endif
-int testlib(int n)
-{
-return n+11 ;
-}
-""")
+ test.write('SConstruct', """\
+import os
+env = Environment()
+objs = env.SharedObject('test.c')
+mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s')
+env.Program('testapp1.c', LIBS = mylib, LIBPATH='.')
+env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.')
+instnode = env.InstallVersionedLib("#/installtest",mylib)
+env.Default(instnode)
+
+# Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment
+# Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError.
+instnode = InstallVersionedLib("defaultenv-installtest",mylib)
+Default(instnode)
+
+""" % libversion)
+
+ test.write('test.c', test_c_src)
+ test.write('testapp1.c', testapp_c_src)
+ test.write('testapp2.c', testapp_c_src)
+
+ test.run(arguments = ['--tree=all'])
+
+ for f in files:
+ test.must_exist([ f])
+ for f in instfiles:
+ test.must_exist(['installtest', f])
+ test.must_exist(['defaultenv-installtest', f])
+
+ wrong_symlinks = []
+ for (linkname,expected) in symlinks:
+ try:
+ endpoint = os.readlink(linkname)
+ except OSError, err:
+ print "%s (expected symlink %r -> %r)" % (err, linkname, expected)
+ wrong_symlinks.append(linkname)
+ else:
+ if endpoint != expected:
+ print "Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected)
+ wrong_symlinks.append(linkname)
+
+ if wrong_symlinks:
+ test.fail_test(wrong_symlinks)
+
+ # modify test.c and make sure it can recompile when links already exist
+ test.write('test.c', test_c_src2)
+
+ test.run()
-test.run()
+ test.run(arguments = ['-c'])
-test.run(arguments = '-c')
+ for f in files:
+ test.must_not_exist([ f])
-for f in files:
- test.must_not_exist([ f])
-for f in instfiles:
- test.must_not_exist(['installtest', f])
+ for f in instfiles:
+ test.must_not_exist(['installtest', f])
+ test.must_not_exist(['defaultenv-installtest', f])
test.pass_test()
diff --git a/test/compat/all.py b/test/MSVC/pch-basics.py index ac7a6ea..45735ed 100644 --- a/test/compat/all.py +++ b/test/MSVC/pch-basics.py @@ -21,43 +21,57 @@ # 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__" - + """ -Verify that we can use the any() function (in any supported Python -version we happen to be testing). - -This test can be retired at some point in the distant future when Python -2.5 becomes the minimum version supported by SCons. +Verify PCH works to build a simple exe and a simple dll. """ - + +import time + import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -print all([True, 1]) and "YES" or "NO" -print all([0]) and "YES" or "NO" -SConscript('SConscript') + +test = TestSCons.TestSCons(match = TestSCons.match_re) + +test.skip_if_not_msvc() + +test.write('Main.cpp', """\ +#include "Precompiled.h" + +int main() +{ + return testf(); +} """) - -test.write('SConscript', """\ -print all([1, False]) and "YES" or "NO" -print all([True, None]) and "YES" or "NO" + +test.write('Precompiled.cpp', """\ +#include "Precompiled.h" """) - -expect = """\ -YES -NO -NO -NO -""" - -test.run(arguments = '-Q -q', stdout = expect) - + +test.write('Precompiled.h', """\ +#pragma once + +static int testf() +{ + return 0; +} +""") + +test.write('SConstruct', """\ +env = Environment() + +env['PCHSTOP'] = 'Precompiled.h' +env['PCH'] = env.PCH('Precompiled.cpp')[0] + +env.SharedLibrary('pch_dll', 'Main.cpp') +env.Program('pch_exe', 'Main.cpp') +""") + +test.run(arguments='.', stderr=None) + test.pass_test() - + # Local Variables: # tab-width:4 # indent-tabs-mode:nil diff --git a/test/MSVS/vs-14.0-exec.py b/test/MSVS/vs-14.0-exec.py new file mode 100644 index 0000000..b96bdab --- /dev/null +++ b/test/MSVS/vs-14.0-exec.py @@ -0,0 +1,109 @@ +#!/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 that we can actually build a simple program using our generated +Visual Studio 14.0 project (.vcxproj) and solution (.sln) files +using Visual Studio 14.0 (Professional edition). +""" + +import os +import sys + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() + +if sys.platform != 'win32': + msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +msvs_version = '14.0' + +if not msvs_version in test.msvs_versions(): + msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version + test.skip_test(msg) + + + +# Let SCons figure out the Visual Studio environment variables for us and +# print out a statement that we can exec to suck them into our external +# environment so we can execute devenv and really try to build something. + +test.run(arguments = '-n -q -Q -f -', stdin = """\ +env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') +print "os.environ.update(%%s)" %% repr(env['ENV']) +""" % locals()) + +exec(test.stdout()) + + + +test.subdir('sub dir') + +test.write(['sub dir', 'SConstruct'], """\ +env=Environment(MSVS_VERSION = '%(msvs_version)s') + +env.MSVSProject(target = 'foo.vcxproj', + srcs = ['foo.c'], + buildtarget = 'foo.exe', + variant = 'Release') + +env.Program('foo.c') +""" % locals()) + +test.write(['sub dir', 'foo.c'], r""" +int +main(int argc, char *argv) +{ + printf("foo.c\n"); + exit (0); +} +""") + +test.run(chdir='sub dir', arguments='.') + +test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) + +import SCons.Platform.win32 +system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' ) +os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path + +test.run(chdir='sub dir', + program=[test.get_msvs_executable(msvs_version)], + arguments=['foo.sln', '/build', 'Release']) + +test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0-files.py b/test/MSVS/vs-14.0-files.py new file mode 100644 index 0000000..e4ba8e2 --- /dev/null +++ b/test/MSVS/vs-14.0-files.py @@ -0,0 +1,110 @@ +#!/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 that we can generate Visual Studio 14.0 project (.vcxproj) and +solution (.sln) files that look correct. +""" + +import os + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() +host_arch = test.get_vs_host_arch() + + +# Make the test infrastructure think we have this version of MSVS installed. +test._msvs_versions = ['14.0'] + + + +expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 +expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 +SConscript_contents = TestSConsMSVS.SConscript_contents_14_0 + + + +test.write('SConstruct', SConscript_contents%{'HOST_ARCH': host_arch}) + +test.run(arguments="Test.vcxproj") + +test.must_exist(test.workpath('Test.vcxproj')) +test.must_exist(test.workpath('Test.vcxproj.filters')) +vcxproj = test.read('Test.vcxproj', 'r') +expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct') +# don't compare the pickled data +assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) + +test.must_exist(test.workpath('Test.sln')) +sln = test.read('Test.sln', 'r') +expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct') +# don't compare the pickled data +assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + +test.run(arguments='-c .') + +test.must_not_exist(test.workpath('Test.vcxproj')) +test.must_not_exist(test.workpath('Test.vcxproj.filters')) +test.must_not_exist(test.workpath('Test.sln')) + +test.run(arguments='Test.vcxproj') + +test.must_exist(test.workpath('Test.vcxproj')) +test.must_exist(test.workpath('Test.vcxproj.filters')) +test.must_exist(test.workpath('Test.sln')) + +test.run(arguments='-c Test.sln') + +test.must_not_exist(test.workpath('Test.vcxproj')) +test.must_not_exist(test.workpath('Test.vcxproj.filters')) +test.must_not_exist(test.workpath('Test.sln')) + + + +# Test that running SCons with $PYTHON_ROOT in the environment +# changes the .vcxproj output as expected. +os.environ['PYTHON_ROOT'] = 'xyzzy' +python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1]) + +test.run(arguments='Test.vcxproj') + +test.must_exist(test.workpath('Test.vcxproj')) +vcxproj = test.read('Test.vcxproj', 'r') +expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', + python=python) +# don't compare the pickled data +assert vcxproj[:len(expect)] == expect, test.diff_substr(expect, vcxproj) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0-scc-files.py b/test/MSVS/vs-14.0-scc-files.py new file mode 100644 index 0000000..c934ac9 --- /dev/null +++ b/test/MSVS/vs-14.0-scc-files.py @@ -0,0 +1,115 @@ +#!/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 that we can generate Visual Studio 14.0 project (.vcxproj) and +solution (.sln) files that contain SCC information and look correct. +""" + +import os + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() + +# Make the test infrastructure think we have this version of MSVS installed. +test._msvs_versions = ['14.0'] + + + +expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 +expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 +SConscript_contents = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', + CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], + CPPPATH=['inc1', 'inc2'], + MSVS_SCC_CONNECTION_ROOT='.', + MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM', + MSVS_SCC_PROJECT_NAME='Perforce Project') + +testsrc = ['test1.cpp', 'test2.cpp'] +testincs = ['sdk_dir\sdk.h'] +testlocalincs = ['test.h'] +testresources = ['test.rc'] +testmisc = ['readme.txt'] + +env.MSVSProject(target = 'Test.vcxproj', + srcs = testsrc, + incs = testincs, + localincs = testlocalincs, + resources = testresources, + misc = testmisc, + buildtarget = 'Test.exe', + variant = 'Release') +""" + +expected_sln_sccinfo = """\ +\tGlobalSection(SourceCodeControl) = preSolution +\t\tSccNumberOfProjects = 2 +\t\tSccProjectName0 = Perforce\u0020Project +\t\tSccLocalPath0 = . +\t\tSccProvider0 = MSSCCI:Perforce\u0020SCM +\t\tCanCheckoutShared = true +\t\tSccProjectUniqueName1 = Test.vcxproj +\t\tSccLocalPath1 = . +\t\tCanCheckoutShared = true +\t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\ +\tEndGlobalSection +""" + +expected_vcproj_sccinfo = """\ +\t\t<SccProjectName>Perforce Project</SccProjectName> +\t\t<SccLocalPath>.</SccLocalPath> +\t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider> +""" + + +test.write('SConstruct', SConscript_contents) + +test.run(arguments="Test.vcxproj") + +test.must_exist(test.workpath('Test.vcxproj')) +vcproj = test.read('Test.vcxproj', 'r') +expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', + vcproj_sccinfo=expected_vcproj_sccinfo) +# don't compare the pickled data +assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + +test.must_exist(test.workpath('Test.sln')) +sln = test.read('Test.sln', 'r') +expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct', + sln_sccinfo=expected_sln_sccinfo) +# don't compare the pickled data +assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0-scc-legacy-files.py b/test/MSVS/vs-14.0-scc-legacy-files.py new file mode 100644 index 0000000..ba6ebad --- /dev/null +++ b/test/MSVS/vs-14.0-scc-legacy-files.py @@ -0,0 +1,98 @@ +#!/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 that we can generate Visual Studio 14.0 project (.vcxproj) and +solution (.sln) files that contain SCC information and look correct. +""" + +import os + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() + +# Make the test infrastructure think we have this version of MSVS installed. +test._msvs_versions = ['14.0'] + + + +expected_slnfile = TestSConsMSVS.expected_slnfile_14_0 +expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_14_0 +SConscript_contents = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', + CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], + CPPPATH=['inc1', 'inc2'], + MSVS_SCC_LOCAL_PATH='C:\\MyMsVsProjects', + MSVS_SCC_PROJECT_NAME='Perforce Project') + +testsrc = ['test1.cpp', 'test2.cpp'] +testincs = ['sdk_dir\sdk.h'] +testlocalincs = ['test.h'] +testresources = ['test.rc'] +testmisc = ['readme.txt'] + +env.MSVSProject(target = 'Test.vcxproj', + srcs = testsrc, + incs = testincs, + localincs = testlocalincs, + resources = testresources, + misc = testmisc, + buildtarget = 'Test.exe', + variant = 'Release') +""" + +expected_vcproj_sccinfo = """\ +\t\t<SccProjectName>Perforce Project</SccProjectName> +\t\t<SccLocalPath>C:\\MyMsVsProjects</SccLocalPath> +""" + + +test.write('SConstruct', SConscript_contents) + +test.run(arguments="Test.vcxproj") + +test.must_exist(test.workpath('Test.vcxproj')) +vcproj = test.read('Test.vcxproj', 'r') +expect = test.msvs_substitute(expected_vcprojfile, '14.0', None, 'SConstruct', + vcproj_sccinfo=expected_vcproj_sccinfo) +# don't compare the pickled data +assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + +test.must_exist(test.workpath('Test.sln')) +sln = test.read('Test.sln', 'r') +expect = test.msvs_substitute(expected_slnfile, '14.0', None, 'SConstruct') +# don't compare the pickled data +assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVS/vs-14.0Exp-exec.py b/test/MSVS/vs-14.0Exp-exec.py new file mode 100644 index 0000000..44ebece --- /dev/null +++ b/test/MSVS/vs-14.0Exp-exec.py @@ -0,0 +1,109 @@ +#!/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 that we can actually build a simple program using our generated +Visual Studio 14.0 project (.vcxproj) and solution (.sln) files +using Visual C++ 14.0 Express edition. +""" + +import os +import sys + +import TestSConsMSVS + +test = TestSConsMSVS.TestSConsMSVS() + +if sys.platform != 'win32': + msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform + test.skip_test(msg) + +msvs_version = '14.0Exp' + +if not msvs_version in test.msvs_versions(): + msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version + test.skip_test(msg) + + + +# Let SCons figure out the Visual Studio environment variables for us and +# print out a statement that we can exec to suck them into our external +# environment so we can execute devenv and really try to build something. + +test.run(arguments = '-n -q -Q -f -', stdin = """\ +env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') +print "os.environ.update(%%s)" %% repr(env['ENV']) +""" % locals()) + +exec(test.stdout()) + + + +test.subdir('sub dir') + +test.write(['sub dir', 'SConstruct'], """\ +env=Environment(MSVS_VERSION = '%(msvs_version)s') + +env.MSVSProject(target = 'foo.vcxproj', + srcs = ['foo.c'], + buildtarget = 'foo.exe', + variant = 'Release') + +env.Program('foo.c') +""" % locals()) + +test.write(['sub dir', 'foo.c'], r""" +int +main(int argc, char *argv) +{ + printf("foo.c\n"); + exit (0); +} +""") + +test.run(chdir='sub dir', arguments='.') + +test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) + +import SCons.Platform.win32 +system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' ) +os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path + +test.run(chdir='sub dir', + program=[test.get_msvs_executable(msvs_version)], + arguments=['foo.sln', '/build', 'Release']) + +test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/NoClean.py b/test/NoClean.py index 01fe209..63e3e28 100644 --- a/test/NoClean.py +++ b/test/NoClean.py @@ -34,14 +34,14 @@ test = TestSCons.TestSCons() test.write('SConstruct', """
def action(target, source, env):
- for t in target: open(t.path, 'w')
+ for t in target: open(t.get_internal_path(), 'w')
Command('1.out', 'SConstruct', action)
NoClean('1.out')
""")
test.write('SConstruct.force', """
def action(target, source, env):
- for t in target: open(t.path, 'w')
+ for t in target: open(t.get_internal_path(), 'w')
open('4.out', 'w')
res = Command('3.out', 'SConstruct.force', action)
Clean('4.out', res)
@@ -50,7 +50,7 @@ NoClean('4.out') test.write('SConstruct.multi', """
def action(target, source, env):
- for t in target: open(t.path, 'w')
+ for t in target: open(t.get_internal_path(), 'w')
Command(['5.out', '6.out'], 'SConstruct.multi', action)
NoClean('6.out')
""")
diff --git a/test/QT/manual.py b/test/QT/manual.py index ff38f32..d911fb3 100644 --- a/test/QT/manual.py +++ b/test/QT/manual.py @@ -46,13 +46,15 @@ sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp'] # normal invocation sources.append(env.Moc('include/aaa.h')) -env.Moc('bbb.cpp') +moc = env.Moc('bbb.cpp') +env.Ignore( moc, moc ) sources.extend(env.Uic('ui/ccc.ui')[1:]) # manual target specification sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', QT_MOCHPREFIX='')) # Watch out ! -env.Moc('moc_eee.cpp', 'eee.cpp') +moc = env.Moc('moc_eee.cpp', 'eee.cpp') +env.Ignore( moc, moc ) sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], 'ui/fff.ui')[1:]) diff --git a/test/RANLIB/RANLIB.py b/test/RANLIB/RANLIB.py index c9fc10f..fbfe36c 100644 --- a/test/RANLIB/RANLIB.py +++ b/test/RANLIB/RANLIB.py @@ -81,6 +81,10 @@ library_function(void) test.write('main.c', r""" #include <stdlib.h> + +void +library_function(void); + int main(int argc, char *argv[]) { diff --git a/test/RANLIB/RANLIBFLAGS.py b/test/RANLIB/RANLIBFLAGS.py index 636059b..86e5283 100644 --- a/test/RANLIB/RANLIBFLAGS.py +++ b/test/RANLIB/RANLIBFLAGS.py @@ -82,6 +82,10 @@ library_function(void) test.write('main.c', r""" #include <stdlib.h> +void +library_function(void); + + int main(int argc, char *argv[]) { diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index 96e00e7..d53fa49 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -43,10 +43,20 @@ if not python: test.write('myswig.py', r""" import getopt import sys -opts, args = getopt.getopt(sys.argv[1:], 'c:o:') +opts, args = getopt.getopt(sys.argv[1:], 'c:o:v:') for opt, arg in opts: if opt == '-c': pass elif opt == '-o': out = arg + elif opt == '-v' and arg == 'ersion': + print "" + print "SWIG Version 0.1.2" + print "" + print "Compiled with g++ [x86_64-pc-linux-gnu]" + print "" + print "Configured options: +pcre" + print "" + print "Please see http://www.swig.org for reporting bugs and further information" + sys.exit(0) infile = open(args[0], 'rb') outfile = open(out, 'wb') for l in infile.readlines(): @@ -58,6 +68,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'swig'], SWIG = [r'%(python)s', 'myswig.py']) +print env.subst("Using SWIG $SWIGVERSION") env.Program(target = 'test1', source = 'test1.i') env.CFile(target = 'test2', source = 'test2.i') env.Clone(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') @@ -91,7 +102,7 @@ main(int argc, char *argv[]) { swig """) -test.run(arguments = '.', stderr = None) +test.run(arguments = '.', stderr = None, stdout = r'.*Using SWIG 0.1.2.*', match = TestSCons.match_re_dotall) test.run(program = test.workpath('test1' + _exe), stdout = "test1.i\n") test.must_exist(test.workpath('test1_wrap.c')) diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py new file mode 100644 index 0000000..364bd73 --- /dev/null +++ b/test/SWIG/recursive-includes-cpp.py @@ -0,0 +1,123 @@ +#!/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__" + +""" +Verify that SWIG include directives produce the correct dependencies +in cases of recursive inclusion. +""" + +import os +import TestSCons +from SCons.Defaults import DefaultEnvironment + +DefaultEnvironment( tools = [ 'swig' ] ) + +test = TestSCons.TestSCons() + +# Check for prerequisites of this test. +for pre_req in ['swig', 'python']: + if not test.where_is(pre_req): + test.skip_test('Can not find installed "' + pre_req + '", skipping test.%s' % os.linesep) + +test.write("recursive.h", """\ +/* An empty header file. */ +""") + +test.write("main.h", """\ +#include "recursive.h" +""") + +test.write("main.c", """\ +#include "main.h" +""") + +test.write("mod.i", """\ +%module mod + +%include "main.h" + +#include "main.h" +""") + +test.write('SConstruct', """\ +import distutils.sysconfig + +DefaultEnvironment( tools = [ 'swig' ] ) + +env = Environment( + SWIGFLAGS = [ + '-python' + ], + CPPPATH = [ + distutils.sysconfig.get_python_inc() + ], + SHLIBPREFIX = "" +) + +env.SharedLibrary( + 'mod.so', + [ + "mod.i", + "main.c", + ] +) +""") + +expectMain = """\ ++-main.os + +-main.c + +-main.h + +-recursive.h""" + +expectMod = """\ ++-mod_wrap.os + +-mod_wrap.c + | +-mod.i + | +-main.h + | +-recursive.h""" + +# Validate that the recursive dependencies are found with SWIG scanning first. +test.run( arguments = '--tree=all mod_wrap.os main.os' ) + +test.must_contain_all( test.stdout(), expectMain ) +test.must_contain_all( test.stdout(), expectMod ) + +# Validate that the recursive dependencies are found consistently. +test.run( arguments = '--tree=all main.os mod_wrap.os' ) + +test.must_contain_all( test.stdout(), expectMain ) +test.must_contain_all( test.stdout(), expectMod ) + +test.run() +test.up_to_date() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Scanner/CrossLanguageNoExtension.py b/test/Scanner/CrossLanguageNoExtension.py new file mode 100644 index 0000000..5bf205f --- /dev/null +++ b/test/Scanner/CrossLanguageNoExtension.py @@ -0,0 +1,110 @@ +#!/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__" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +# Test behavior of Scanners when evaluating implicit dependencies +# for nodes that do not have mappings from their scanner_key +# to a scanner instance + +test.write('SConstruct', """ +import re + +include_re = re.compile(r'^include\s+(\S+)$', re.M) + +def scan(node, env, scanpaths, arg): + contents = node.get_text_contents() + includes = include_re.findall(contents) + return includes + +def kfile_scan(node, env, scanpaths, arg): + print 'kscan: ' + str(node) + return scan(node, env, scanpaths, arg) + +def k2file_scan(node, env, scanpaths, arg): + print 'k2scan: ' + str(node) + return scan(node, env, scanpaths, arg) + +kscan = Scanner(name = 'kfile', + function = kfile_scan, + argument = None, + skeys = ['.k'], + recursive = True) + +k2scan = Scanner(name = 'k2', + function = k2file_scan, + argument = None, + skeys = ['.k2']) + +k2scan2 = Scanner(name = 'k2', + function = k2file_scan, + argument = None, + skeys = ['']) + +env1 = Environment() +env1.Append(SCANNERS = [ kscan, k2scan ] ) +env1.Command( 'k', 'foo.k', Copy( '$TARGET', '$SOURCE' ) ) + +env2 = env1.Clone() +env2.Append(SCANNERS = [ k2scan2 ] ) +env2.Command( 'k2', 'foo.k', Copy( '$TARGET', '$SOURCE' ) ) +""") + +test.write('foo.k', +"""foo.k 1 line 1 +include xxx.k +include yyy +foo.k 1 line 4 +""") + +test.write('xxx.k', "xxx.k 1\n") +test.write('yyy', "yyy 1\n") +test.write('yyy.k2', "yyy.k2 1\n") + +expected_stdout = test.wrap_stdout("""\ +kscan: foo.k +kscan: xxx.k +kscan: yyy +Copy("k", "foo.k") +kscan: foo.k +kscan: xxx.k +k2scan: yyy +Copy("k2", "foo.k") +""") + +test.run(arguments='k k2', stdout=expected_stdout) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Scanner/exception.py b/test/Scanner/exception.py index 5af7ac3..1a14152 100644 --- a/test/Scanner/exception.py +++ b/test/Scanner/exception.py @@ -79,7 +79,6 @@ env.Cat('foo', 'foo.k') bar_in = File('bar.in') env.Cat('bar', bar_in) -bar_in.source_scanner = kscan """) test.write('foo.k', diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index 82206c2..7246cbe 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -338,6 +338,7 @@ class CScannerCounter(object): import SCons.Tool MyCScanner = CScannerCounter(SCons.Script.CScanner) SCons.Tool.SourceFileScanner.add_scanner('.c', MyCScanner) +SCons.Tool.SourceFileScanner.add_scanner('.h', MyCScanner) env = Environment(CPPPATH = ".") l = env.StaticLibrary("g", Split("libg_1.c libg_2.c libg_3.c")) diff --git a/test/Script-import.py b/test/Script-import.py index 98ae271..504de0e 100644 --- a/test/Script-import.py +++ b/test/Script-import.py @@ -62,7 +62,6 @@ SCons.Script.CleanTask SCons.Script.QuestionTask old_SCons_Script_variables = [ - 'PrintHelp', 'OptParser', 'keep_going_on_error', 'print_explanations', diff --git a/test/TEX/bibliography.py b/test/TEX/bibliography.py index 5e26f6e..c26b010 100644 --- a/test/TEX/bibliography.py +++ b/test/TEX/bibliography.py @@ -118,9 +118,6 @@ test.must_not_exist(test.workpath('simple.blg')) test.pass_test() - -# FUTURE: - test.write('SConstruct', """\ env = Environment(tools = ['tex', 'latex', 'dvips']) env.PostScript('d00', 'd00.tex') diff --git a/test/TEX/variant_dir_newglossary.py b/test/TEX/variant_dir_newglossary.py index 8604270..5a28ed4 100644 --- a/test/TEX/variant_dir_newglossary.py +++ b/test/TEX/variant_dir_newglossary.py @@ -25,7 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Validate the use of \newglossary in TeX source files in conjuction +Validate the use of \newglossary in TeX source files in conjunction with variant_dir. Test configuration contributed by Kendrick Boyd. diff --git a/test/explain/basic.py b/test/explain/basic.py index 5e31cfd..1072ac4 100644 --- a/test/explain/basic.py +++ b/test/explain/basic.py @@ -169,10 +169,18 @@ test.write(['src', 'file6.in'], "file6.in 1\n") test.write(['src', 'subdir', 'file7.in'], "subdir/file7.in 1\n") -args = '--debug=explain .' +args = '--debug=explain ..' expect = test.wrap_stdout("""\ +scons: building `%(inc_aaa)s' because it doesn't exist +Install file: "aaa" as "%(inc_aaa)s" +scons: building `%(inc_bbb_k)s' because it doesn't exist +Install file: "bbb.k" as "%(inc_bbb_k)s" +scons: building `%(inc_ddd)s' because it doesn't exist +Install file: "ddd" as "%(inc_ddd)s" +scons: building `%(inc_eee)s' because it doesn't exist +Install file: "eee.in" as "%(inc_eee)s" scons: building `file1' because it doesn't exist %(_python_)s %(cat_py)s file1 file1.in scons: building `file2' because it doesn't exist @@ -181,14 +189,6 @@ scons: building `file3' because it doesn't exist %(_python_)s %(cat_py)s file3 xxx yyy zzz scons: building `file4' because it doesn't exist %(_python_)s %(cat_py)s file4 - file4.in -scons: building `%(inc_aaa)s' because it doesn't exist -Install file: "aaa" as "%(inc_aaa)s" -scons: building `%(inc_ddd)s' because it doesn't exist -Install file: "ddd" as "%(inc_ddd)s" -scons: building `%(inc_eee)s' because it doesn't exist -Install file: "eee.in" as "%(inc_eee)s" -scons: building `%(inc_bbb_k)s' because it doesn't exist -Install file: "bbb.k" as "%(inc_bbb_k)s" scons: building `file5' because it doesn't exist %(_python_)s %(cat_py)s file5 file5.k scons: building `file6' because it doesn't exist @@ -236,6 +236,8 @@ test_value = '"second"' WriteInitialTest( locals() ) expect = test.wrap_stdout("""\ +scons: rebuilding `%(inc_bbb_k)s' because `bbb.k' changed +Install file: "bbb.k" as "%(inc_bbb_k)s" scons: rebuilding `file1' because `file1.in' changed %(_python_)s %(cat_py)s file1 file1.in scons: rebuilding `file2' because `yyy' changed @@ -244,11 +246,6 @@ scons: rebuilding `file3' because: `yyy' changed `zzz' changed %(_python_)s %(cat_py)s file3 xxx yyy zzz -scons: rebuilding `%(inc_bbb_k)s' because: - `%(inc_ddd)s' is no longer a dependency - `%(inc_eee)s' is no longer a dependency - `bbb.k' changed -Install file: "bbb.k" as "%(inc_bbb_k)s" scons: rebuilding `file5' because `%(inc_bbb_k)s' changed %(_python_)s %(cat_py)s file5 file5.k scons: rebuilding `file6' because AlwaysBuild() is specified diff --git a/test/explain/function-actions.py b/test/explain/function-actions.py index e5f9ba8..bd3ad01 100644 --- a/test/explain/function-actions.py +++ b/test/explain/function-actions.py @@ -59,8 +59,8 @@ if mode: else: MyCopy = Builder(action = Copy('$TARGET', '$SOURCE')) def ChangingCopy(target, source, env): - tgt = str(target[0].abspath) - src = str(source[0].abspath) + tgt = str(target[0].get_abspath()) + src = str(source[0].get_abspath()) shutil.copy(src, tgt) ChangingCopy = Builder(action = ChangingCopy) diff --git a/test/explain/save-info.py b/test/explain/save-info.py index d2ffc7d..af4c3f5 100644 --- a/test/explain/save-info.py +++ b/test/explain/save-info.py @@ -141,7 +141,7 @@ file5.k 1 line 4 test.write(['src', 'subdir', 'file6.in'], "subdir/file6.in 1\n") # -test.run(chdir='src', arguments='.') +test.run(chdir='src', arguments='..') test.must_match(['src', 'file1'], "file1.in 1\n") test.must_match(['src', 'file2'], """\ @@ -176,10 +176,7 @@ scons: rebuilding `file3' because: `yyy' changed `zzz' changed %(_python_)s %(cat_py)s file3 xxx yyy zzz -scons: rebuilding `%(inc_bbb_k)s' because: - `%(inc_ddd)s' is no longer a dependency - `%(inc_eee)s' is no longer a dependency - `bbb.k' changed +scons: rebuilding `%(inc_bbb_k)s' because `bbb.k' changed Install file: "bbb.k" as "%(inc_bbb_k)s" scons: rebuilding `file5' because `%(inc_bbb_k)s' changed %(_python_)s %(cat_py)s file5 file5.k diff --git a/test/implicit-cache/DualTargets.py b/test/implicit-cache/DualTargets.py index f0694b1..45174ea 100644 --- a/test/implicit-cache/DualTargets.py +++ b/test/implicit-cache/DualTargets.py @@ -37,14 +37,14 @@ test.write('SConstruct', """\ import os.path def emitter(target, source, env): - tgt0 = target[0].abspath + tgt0 = target[0].get_abspath() base,ext = os.path.splitext(tgt0) target.append(base + '.b') return(target, source) def source_scan(node, env, path): - path = node.abspath + path = node.get_abspath() base,ext = os.path.splitext(path) return [base + '.lib'] diff --git a/test/option-j.py b/test/option-j.py index 3eb7bd3..69ef414 100644 --- a/test/option-j.py +++ b/test/option-j.py @@ -30,9 +30,11 @@ SConscript settable option. __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path +import sys import TestSCons + _python_ = TestSCons._python_ try: @@ -120,42 +122,41 @@ test.fail_test(start2 < finish1) # succeeds. test.run(arguments='-j 2 out') +if sys.platform != 'win32': + # Test breaks on win32 when using real subprocess is not the only + # package to import threading + # + # Test that we fall back and warn properly if there's no threading.py + # module (simulated), which is the case if this version of Python wasn't + # built with threading support. -# Test that we fall back and warn properly if there's no threading.py -# module (simulated), which is the case if this version of Python wasn't -# built with threading support. + test.subdir('pythonlib') -test.subdir('pythonlib') + test.write(['pythonlib', 'threading.py'], "raise ImportError\n") -test.write(['pythonlib', 'threading.py'], """\ -raise ImportError -""") + save_pythonpath = os.environ.get('PYTHONPATH', '') + os.environ['PYTHONPATH'] = test.workpath('pythonlib') -save_pythonpath = os.environ.get('PYTHONPATH', '') -os.environ['PYTHONPATH'] = test.workpath('pythonlib') + #start2, finish1 = RunTest('-j 2 f1, f2', "fifth") -#start2, finish1 = RunTest('-j 2 f1, f2', "fifth") + test.write('f1.in', 'f1.in pythonlib\n') + test.write('f2.in', 'f2.in pythonlib\n') -test.write('f1.in', 'f1.in pythonlib\n') -test.write('f2.in', 'f2.in pythonlib\n') + test.run(arguments = "-j 2 f1 f2", stderr=None) -test.run(arguments = "-j 2 f1 f2", stderr=None) - -warn = \ -"""scons: warning: parallel builds are unsupported by this version of Python; -\tignoring -j or num_jobs option. -""" -test.must_contain_all_lines(test.stderr(), [warn]) + warn = """scons: warning: parallel builds are unsupported by this version of Python; +\tignoring -j or num_jobs option.""" + test.must_contain_all_lines(test.stderr(), [warn]) -str = test.read("f1") -start1,finish1 = list(map(float, str.split("\n"))) + str = test.read("f1") + start1,finish1 = list(map(float, str.split("\n"))) -str = test.read("f2") -start2,finish2 = list(map(float, str.split("\n"))) + str = test.read("f2") + start2,finish2 = list(map(float, str.split("\n"))) -test.fail_test(start2 < finish1) + test.fail_test(start2 < finish1) -os.environ['PYTHONPATH'] = save_pythonpath + os.environ['PYTHONPATH'] = save_pythonpath # Test SetJobs() with no -j: diff --git a/test/option/debug-count.py b/test/option/debug-count.py index ce79086..b82a434 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -29,6 +29,7 @@ Test that the --debug=count option works. """ import re +import sys import TestSCons @@ -86,11 +87,13 @@ scons: warning: --debug=count is not supported when running SCons \twith the python -O option or optimized \\(.pyo\\) modules. """ + TestSCons.file_expr -test.run(arguments = '--debug=count -h', - interpreter = ['python', '-O'], - stderr = expect_warning, - match = TestSCons.match_re) - +test.run( + arguments = '--debug=count -h', + # Test against current interpreter vs default path option. + interpreter = [ sys.executable, '-O' ], + stderr = expect_warning, + match = TestSCons.match_re +) test.pass_test() diff --git a/test/option/md5-chunksize.py b/test/option/md5-chunksize.py index 375208d..dbb2615 100644 --- a/test/option/md5-chunksize.py +++ b/test/option/md5-chunksize.py @@ -104,8 +104,8 @@ get_stat(["test.stat"], ["test.big"]) test2.write('SConstruct', """ import os def get_stat(target, source, env): - stat = os.stat(source[0].abspath) - dest = open(target[0].abspath,'w') + stat = os.stat(source[0].get_abspath()) + dest = open(target[0].get_abspath(),'w') dest.write(str(stat)) dest.close() env = Environment() diff --git a/test/option/profile.py b/test/option/profile.py index f408136..93dad91 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -26,19 +26,14 @@ from SCons.compat.six import u __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys -try: - import io - _StringIO = io.StringIO -except (ImportError, AttributeError): - # Pre-2.6 Python has no "io" module. - exec('from cStringIO import StringIO') -else: - # TODO(2.6): In 2.6 and beyond, the io.StringIO.write() method - # requires unicode strings. This subclass can probably be removed - # when we drop support for Python 2.6. - class StringIO(_StringIO): - def write(self, s): - _StringIO.write(self, u(s)) +import io +_StringIO = io.StringIO +# TODO(2.6): In 2.6 and beyond, the io.StringIO.write() method +# requires unicode strings. This subclass can probably be removed +# when we drop support for Python 2.6. +class StringIO(_StringIO): + def write(self, s): + _StringIO.write(self, unicode(s)) import TestSCons diff --git a/test/option/tree-lib.py b/test/option/tree-lib.py index 2721344..2dc5fb0 100644 --- a/test/option/tree-lib.py +++ b/test/option/tree-lib.py @@ -52,7 +52,7 @@ test.write('main.c', """\ #include <stdlib.h> #include <stdio.h> int -main(int argc, char *argv) +main(int argc, char **argv) { printf("#define FOO_H \\"foo.h\\"\\n"); return (0); diff --git a/test/packaging/guess-package-name.py b/test/packaging/guess-package-name.py index 9c85b9a..33c3329 100644 --- a/test/packaging/guess-package-name.py +++ b/test/packaging/guess-package-name.py @@ -86,7 +86,7 @@ test.run(stderr = None) test.must_exist( 'src.tar.gz' ) # -# TEST: default package name creation with overriden packager. +# TEST: default package name creation with overridden packager. # test.write('SConstruct', """ diff --git a/test/packaging/msi/explicit-target.py b/test/packaging/msi/explicit-target.py index bc786ee..85bfa85 100644 --- a/test/packaging/msi/explicit-target.py +++ b/test/packaging/msi/explicit-target.py @@ -26,7 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test the ability to use a explicit target package name and the use -of FindInstalledFiles() in conjuction with .msi packages. +of FindInstalledFiles() in conjunction with .msi packages. """ import TestSCons diff --git a/test/sconsign/script/Configure.py b/test/sconsign/script/Configure.py index 3b43def..679f084 100644 --- a/test/sconsign/script/Configure.py +++ b/test/sconsign/script/Configure.py @@ -58,9 +58,8 @@ CC_file = re.escape(CC_file) _sconf_temp_conftest_0_c = '.sconf_temp/conftest_0.c' test.write('SConstruct', """ -env = Environment() import os -env.AppendENVPath('PATH', os.environ['PATH']) +env = Environment(ENV={'PATH' : os.environ.get('PATH','')}) conf = Configure(env) r1 = conf.CheckCHeader( 'math.h' ) env = conf.Finish() diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 71a7e6d..dc45cc1 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -173,33 +173,33 @@ inc2.h: %(sig_re)s \d+ \d+ test.run_sconsign(arguments = "--raw .sconsign", stdout = r"""=== .: -SConstruct: {'csig': None, 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +SConstruct: {'csig': None, 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} === sub1: -hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] === sub2: -hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} """ % locals()) expect = r"""=== .: diff --git a/test/sconsign/script/bad.py b/test/sconsign/script/bad.py index fc21577..a384748 100644 --- a/test/sconsign/script/bad.py +++ b/test/sconsign/script/bad.py @@ -47,16 +47,16 @@ test.run_sconsign(arguments = "-f dblite bad1.dblite", stderr = "sconsign: \[Errno 2\] No such file or directory: 'bad1.dblite'\n") test.run_sconsign(arguments = "-f dblite bad2", - stderr = "sconsign: ignoring invalid `dblite' file `bad2'\n") + stderr = "sconsign: ignoring invalid `dblite' file `bad2'.*\n") test.run_sconsign(arguments = "-f dblite bad2.dblite", - stderr = "sconsign: ignoring invalid `dblite' file `bad2.dblite'\n") + stderr = "sconsign: ignoring invalid `dblite' file `bad2.dblite'.*\n") test.run_sconsign(arguments = "-f sconsign no_sconsign", stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n") test.run_sconsign(arguments = "-f sconsign bad3", - stderr = "sconsign: ignoring invalid .sconsign file `bad3'\n") + stderr = "sconsign: ignoring invalid .sconsign file `bad3'.*\n") test.pass_test() diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 70b18c8..4e9915b 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -159,14 +159,14 @@ hello.obj: %(sig_re)s \d+ \d+ test.run_sconsign(arguments = "sub1/.sconsign", stdout=expect) test.run_sconsign(arguments = "--raw sub1/.sconsign", - stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} -hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} + stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} +hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] -hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} - fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 1} +hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} + fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} %(sig_re)s \[.*\] """ % locals()) diff --git a/test/site_scons/override.py b/test/site_scons/override.py index ad03eae..e33bb88 100644 --- a/test/site_scons/override.py +++ b/test/site_scons/override.py @@ -48,7 +48,7 @@ def exists(env): """) test.write('SConstruct', """ -e=Environment() +e=Environment(tools=['m4']) print e.subst('M4 is $M4, M4_MINE is $M4_MINE') """) test.run(arguments = '-Q .', diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index 87f448d..663700b 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -21,7 +21,6 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -40,7 +39,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ import SCons.Script -SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').path) +SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').get_internal_path()) """) test.run(arguments = '-Q .') @@ -55,10 +54,10 @@ else: dir_to_check_for='.scons' if 'Loading site dir' not in test.stdout(): - print(test.stdout()) + print test.stdout() test.fail_test() if dir_to_check_for not in test.stdout(): - print(test.stdout()) + print test.stdout() test.fail_test() test.pass_test() diff --git a/test/update-release-info/update-release-info.py b/test/update-release-info/update-release-info.py index e44aa99..970bcce 100644 --- a/test/update-release-info/update-release-info.py +++ b/test/update-release-info/update-release-info.py @@ -60,10 +60,10 @@ combo_strings = [ """version_tuple = (2, 0, 0, 'bad', 0) """, # Index 1: Python version tuple -"""unsupported_python_version = (2, 3) +"""unsupported_python_version = (2, 6) """, # Index 2: Python version tuple -"""deprecated_python_version = (2, 4) +"""deprecated_python_version = (2, 7) """, # Index 3: alpha version tuple """version_tuple = (2, 0, 0, 'alpha', 0) @@ -223,14 +223,14 @@ These files are a part of 33.22.11: test.must_match(TestSCons, """ copyright_years = '%s' default_version = '2.0.0.alpha.yyyymmdd' -python_version_unsupported = (2, 3) -python_version_deprecated = (2, 4) +python_version_unsupported = (2, 6) +python_version_deprecated = (2, 7) """%years, mode = 'r') # should get Python floors from TestSCons module. test.must_match(Main, """ -unsupported_python_version = (2, 3) -deprecated_python_version = (2, 4) +unsupported_python_version = (2, 6) +deprecated_python_version = (2, 7) """, mode = 'r') #TODO: Release option |