Example #1
0
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))

    test.dir_fixture('Image')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))

    test.run()

    test.must_not_exist(test.workpath('amod.o'))
    test.must_not_exist(test.workpath('bmod.o'))
    test.must_not_exist(test.workpath('main.o'))
    if tool == 'gdc':
        test.must_not_exist(test.workpath('project.o'))
    else:
        test.must_exist(test.workpath('project.o'))
    test.must_exist(test.workpath('project'))

    test.run(program=test.workpath('project'+TestSCons._exe))
    test.fail_test(test.stdout() != '''This is a test program for a new SCons D builder.
The value is 42.
''')

    test.run('-c')

    test.must_not_exist(test.workpath('amod.o'))
    test.must_not_exist(test.workpath('bmod.o'))
    test.must_not_exist(test.workpath('main.o'))
    test.must_not_exist(test.workpath('project.o'))
    test.must_not_exist(test.workpath('project'))

    test.pass_test()
Example #2
0
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))

    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('helloWorld.o'))
    test.must_exist(test.workpath('helloWorld'))

    test.run(program=test.workpath('helloWorld' + TestSCons._exe))
    test.fail_test(test.stdout() != 'Hello World.\n')

    test.pass_test()
Example #3
0
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))

    test.dir_fixture('Project')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format('tools=["{0}", "link"]'.format(tool))
    test.write('SConstruct', config)

    test.run()

    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()
Example #4
0
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))

    test.dir_fixture('SingleStringCannotBeMultipleOptions')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))

    test.run(status=2, stdout=None, stderr=None)

    result = {
        'dmd': ".*unrecognized switch '-m64 -O'.*",
        'gdc': ".*unrecognized command line option.*",
        '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()
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))

    test.dir_fixture('SingleStringCannotBeMultipleOptions')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format(tool))

    test.run(status=2, stdout=None, stderr=None)

    result = {
        'dmd': ".*unrecognized switch '-m64 -O'.*",
        'gdc': ".*unrecognized command line option.*",
        '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()
Example #6
0
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))

    test.dir_fixture('Project')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "link"]'.format(tool)))

    test.run()

    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()
Example #7
0
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':
        result = check_output(('gdc', '--version'))
        version = result.decode().splitlines()[0].split()[3]
        major, minor, debug = [int(x) for x in version.split('.')]
        if (major < 6) or (major == 6 and minor < 3):
            test.skip_test(
                'gdc prior to version 6.0.0 does not 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'
        )

    code_root = 'code'
    library_root = 'answer'

    platform = Base()['PLATFORM']
    if platform == 'posix':
        code_name = code_root + '.o'
        library_name = 'lib' + library_root + '.so'
    elif platform == 'darwin':
        code_name = code_root + '.o'
        library_name = 'lib' + library_root + '.dylib'
        # As at 2017-08-22, DMD 2.075.1, LDC 1.2.0 (D 2.072.2), and GDC 7.2.0 (D 2.068.2)
        # it is not clear if shared libraries are supported on macOS.
        # test.skip_test('Dynamic libraries not yet supported on macOS.\n')
    elif platform == 'win32':
        code_name = code_root + '.obj'
        library_name = library_root + '.dll'
    else:
        test.fail_test()

    test.dir_fixture('Image')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format(tool)
    test.write('SConstruct', config)

    if Base()['DC'] == 'gdmd':
        # 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(code_name))
    test.must_exist(test.workpath(library_name))

    test.pass_test()
Example #8
0
def testForTool(tool):

    test = TestSCons.TestSCons()

    _obj = TestSCons._obj

    if not isExecutableOfToolAvailable(test, 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))

    arguments = 'test1%(_obj)s test2%(_obj)s' % locals()

    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(arguments=arguments, stderr=None)
    else:
        test.run(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.write(['module2.d'], """\
module  module2;

int something_else;
""")

    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.not_up_to_date(arguments=arguments, stderr=None)
    else:
        test.not_up_to_date(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.write(['p', 'submodule2.d'], """\
module p.submodule2;

int something_else;
""")

    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.not_up_to_date(arguments=arguments, stderr=None)
    else:
        test.not_up_to_date(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.pass_test()
Example #9
0
def testForTool(tool):

    test = TestSCons.TestSCons()

    _obj = TestSCons._obj

    if not isExecutableOfToolAvailable(test, 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))

    arguments = 'test1%(_obj)s test2%(_obj)s' % locals()

    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(arguments=arguments, stderr=None)
    else:
        test.run(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.write(['module2.d'], """\
module  module2;

int something_else;
""")

    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.not_up_to_date(arguments=arguments, stderr=None)
    else:
        test.not_up_to_date(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.write(['p', 'submodule2.d'], """\
module p.submodule2;

int something_else;
""")

    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.not_up_to_date(arguments=arguments, stderr=None)
    else:
        test.not_up_to_date(arguments=arguments)

    test.up_to_date(arguments=arguments)

    test.pass_test()
Example #10
0
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':
        result = check_output(('gdc', '--version'))
        version = result.decode().splitlines()[0].split()[3]
        major, minor, debug = [int(x) for x in version.split('.')]
        if (major < 6) or (major == 6 and minor < 3):
            test.skip_test(
                'gdc prior to version 6.0.0 does not 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'
    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 Base()['DC'] == 'gdmd':
        # 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()
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))

    test.dir_fixture('Project')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "link"]'.format(tool)))

    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()
Example #12
0
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':
        result = check_output(('gdc', '--version'))
        version = result.decode().splitlines()[0].split()[3]
        major, minor, debug = [int(x) for x in version.split('.')]
        if (major < 6) or (major == 6 and minor < 3):
            test.skip_test('gdc prior to version 6.0.0 does not 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()
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))

    test.dir_fixture('ArLibIssue')
    test.write('SConstruct', open('SConstruct_template', 'r').read().format('tools=["{0}", "ar"]'.format(tool)))

    test.run()

    test.must_exist(test.workpath('a.o'))
    test.must_exist(test.workpath('b.o'))
    test.must_exist(test.workpath('mylib.a' if Base()['PLATFORM'] == 'win32' else 'libmylib.a'))

    test.pass_test()
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))

    test.dir_fixture('Project')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format('tools=["{0}", "link"]'.format(tool))
    test.write('SConstruct', config)

    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()
Example #15
0
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()
Example #16
0
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 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))

    test.run()

    test.must_exist(test.workpath('ncurs_impl.o'))
    test.must_exist(test.workpath('cprog'))
    test.must_exist(test.workpath('prog'))

    test.pass_test()
Example #17
0
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))

    test.dir_fixture('Image')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format(tool)
    test.write('SConstruct', config)

    test.run()

    test.must_not_exist(test.workpath('amod.o'))
    test.must_not_exist(test.workpath('bmod.o'))
    test.must_not_exist(test.workpath('main.o'))
    if tool == 'gdc':
        test.must_not_exist(test.workpath('project.o'))
    else:
        test.must_exist(test.workpath('project.o'))
    test.must_exist(test.workpath('project'))

    test.run(program=test.workpath('project' + TestSCons._exe))
    test.fail_test(
        test.stdout() != '''This is a test program for a new SCons D builder.
The value is 42.
''')

    test.run('-c')

    test.must_not_exist(test.workpath('amod.o'))
    test.must_not_exist(test.workpath('bmod.o'))
    test.must_not_exist(test.workpath('main.o'))
    test.must_not_exist(test.workpath('project.o'))
    test.must_not_exist(test.workpath('project'))

    test.pass_test()
Example #18
0
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))

    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()
Example #19
0
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))

    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()
Example #20
0
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))

    test.dir_fixture('LibCompileOptions')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format('tools=["{0}", "link", "ar"]'.format(tool))
    test.write('SConstruct', config)

    test.run()

    test.must_exist(test.workpath('mylib.o'))
    test.must_exist(
        test.workpath('mylib.a' if Base()['PLATFORM'] ==
                      'win32' else 'libmylib.a'))
    test.must_exist(test.workpath('prog'))

    test.pass_test()
Example #21
0
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))

    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=["{0}", "link"]'.format(tool)))

    test.run()

    for f in (libraryname, filename, 'test1', 'test1.o', 'test2', 'test2.o'):
        test.must_exist(test.workpath(join('test', 'test1', f)))

    test.pass_test()
Example #22
0
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))

    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('helloWorld.o'))
    test.must_exist(test.workpath('helloWorld'))

    test.run(program=test.workpath('helloWorld'+TestSCons._exe))
    test.fail_test(test.stdout() != 'Hello World.\n')

    test.pass_test()
Example #23
0
#  Amended by Russel Winder <*****@*****.**> 2010-05-05

__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 isExecutableOfToolAvailable(test, 'dmd'):
    test.skip_test("Could not find 'dmd'; skipping test.\n")

test.write('SConstruct', """\
import os
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')
""")

test.write('foo.d', """\
import std.stdio;
int main(string[] args) {
    printf("Hello!");
    return 0;
Example #24
0
#  Amended by Russel Winder <*****@*****.**> 2010-05-05

__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 isExecutableOfToolAvailable(test, "dmd"):
    test.skip_test("Could not find 'dmd'; skipping test.\n")

test.write(
    "SConstruct",
    """\
import os
env = Environment()
if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
env.Program('foo', 'foo.d')
""",
)

test.write(
    "foo.d",
    """\
Example #25
0
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':
        cp = subprocess.run(('gdc', '--version'), stdout=subprocess.PIPE)
        # different version strings possible, i.e.:
        # gdc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3)\nCopyright (C)...
        # gdc (Ubuntu 10.2.0-5ubuntu1~20.04) 10.20.0\nCopyright (C)...
        vstr = cp.stdout.decode().splitlines()[0]
        match = re.search(r'[0-9]+(\.[0-9]+)+', vstr)
        if match:
            version = match.group(0)
            major, minor, debug = [int(x) for x in version.split('.')]
        else:
            major = 0
        if (major < 6) or (major == 6 and minor < 3):
            test.skip_test(
                'gdc prior to version 6.0.0 does not 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'
        )

    code_root = 'code'
    library_root = 'answer'

    platform = Base()['PLATFORM']
    if platform == 'posix':
        code_name = code_root + '.o'
        library_name = 'lib' + library_root + '.so'
    elif platform == 'darwin':
        code_name = code_root + '.o'
        library_name = 'lib' + library_root + '.dylib'
        # As at 2017-08-22, DMD 2.075.1, LDC 1.2.0 (D 2.072.2), and GDC 7.2.0 (D 2.068.2)
        # it is not clear if shared libraries are supported on macOS.
        # test.skip_test('Dynamic libraries not yet supported on macOS.\n')
    elif platform == 'win32':
        code_name = code_root + '.obj'
        library_name = library_root + '.dll'
    else:
        test.fail_test()

    test.dir_fixture('Image')
    with open('SConstruct_template', 'r') as f:
        config = f.read().format(tool)
    test.write('SConstruct', config)

    if Base()['DC'] == 'gdmd':
        # 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(code_name))
    test.must_exist(test.workpath(library_name))

    test.pass_test()
Example #26
0
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import TestSCons

from os.path import abspath, dirname

import sys
sys.path.insert(1, abspath(dirname(__file__) + '/Support'))

from executablesSearch import isExecutableOfToolAvailable

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

if not isExecutableOfToolAvailable(test, 'ldc'):
    test.skip_test("Could not find 'ldc', skipping test.\n")

test.write('SConstruct', """\
import os
env = Environment(tools=['ldc', 'link'])
if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
env.Program('foo', 'foo.d')
""")

test.write('foo.d', """\
import std.stdio;
int main(string[] args) {
    printf("Hello!");
    return 0;
}
Example #27
0
#  Amended by Russel Winder <*****@*****.**> 2010-05-05

__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 isExecutableOfToolAvailable(test, 'dmd'):
    test.skip_test("Could not find 'dmd'; skipping test.\n")

test.write(
    'SConstruct', """\
import os
env = Environment()
if env['PLATFORM'] == 'cygwin': env['OBJSUFFIX'] = '.obj'  # trick DMD
env.Program('foo', 'foo.d')
""")

test.write(
    'foo.d', """\
import std.stdio;
int main(char[][] args) {
    printf("Hello!\n");