Beispiel #1
0
import TestSCons

_exe = TestSCons._exe

test = TestSCons.TestSCons()

test.write('SConscript', """
BuildDir('build', 'src')
""")

msg = """BuildDir() and the build_dir keyword have been deprecated;
\tuse VariantDir() and the variant_dir keyword instead."""
test.deprecated_warning('deprecated-build-dir', msg)

warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \
                               + '\n' + TestSCons.file_expr

foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe)
foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe)
foo21 = test.workpath('work1', 'build', 'var2', 'foo1' + _exe)
foo22 = test.workpath('work1', 'build', 'var2', 'foo2' + _exe)
foo31 = test.workpath('work1', 'build', 'var3', 'foo1' + _exe)
foo32 = test.workpath('work1', 'build', 'var3', 'foo2' + _exe)
foo41 = test.workpath('work1', 'build', 'var4', 'foo1' + _exe)
foo42 = test.workpath('work1', 'build', 'var4', 'foo2' + _exe)
foo51 = test.workpath('build', 'var5', 'foo1' + _exe)
foo52 = test.workpath('build', 'var5', 'foo2' + _exe)

test.subdir('work1')
Beispiel #2
0
os.environ['SCONSFLAGS'] = '-h'

test.run(stdout = expect,
         stderr = TestSCons.deprecated_python_expr)

# No TestSCons.deprecated_python_expr because the -H option gets
# processed before the SConscript files and therefore before we check
# for the deprecation warning.
test.run(arguments = "-H")

test.must_not_contain_any_line(test.stdout(), ['Help text.'])
test.must_contain_all_lines(test.stdout(), ['-H, --help-options'])

os.environ['SCONSFLAGS'] = '-Z'

expect = r"""usage: scons [OPTION] [TARGET] ...

SCons error: no such option: -Z
"""

test.run(arguments = "-H", status = 2,
         stderr = TestSCons.re_escape(expect))

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
Beispiel #3
0
import os
import re

import TestCmd
import TestSCons

test = TestSCons.TestSCons(match = TestCmd.match_re_dotall,ignore_python_version=0)

test.write('SConstruct', "\n")

test.write('SetOption-deprecated', "SetOption('warn', 'no-deprecated')\n")

test.write('SetOption-python', "SetOption('warn', ['no-python-version'])\n")

if TestSCons.unsupported_python_version():

    error = "scons: \*\*\* SCons version \S+ does not run under Python version %s."
    error = error % re.escape(TestSCons.python_version_string()) + "\n"
    test.run(arguments = '-Q', status = 1, stderr = error)

else:

    if TestSCons.deprecated_python_version():

        test.run(arguments = '-Q', stderr = TestSCons.deprecated_python_expr)

    else:

        test.run(arguments = '-Q')
Beispiel #4
0
Verify that a builder with "multi" not set generates an error on the
second call.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write('SConstruct', """\
def build(env, target, source):
    file = open(str(target[0]), 'wb')
    for s in source:
        file.write(open(str(s), 'rb').read())

B = Builder(action=build, multi=0)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file2.out', source = 'file2a.in')
env.B(target = 'file2.out', source = 'file2b.in')
""")

test.write('file2a.in', 'file2a.in\n')
test.write('file2b.in', 'file2b.in\n')

expect = TestSCons.re_escape("""
scons: *** Multiple ways to build the same target were specified for: file2.out  (from ['file2a.in'] and from ['file2b.in'])
""") + TestSCons.file_expr

test.run(arguments='file2.out', status=2, stderr=expect)

test.pass_test()
Beispiel #5
0
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Verify basic interaction of the historic TargetSignatures('build')
and TargetSignatures('content') settings, overriding one with
the other in specific construction environments.
"""

import re

import TestSCons

test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)

expect = TestSCons.re_escape("""
scons: warning: The env.TargetSignatures() method is deprecated;
\tconvert your build to use the env.Decider() method instead.
""") + TestSCons.file_expr


sconstruct_contents = """\
SetOption('warn', 'deprecated-target-signatures')
env = Environment()

def copy1(env, source, target):
    open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())

def copy2(env, source, target):
    %s
    return copy1(env, source, target)

env['BUILDERS']['Copy1'] = Builder(action=copy1)
Beispiel #6
0
#c++
#link
""")

test.write('test3.F', r"""test3.F
#g77
#link
""")

test.run(arguments = '.', stderr=None)

test.must_match('test1.obj', "test1.c\n#link\n")
test.must_match('test2.obj', "test2.cpp\n#link\n")
test.must_match('test3.obj', "test3.F\n#link\n")
test.must_match('foo.exe',   "test1.c\ntest2.cpp\ntest3.F\n")
if TestSCons.case_sensitive_suffixes('.F', '.f'):
    test.must_match('mygcc.out', "cc\nc++\ng77\n")
else:
    test.must_match('mygcc.out', "cc\nc++\n")   

test.write('SConstruct', """
env = Environment(CPPFLAGS = '-x',
                  SHLINK = r'%(_python_)s mylink.py',
                  SHLINKFLAGS = [],
                  CC = r'%(_python_)s mygcc.py cc',
                  CXX = r'%(_python_)s mygcc.py c++',
                  CXXFLAGS = [],
                  FORTRAN = r'%(_python_)s mygcc.py g77',
                  OBJSUFFIX = '.obj',
                  SHOBJPREFIX = '',
                  SHOBJSUFFIX = '.shobj',
Beispiel #7
0
# 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 TestCmd
import TestSCons

test = TestSCons.TestSCons(match=TestCmd.match_re_dotall,
                           ignore_python_version=0)

wpath = test.workpath()

test.write('SConstruct', r"""
Help("Help text.\n")
""")

expect = """scons: Reading SConscript files ...
scons: done reading SConscript files.
Help text.

Use scons -H for help about command-line options.
"""

os.environ['SCONSFLAGS'] = ''
import TestSCons

test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)

test.write('SConscript', """
SConscript('DummyScript', build_dir = 'build')
""")

test.write('DummyScript', """
""")

msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead."""
test.deprecated_warning('deprecated-build-dir', msg)

warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \
                               + '\n' + TestSCons.file_expr

all1 = test.workpath('test', 'build', 'var1', 'all')
all2 = test.workpath('test', 'build', 'var2', 'all')
all3 = test.workpath('test', 'build', 'var3', 'all')
all4 = test.workpath('test', 'build', 'var4', 'all')
all5 = test.workpath('build', 'var5', 'all')
all6 = test.workpath('build', 'var6', 'all')
all7 = test.workpath('build', 'var7', 'all')
all8 = test.workpath('build', 'var8', 'all')
all9 = test.workpath('test', 'build', 'var9', 'src', 'all')

test.subdir('test')

test.write(['test', 'SConstruct'], """
Beispiel #9
0
# 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 the --debug=dtree option correctly prints just the explicit
dependencies (sources or Depends()) of a target.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)

test.write(
    'SConstruct', """
env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx')
env.Program('foo', Split('foo.c bar.c'))
""")

test.write(
    'foo.c', r"""
#include <stdio.h>
#include <stdlib.h>
#include "foo.h"
int main(int argc, char *argv[])
{
        argv[argc++] = "--";
Beispiel #10
0
# 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 the deprecated BuildDir() function and method still
work to create a variant directory tree (by calling VariantDir()
under the covers).
"""

import TestSCons

_exe = TestSCons._exe

test = TestSCons.TestSCons()

test.write('SConscript', """
BuildDir('build', 'src')
""")

msg = """BuildDir() and the build_dir keyword have been deprecated;
\tuse VariantDir() and the variant_dir keyword instead."""
test.deprecated_warning('deprecated-build-dir', msg)

warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \
                               + '\n' + TestSCons.file_expr

foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe)
foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe)
foo21 = test.workpath('work1', 'build', 'var2', 'foo1' + _exe)
Beispiel #11
0
# 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__ = "test/Builder/multi/same-overrides.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
"""
Verify that everything works if two multi calls have the same overrides.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

_python_ = TestSCons._python_

test.write(
    'build.py', r"""#!/usr/bin/env python
import sys
def build(num, target, source):
    file = open(str(target), 'wb')
    file.write('%s\n'%num)
    for s in source:
        file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")

test.write(
# 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 "build" command of --interactive mode can take a -j
option to build things in parallel.
"""

import TestSCons

test = TestSCons.TestSCons(combine=1)

test.write(
    'SConstruct', """\
import os
import time
from SCons.Script import *
def cat(target, source, env):
    t = str(target[0])
    os.mkdir(t + '.started')
    fp = open(t, 'wb')
    for s in source:
        fp.write(open(str(s), 'rb').read())
    fp.close()
    os.mkdir(t + '.finished')
Beispiel #13
0
    def test_Save(self):
        """Testing saving Variables"""

        test = TestSCons.TestSCons()
        cache_file = test.workpath('cached.options')
        opts = SCons.Variables.Variables()

        def bool_converter(val):
            if val in [1, 'y']: val = 1
            if val in [0, 'n']: val = 0
            return val

        # test saving out empty file
        opts.Add('OPT_VAL', 'An option to test', 21, None, None)
        opts.Add('OPT_VAL_2', default='foo')
        opts.Add('OPT_VAL_3', default=1)
        opts.Add('OPT_BOOL_0', default='n', converter=bool_converter)
        opts.Add('OPT_BOOL_1', default='y', converter=bool_converter)
        opts.Add('OPT_BOOL_2', default=0, converter=bool_converter)

        env = Environment()
        opts.Update(env, {'OPT_VAL_3': 2})
        assert env['OPT_VAL'] == 21, env['OPT_VAL']
        assert env['OPT_VAL_2'] == 'foo', env['OPT_VAL_2']
        assert env['OPT_VAL_3'] == 2, env['OPT_VAL_3']
        assert env['OPT_BOOL_0'] == 0, env['OPT_BOOL_0']
        assert env['OPT_BOOL_1'] == 1, env['OPT_BOOL_1']
        assert env['OPT_BOOL_2'] == '0', env['OPT_BOOL_2']

        env['OPT_VAL_2'] = 'bar'
        env['OPT_BOOL_0'] = 0
        env['OPT_BOOL_1'] = 1
        env['OPT_BOOL_2'] = 2

        opts.Save(cache_file, env)
        checkSave(cache_file, {
            'OPT_VAL_2': 'bar',
            'OPT_VAL_3': 2,
            'OPT_BOOL_2': 2
        })

        # Test against some old bugs
        class Foo(object):
            def __init__(self, x):
                self.x = x

            def __str__(self):
                return self.x

        test = TestSCons.TestSCons()
        cache_file = test.workpath('cached.options')
        opts = SCons.Variables.Variables()

        opts.Add('THIS_USED_TO_BREAK', 'An option to test', "Default")

        opts.Add('THIS_ALSO_BROKE', 'An option to test', "Default2")

        opts.Add('THIS_SHOULD_WORK', 'An option to test', Foo('bar'))

        env = Environment()
        opts.Update(
            env, {
                'THIS_USED_TO_BREAK': "Single'Quotes'In'String",
                'THIS_ALSO_BROKE': "\\Escape\nSequences\t",
                'THIS_SHOULD_WORK': Foo('baz')
            })
        opts.Save(cache_file, env)
        checkSave(
            cache_file, {
                'THIS_USED_TO_BREAK': "Single'Quotes'In'String",
                'THIS_ALSO_BROKE': "\\Escape\nSequences\t",
                'THIS_SHOULD_WORK': 'baz'
            })
Beispiel #14
0
#link
""")

test.write('test5.spp', r"""This is a .spp file.
#as
#link
""")

test.write('test6.SPP', r"""This is a .SPP file.
#as
#link
""")

test.run(arguments = '.', stderr = None)

if TestSCons.case_sensitive_suffixes('.s', '.S'):
    o_css = o_c
else:
    o_css = o

test.must_match('test1' + _exe, "%s\nThis is a .s file.\n" % o)
test.must_match('test2' + _exe, "%s\nThis is a .S file.\n" % o_css)
test.must_match('test3' + _exe, "%s\nThis is a .asm file.\n" % o)
test.must_match('test4' + _exe, "%s\nThis is a .ASM file.\n" % o)
test.must_match('test5' + _exe, "%s\nThis is a .spp file.\n" % o_c)
test.must_match('test6' + _exe, "%s\nThis is a .SPP file.\n" % o_c)

test.pass_test()

# Local Variables:
# tab-width:4
Beispiel #15
0
# 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 a warning is generated if the calls have different overrides
but the overrides don't appear to affect the build operation.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write(
    'SConstruct', """\
DefaultEnvironment(tools=[])
def build(env, target, source):
    with open(str(target[0]), 'wb') as f:
        for s in source:
            with open(str(s), 'rb') as infp:
                f.write(infp.read())

B = Builder(action=build, multi=1)
env = Environment(tools=[], BUILDERS = { 'B' : B })
env.B(target = 'file3.out', source = 'file3a.in', foo=1)
env.B(target = 'file3.out', source = 'file3b.in', foo=2)
""")
Beispiel #16
0
#include "bar.h"
#endif
""")

test.write('bar.h', """
#ifndef BAR_H
#define BAR_H
#include "foo.h"
#endif
""")

expect = """
scons: warning: The --debug=dtree option is deprecated; please use --tree=derived instead.
"""

stderr = TestSCons.re_escape(expect) + TestSCons.file_expr

dtree1 = """
+-foo.xxx
  +-foo.ooo
  +-bar.ooo
"""

test.run(arguments = "--debug=dtree foo.xxx",
         stderr = stderr)
test.must_contain_all_lines(test.stdout(), [dtree1])

dtree2 = """
+-.
  +-bar.ooo
  +-foo.ooo
Beispiel #17
0
# 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

__docformat__ = "restructuredText"
"""
TODO: Write documentation
"""

import sys
import TestSCons

if sys.platform == 'win32':
    test = TestSCons.TestSCons(program='scons.bat', interpreter=None)
else:
    test = TestSCons.TestSCons()

test.dir_fixture('image')
test.subdir(['src', 'site_scons'])
test.subdir(['src', 'site_scons', 'site_tools'])
test.subdir(['src', 'site_scons', 'site_tools', 'texas'])
test.file_fixture('../../../../../../about.py',
                  'src/site_scons/site_tools/texas/about.py')
test.file_fixture('../../../../../../__init__.py',
                  'src/site_scons/site_tools/texas/__init__.py')
test.file_fixture('../../../../../../TeXASCommon.py',
                  'src/site_scons/site_tools/texas/TeXASCommon.py')
test.file_fixture('../../../../../../TeXASDist.py',
                  'src/site_scons/site_tools/texas/TeXASDist.py')
Beispiel #18
0
    file = open(str(target[0]), 'wb')
    for s in source:
        file.write(open(str(s), 'rb').read())

B = Builder(action=build, multi=1)
env = Environment(BUILDERS = { 'B' : B })
env2 = env.Clone(DIFFERENT_VARIABLE = 'true')
env.B(target = 'file5.out', source = 'file5a.in')
env2.B(target = 'file5.out', source = 'file5b.in')
""")

test.write('file5a.in', 'file5a.in\n')
test.write('file5b.in', 'file5b.in\n')

expect = TestSCons.re_escape("""
scons: warning: Two different environments were specified for target file5.out,
\tbut they appear to have the same action: build(target, source, env)
""") + TestSCons.file_expr

test.run(arguments='file5.out', stderr=expect)

test.must_match('file5.out', "file5a.in\nfile5b.in\n")

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
# 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 environments with actions that have different signatures
generate an error.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write(
    'SConstruct', """\
DefaultEnvironment(tools=[])
def build(env, target, source):
    file = open(str(target[0]), 'wb')
    for s in source:
        file.write(open(str(s), 'rb').read())

B = Builder(action=Action(build, varlist=['XXX']), multi=1)
env = Environment(tools=[], BUILDERS = { 'B' : B }, XXX = 'foo')
env2 = env.Clone(XXX = 'var')
env.B(target = 'file6.out', source = 'file6a.in')
env2.B(target = 'file6.out', source = 'file6b.in')
""")
import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write('SConstruct', """\
def build(env, target, source):
    for t in target:
        file = open(str(target[0]), 'wb')
        for s in source:
            file.write(open(str(s), 'rb').read())

B = Builder(action=build, multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = ['file12a.out', 'file12b.out'], source = 'file12a.in')
env.B(target = 'file12a.out', source = 'file12b.in')
""")

test.write('file12a.in', 'file12a.in\n')
test.write('file12b.in', 'file12b.in\n')

expect = TestSCons.re_escape("""
scons: *** Two different target lists have a target in common: file12a.out  (from ['file12a.out', 'file12b.out'] and from ['file12a.out'])
""") + TestSCons.file_expr

test.run(arguments='file12.out', status=2, stderr=expect)



test.pass_test()
Beispiel #21
0
# 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(
    'build.py', r"""
import sys
with open(sys.argv[1], 'wb') as f, open(sys.argv[2], 'rb') as infp:
    f.write(infp.read())
""")

test.write(
    'SConstruct', """
DefaultEnvironment(tools=[])
SetOption('md5_chunksize', 128)
B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
env = Environment(tools=[], BUILDERS = { 'B' : B })
f1 = env.B(target = 'f1.out', source = 'f1.in')
Beispiel #22
0
    def test_Update(self):
        """Test updating an Environment"""

        # Test that a default value is validated correctly.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', 'THE answer to THE question', "42", check,
                 lambda x: int(x) + 12)

        env = Environment()
        opts.Update(env)
        assert env['ANSWER'] == 54

        env = Environment()
        opts.Update(env, {})
        assert env['ANSWER'] == 54

        # Test that a bad value from the file is used and
        # validation fails correctly.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        test.write('custom.py', 'ANSWER=54')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', 'THE answer to THE question', "42", check,
                 lambda x: int(x) + 12)

        env = Environment()
        exc_caught = None
        try:
            opts.Update(env)
        except AssertionError:
            exc_caught = 1
        assert exc_caught, "did not catch expected assertion"

        env = Environment()
        exc_caught = None
        try:
            opts.Update(env, {})
        except AssertionError:
            exc_caught = 1
        assert exc_caught, "did not catch expected assertion"

        # Test that a good value from the file is used and validated.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        test.write('custom.py', 'ANSWER=42')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', 'THE answer to THE question', "10", check,
                 lambda x: int(x) + 12)

        env = Environment()
        opts.Update(env)
        assert env['ANSWER'] == 54

        env = Environment()
        opts.Update(env, {})
        assert env['ANSWER'] == 54

        # Test that a bad value from an args dictionary passed to
        # Update() is used and validation fails correctly.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        test.write('custom.py', 'ANSWER=10')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', 'THE answer to THE question', "12", check,
                 lambda x: int(x) + 12)

        env = Environment()
        exc_caught = None
        try:
            opts.Update(env, {'ANSWER': '54'})
        except AssertionError:
            exc_caught = 1
        assert exc_caught, "did not catch expected assertion"

        # Test that a good value from an args dictionary
        # passed to Update() is used and validated.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        test.write('custom.py', 'ANSWER=10')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', 'THE answer to THE question', "12", check,
                 lambda x: int(x) + 12)

        env = Environment()
        opts.Update(env, {'ANSWER': '42'})
        assert env['ANSWER'] == 54

        # Test against a former bug.  If we supply a converter,
        # but no default, the value should *not* appear in the
        # Environment if no value is specified in the options file
        # or args.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', help='THE answer to THE question', converter=str)

        env = Environment()
        opts.Update(env, {})
        assert 'ANSWER' not in env

        # Test that a default value of None is all right.
        test = TestSCons.TestSCons()
        file = test.workpath('custom.py')
        opts = SCons.Variables.Variables(file)

        opts.Add('ANSWER', "This is the answer", None, check)

        env = Environment()
        opts.Update(env, {})
        assert 'ANSWER' not in env
Beispiel #23
0
# 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'):
    f77pp = 'f77'
else:
Beispiel #24
0
actions generate an error.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write('SConstruct', """\
e1 = Environment()
e2 = Environment()

e1.Command('out.txt', [], 'echo 1 > $TARGET')
e2.Command('out.txt', [], 'echo 2 > $TARGET')
""",'w')

expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: out.txt
(action 1: echo 1 > out.txt)
(action 2: echo 2 > out.txt)
""") + TestSCons.file_expr

test.run(arguments='out.txt', status=2, stderr=expect)

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
Beispiel #25
0
# 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 setting the $P4COM variable.
"""

import os.path

import TestSCons

_python_ = TestSCons._python_

test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)

test.write('SConscript', """
Environment(tools = ['Perforce']).Perforce()
""")

msg_p4 = """The Perforce() factory is deprecated and there is no replacement."""
warn_p4 = test.deprecated_fatal('deprecated-build-dir', msg_p4)
msg_sc = """SourceCode() has been deprecated and there is no replacement.
\tIf you need this function, please contact [email protected]."""
warn_sc = test.deprecated_wrap(msg_sc)

test.subdir('Perforce', ['Perforce', 'sub'], 'sub')

sub_Perforce = os.path.join('sub', 'Perforce')
sub_SConscript = os.path.join('sub', 'SConscript')
    for s in source:
        file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")

test.write('SConstruct', """\
B = Builder(action=r'%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file03.out', source = 'file03a.in', foo=1)
env.B(target = 'file03.out', source = 'file03b.in', foo=2)
""" % locals())

test.write('file03a.in', 'file03a.in\n')
test.write('file03b.in', 'file03b.in\n')

expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: file03.out
(action 1: %s build.py 1 file03.out file03b.in)
(action 2: %s build.py 2 file03.out file03b.in)
""" % (sys.executable, sys.executable )) + TestSCons.file_expr

test.run(arguments='file03.out', status=2, stderr=expect)

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Verify that a target file can't be in two different target lists.
"""

# XXX It would be nice if the following two tests could be made to work
# by executing the action once for each unique set of targets. This
# would make it simple to deal with PDB files on Windows like so:
#
#     env.Object(['foo.obj', 'vc60.pdb'], 'foo.c')
#     env.Object(['bar.obj', 'vc60.pdb'], 'bar.c')

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write(
    'SConstruct', """\
DefaultEnvironment(tools=[])
def build(env, target, source):
    for t in target:
        file = open(str(target[0]), 'wb')
        for s in source:
            file.write(open(str(s), 'rb').read())

B = Builder(action=build, multi=1)
env = Environment(tools=[], BUILDERS = { 'B' : B })
env.B(target = ['file11a.out', 'file11b.out'], source = 'file11a.in')
env.B(target = ['file11b.out', 'file11c.out'], source = 'file11b.in')
""")
Beispiel #28
0
cat(["bbb.out"], ["bbb.in"])
%(_python_)s my-cvs-co-.py ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
%(_python_)s my-cvs-co-.py %(sub_ddd_in)s
cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
%(_python_)s my-cvs-co-.py %(sub_fff_in)s
cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
"""
    % locals()
)

stdout = test.wrap_stdout(read_str=read_str, build_str=build_str)

test.run(arguments=".", stdout=TestSCons.re_escape(stdout), stderr=warn_cvs + warn_sc)

test.must_match("all", "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n")

test.must_match(["sub", "all"], "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n")


test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
Beispiel #29
0
# 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 a "multi" builder can be called multiple times with the same
target list if everything is identical.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re)

test.write(
    'SConstruct', """\
def build(env, target, source):
    for t in target:
        file = open(str(t), 'wb')
        for s in source:
            file.write(open(str(s), 'rb').read())

B = Builder(action=build, multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = ['file9a.out', 'file9b.out'], source = 'file9a.in')
env.B(target = ['file9a.out', 'file9b.out'], source = 'file9b.in')
""")
Beispiel #30
0
cat(["sub/fff.out"], ["sub/fff.in"])
cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"])
"""

    stdout = test.wrap_stdout(read_str = read_str, build_str = build_str)

    stderr = """\
sub/SConscript 1.1 -> 1.2: 5 lines
aaa.in 1.1 -> 1.2: 1 lines
ccc.in 1.1 -> 1.2: 1 lines
sub/ddd.in 1.1 -> 1.2: 1 lines
sub/fff.in 1.1 -> 1.2: 1 lines
"""

    test.run(arguments = '.',
             stdout = TestSCons.re_escape(stdout),
             stderr = warn_bk + warn_sc + TestSCons.re_escape(stderr))

    test.must_match(['work1', 'all'], "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n")

    test.must_be_writable(test.workpath('work1', 'sub', 'SConscript'))
    test.must_be_writable(test.workpath('work1', 'aaa.in'))
    test.must_be_writable(test.workpath('work1', 'ccc.in'))
    test.must_be_writable(test.workpath('work1', 'sub', 'ddd.in'))
    test.must_be_writable(test.workpath('work1', 'sub', 'fff.in'))

# Test using BitKeeper to fetch from RCS/file,v files.
rcs = test.where_is('rcs')
ci = test.where_is('ci')
if not rcs:
    print "Could not find RCS,\nskipping sub-test of BitKeeper using RCS files."
Beispiel #31
0

def match_normcase(lines, matches):
    if not isinstance(lines, list):
        lines = lines.split("\n")
    if not isinstance(matches, list):
        matches = matches.split("\n")
    if len(lines) != len(matches):
        return
    for i in range(len(lines)):
        if os.path.normcase(lines[i]) != os.path.normcase(matches[i]):
            return
    return 1


test = TestSCons.TestSCons(match=match_normcase)

wpath = test.workpath()
wpath_sub = test.workpath('sub')
wpath_sub_dir = test.workpath('sub', 'dir')
wpath_sub_foo_bar = test.workpath('sub', 'foo', 'bar')

test.subdir('sub', ['sub', 'dir'])

test.write('SConstruct', """
import os
print("SConstruct", os.getcwd())
""")

test.write(['sub', 'SConstruct'], """
import os
    file = open(str(target), 'wb')
    file.write('%s\n'%num)
    for s in source:
        file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")

test.write('SConstruct', """\
B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file4.out', source = 'file4a.in', foo=3)
env.B(target = 'file4.out', source = 'file4b.in', foo=3)
""" % locals())

test.write('file4a.in', 'file4a.in\n')
test.write('file4b.in', 'file4b.in\n')

python_expr = string.replace(TestSCons.python, '\\', '\\\\')
act = TestSCons.re_escape('"%s" build.py \$foo \$TARGET \$SOURCES' % python_expr)

expect = ("""
scons: warning: Two different environments were specified for target file4.out,
\tbut they appear to have the same action: %s
""" % act) + TestSCons.file_expr

test.run(arguments='file4.out', stderr=expect)

test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n")

test.pass_test()
Beispiel #33
0
# 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 string
import sys
import TestSCons

_python_ = TestSCons._python_

test = TestSCons.TestSCons()
_exe = TestSCons._exe

if sys.platform == 'win32':

    o = ' -x'

    o_c = ' -x'

    test.write(
        'mylink.py', r"""
import string
import sys
args = sys.argv[1:]
while args:
    a = args[0]
_python_ = TestSCons._python_

test.write('build.py', r"""#!/usr/bin/env python
import sys
def build(num, target, source):
    file = open(str(target), 'wb')
    file.write('%s\n'%num)
    for s in source:
        file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")

test.write('SConstruct', """\
B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file03.out', source = 'file03a.in', foo=1)
env.B(target = 'file03.out', source = 'file03b.in', foo=2)
""" % locals())

test.write('file03a.in', 'file03a.in\n')
test.write('file03b.in', 'file03b.in\n')

expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: file03.out
""") + TestSCons.file_expr

test.run(arguments='file03.out', status=2, stderr=expect)

test.pass_test()
# 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 fetching source files using the SourceCode() method.
"""

import os

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)

test.write('SConscript', """
SourceCode('.', None)
""")

msg = """SourceCode() has been deprecated and there is no replacement.
\tIf you need this function, please contact [email protected]"""
warning = test.deprecated_warning('deprecated-source-code', msg)

test.subdir('sub', 'sub2')

test.write(
    'SConstruct', """\
SetOption('warn', 'deprecated-source-code')
import os
Beispiel #36
0
def build2(env, target, source):
    build(env, target, source)

# Put the names on the Builder objects and in the environment so
# the error output should be consistent regardless of Python version
# or how we mess with the Builder internals.
B = Builder(action=build, multi=1, name='B')
C = Builder(action=build2, multi=1, name='C')
env = Environment(BUILDERS = { 'B' : B, 'C' : C })
env.B(target = 'file8.out', source = 'file8.in')
env.C(target = 'file8.out', source = 'file8.in')
""")

test.write('file8a.in', 'file8a.in\n')
test.write('file8b.in', 'file8b.in\n')

expect = TestSCons.re_escape("""
scons: *** Two different builders (B and C) were specified for the same target: file8.out
""") + TestSCons.file_expr

test.run(arguments='file8.out', status=2, stderr=expect)

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
# 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 use of the --warn=misleading-keywords option.
"""

import TestSCons

test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)

test.write(
    'SConstruct', """
DefaultEnvironment(tools=[])
def build(env, target, source):
    file = open(str(target[0]), 'wb')
    for s in source:
        file.write(open(str(s), 'rb').read())

WARN = ARGUMENTS.get('WARN')
if WARN:
    SetOption('warn', WARN)

B = Builder(action=build, multi=1)
env = Environment(tools=[], BUILDERS = { 'B' : B })
Beispiel #38
0
cat(["bbb.out"], ["bbb.in"])
%(_python_)s my-bk-get.py ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
%(_python_)s my-bk-get.py %(sub_ddd_in)s
cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
%(_python_)s my-bk-get.py %(sub_fff_in)s
cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
""" % locals()

stdout = test.wrap_stdout(read_str = read_str, build_str = build_str)

test.run(arguments = '.',
         stdout = TestSCons.re_escape(stdout),
         stderr = warn_bk + warn_sc)

test.must_match('all',
                "BitKeeper/aaa.in\nchecked-out bbb.in\nBitKeeper/ccc.in\n")

test.must_match(['sub', 'all'],
                "BitKeeper/sub/ddd.in\nchecked-out sub/eee.in\nBitKeeper/sub/fff.in\n")


test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
Beispiel #39
0
# 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_
_exe   = TestSCons._exe

test = TestSCons.TestSCons()

test.file_fixture('mylink.py')
test.file_fixture(['fixture', 'myfortran.py'])

test.write('SConstruct', """
env = Environment(LINK = r'%(_python_)s mylink.py',
                  LINKFLAGS = [],
                  F03 = r'%(_python_)s myfortran.py f03',
                  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')
Beispiel #40
0
/*link*/
""")

test.run(arguments = '.', stderr = None)

test.must_match('test1' + _exe, "This is a .cc file.\n")

test.must_match('test2' + _exe, "This is a .cpp file.\n")

test.must_match('test3' + _exe, "This is a .cxx file.\n")

test.must_match('test4' + _exe, "This is a .c++ file.\n")

test.must_match('test5' + _exe, "This is a .C++ file.\n")

if TestSCons.case_sensitive_suffixes('.c', '.C'):

    test.write('SConstruct', """
env = Environment(LINK = r'%(_python_)s mylink.py',
                  LINKFLAGS = [],
                  CXX = r'%(_python_)s myc++.py',
                  CXXFLAGS = [])
env.Program(target = 'test6', source = 'test6.C')
""" % locals())

    test.write('test6.C', r"""This is a .C file.
/*c++*/
/*link*/
""")

    test.run(arguments = '.', stderr = None)

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"):
    fortranpp = "fortran"
else:
    fortranpp = "fortranpp"


test.write(
    "SConstruct",
    """
env = Environment(SHFORTRANCOM = r'%(_python_)s myfc.py fortran $TARGET $SOURCES',
                  SHFORTRANCOMSTR = 'Building fortran $TARGET from $SOURCES',
                  SHFORTRANPPCOM = r'%(_python_)s myfc.py fortranpp $TARGET $SOURCES',
                  SHFORTRANPPCOMSTR = 'Building fortranpp $TARGET from $SOURCES',
                  SHOBJPREFIX='', SHOBJSUFFIX='.shobj')
env.SharedObject(source = 'test01.f')
env.SharedObject(source = 'test02.F')
Beispiel #42
0
cat(["bbb.out"], ["%s"])
sc_cat(["%s"], [])
cat(["ccc.out"], ["%s"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
sc_cat(["%s"], [])
cat(["ddd.out"], ["%s"])
""" % (os.path.join('sub', 'aaa.in'),
       os.path.join('sub', 'aaa.in'),
       os.path.join('sub', 'bbb.in'),
       os.path.join('sub', 'bbb.in'),
       os.path.join('sub', 'ccc.in'),
       os.path.join('sub', 'ccc.in'),
       os.path.join('sub2', 'ddd.in'),
       os.path.join('sub2', 'ddd.in'))

stdout = TestSCons.re_escape(test.wrap_stdout(read_str = read_str,
                                              build_str = build_str))

test.run(arguments = '.', stdout = stdout, stderr = 2*warning)

test.must_match(['sub', 'SConscript'], "'sub/sc-SConscript'\n")
test.must_match('all', "sub/sc-aaa.in\nsub/sc-bbb.in\nsub/sc-ccc.in\n")
test.must_match('ddd.out', "sub2/sc-ddd.in\n")

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
Beispiel #43
0
        file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")

test.write('SConstruct', """\
B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file4.out', source = 'file4a.in', foo=3)
env.B(target = 'file4.out', source = 'file4b.in', foo=3)
""" % locals())

test.write('file4a.in', 'file4a.in\n')
test.write('file4b.in', 'file4b.in\n')

expect = ("""
scons: warning: Two different environments were specified for target file4.out,
\tbut they appear to have the same action: %s build.py .foo .TARGET .SOURCES
""" % TestSCons.re_escape(_python_)) + TestSCons.file_expr

test.run(arguments='file4.out', stderr=expect)

test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n")

test.pass_test()

# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
Beispiel #44
0
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'):
    f90pp = 'f90'
else:
    f90pp = 'f90pp'

test.write('SConstruct', """
env = Environment(F90COM = r'%(_python_)s myfc.py f90 $TARGET $SOURCES',
                  F90COMSTR = 'Building f90 $TARGET from $SOURCES',
                  F90PPCOM = r'%(_python_)s myfc.py f90pp $TARGET $SOURCES',
                  F90PPCOMSTR = 'Building f90pp $TARGET from $SOURCES',
                  OBJSUFFIX='.obj')
env.Object(source = 'test01.f90')
env.Object(source = 'test02.F90')
""" % locals())

test.write('test01.f90',        "A .f90 file.\n#f90\n")
Beispiel #45
0
#

__revision__ = "test/python-version.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"

"""
Verify the behavior of our check for unsupported or deprecated versions
of Python.
"""

import os
import re

import TestCmd
import TestSCons

test = TestSCons.TestSCons(match = TestCmd.match_re_dotall,ignore_python_version=0)

test.write('SConstruct', "\n")

test.write('SetOption-deprecated', "SetOption('warn', 'no-deprecated')\n")

test.write('SetOption-python', "SetOption('warn', ['no-python-version'])\n")

if TestSCons.unsupported_python_version():

    error = "scons: \*\*\* SCons version \S+ does not run under Python version %s."
    error = error % re.escape(TestSCons.python_version_string()) + "\n"
    test.run(arguments = '-Q', status = 1, stderr = error)

else: