Example #1
0
def make_benchmarks(test_programs, tests, userconfig, copy_files_since):
    '''Make a new set of benchmarks.

test_programs: dictionary of test programs.
tests: list of tests.
userconfig: path to the userconfig file.  This is updated with the new benchmark id.
copy_files_since: files produced since the timestamp (in seconds since the
    epoch) are copied to the testcode_data subdirectory in each test.
'''

    # All tests passed?
    statuses = [test.get_status() for test in tests]
    npassed = sum(status['passed'] for status in statuses)
    nran = sum(status['ran'] for status in statuses)
    if npassed != nran:
        ans = ''
        print('Not all tests passed.')
        while ans != 'y' and ans != 'n':
            ans = testcode2.compatibility.compat_input(
                                                'Create new benchmarks? [y/n] ')
        if ans != 'y':
            return None

    # Get vcs info.
    vcs = {}
    for (key, program) in test_programs.items():
        if program.vcs and program.vcs.vcs:
            vcs[key] = program.vcs.get_code_id()
        else:
            print('Program not under (known) version control system')
            vcs[key] = testcode2.compatibility.compat_input(
                    'Enter revision id for %s: ' % (key))

    # Benchmark label from vcs info.
    if len(vcs) == 1:
        benchmark = vcs.popitem()[1]
    else:
        benchmark = []
        for (key, code_id) in vcs.items():
            benchmark.append('%s-%s' % (key, code_id))
        benchmark = '.'.join(benchmark)

    # Create benchmarks.
    for test in tests:
        test.create_new_benchmarks(benchmark, copy_files_since)

    # update userconfig file.
    if userconfig:
        print('Setting new benchmark in userconfig to be %s.' % (benchmark))
        config = testcode2.compatibility.configparser.RawConfigParser()
        config.optionxform = str # Case sensitive file.
        config.read(userconfig)
        config.set('user', 'benchmark', benchmark)
        userconfig = open(userconfig, 'w')
        config.write(userconfig)
        userconfig.close()
Example #2
0
def make_benchmarks(test_programs, tests, userconfig, copy_files_since):
    """Make a new set of benchmarks.

test_programs: dictionary of test programs.
tests: list of tests.
userconfig: path to the userconfig file.  This is updated with the new benchmark id.
copy_files_since: files produced since the timestamp (in seconds since the
    epoch) are copied to the testcode_data subdirectory in each test.
"""

    # All tests passed?
    statuses = [test.get_status() for test in tests]
    npassed = sum(status["passed"] for status in statuses)
    nran = sum(status["ran"] for status in statuses)
    if npassed != nran:
        ans = ""
        print("Not all tests passed.")
        while ans != "y" and ans != "n":
            ans = testcode2.compatibility.compat_input("Create new benchmarks? [y/n] ")
        if ans != "y":
            return None

    # Get vcs info.
    vcs = {}
    for (key, program) in test_programs.items():
        if program.vcs and program.vcs.vcs:
            vcs[key] = program.vcs.get_code_id()
        else:
            print("Program not under (known) version control system")
            vcs[key] = testcode2.compatibility.compat_input("Enter revision id for %s: " % (key))

    # Benchmark label from vcs info.
    if len(vcs) == 1:
        benchmark = vcs.popitem()[1]
    else:
        benchmark = []
        for (key, code_id) in vcs.items():
            benchmark.append("%s-%s" % (key, code_id))
        benchmark = ".".join(benchmark)

    # Create benchmarks.
    for test in tests:
        test.create_new_benchmarks(benchmark, copy_files_since)

    # update userconfig file.
    if userconfig:
        print("Setting new benchmark in userconfig to be %s." % (benchmark))
        config = testcode2.compatibility.configparser.RawConfigParser()
        config.optionxform = str  # Case sensitive file.
        config.read(userconfig)
        config.set("user", "benchmark", benchmark)
        userconfig = open(userconfig, "w")
        config.write(userconfig)
        userconfig.close()
def make_benchmarks(test_programs, tests, userconfig, copy_files_since,
        insert_id=False):
    '''Make a new set of benchmarks.

test_programs: dictionary of test programs.
tests: list of tests.
userconfig: path to the userconfig file.  This is updated with the new benchmark id.
copy_files_since: files produced since the timestamp (in seconds since the
    epoch) are copied to the testcode_data subdirectory in each test.
insert_id: insert the new benchmark id into the existing list of benchmark ids in
    userconfig if True, otherwise overwrite the existing benchmark ids with the
    new benchmark id (default).
'''

    # All tests passed?
    statuses = [test.get_status() for test in tests]
    npassed = sum(status['passed'] for status in statuses)
    nran = sum(status['ran'] for status in statuses)
    if npassed != nran:
        ans = ''
        print('Not all tests passed.')
        while ans != 'y' and ans != 'n':
            ans = testcode2.compatibility.compat_input(
                                                'Create new benchmarks? [y/n] ')
        if ans != 'y':
            return None

    # Get vcs info.
#    vcs = {}
#    for (key, program) in test_programs.items():
#        if program.vcs and program.vcs.vcs:
#            vcs[key] = program.vcs.get_code_id()
#        else:
#            print('Program not under (known) version control system')
#            vcs[key] = testcode2.compatibility.compat_input(
#                    'Enter revision id for %s: ' % (key))

    # HACK
    code_id = testcode2.compatibility.compat_input(
                    'Enter new revision id : ')

    # Benchmark label from vcs info.
#    if len(vcs) == 1:
#        benchmark = vcs.popitem()[1]
#    else:
#        benchmark = []
#        for (key, code_id) in vcs.items():
#            benchmark.append('%s-%s' % (key, code_id))
#        benchmark = '.'.join(benchmark)

    # HACK
    benchmark = code_id

    # Create benchmarks.
    for test in tests:
        test.create_new_benchmarks(benchmark, copy_files_since)

    # update userconfig file.
    if userconfig:
        config = testcode2.compatibility.configparser.RawConfigParser()
        config.optionxform = str # Case sensitive file.
        config.read(userconfig)
        if insert_id:
            ids = config.get('user', 'benchmark').split()
            if benchmark in ids:
                ids.remove(benchmark)
            ids.insert(0, benchmark)
            benchmark = ' '.join(ids)
        if len(benchmark.split()) > 1:
            print('Setting new benchmarks in userconfig to be: %s.' %
                    (benchmark))
        else:
            print('Setting new benchmark in userconfig to be: %s.' %
                    (benchmark))
        config.set('user', 'benchmark', benchmark)
        userconfig = open(userconfig, 'w')
        config.write(userconfig)
        userconfig.close()
Example #4
0
def make_benchmarks(test_programs, tests, userconfig, copy_files_since,
        insert_id=False):
    '''Make a new set of benchmarks.

test_programs: dictionary of test programs.
tests: list of tests.
userconfig: path to the userconfig file.  This is updated with the new benchmark id.
copy_files_since: files produced since the timestamp (in seconds since the
    epoch) are copied to the testcode_data subdirectory in each test.
insert_id: insert the new benchmark id into the existing list of benchmark ids in
    userconfig if True, otherwise overwrite the existing benchmark ids with the
    new benchmark id (default).
'''

    # All tests passed?
    statuses = [test.get_status() for test in tests]
    npassed = sum(status['passed'] for status in statuses)
    nran = sum(status['ran'] for status in statuses)
    if npassed != nran:
        ans = ''
        print('Not all tests passed.')
        while ans != 'y' and ans != 'n':
            ans = testcode2.compatibility.compat_input(
                                                'Create new benchmarks? [y/n] ')
        if ans != 'y':
            return None

    # Get vcs info.
#    vcs = {}
#    for (key, program) in test_programs.items():
#        if program.vcs and program.vcs.vcs:
#            vcs[key] = program.vcs.get_code_id()
#        else:
#            print('Program not under (known) version control system')
#            vcs[key] = testcode2.compatibility.compat_input(
#                    'Enter revision id for %s: ' % (key))

    # HACK
    code_id = testcode2.compatibility.compat_input(
                    'Enter new revision id : ')

    # Benchmark label from vcs info.
#    if len(vcs) == 1:
#        benchmark = vcs.popitem()[1]
#    else:
#        benchmark = []
#        for (key, code_id) in vcs.items():
#            benchmark.append('%s-%s' % (key, code_id))
#        benchmark = '.'.join(benchmark)

    # HACK
    benchmark = code_id

    # Create benchmarks.
    for test in tests:
        test.create_new_benchmarks(benchmark, copy_files_since)

    # update userconfig file.
    if userconfig:
        config = testcode2.compatibility.configparser.RawConfigParser()
        config.optionxform = str # Case sensitive file.
        config.read(userconfig)
        if insert_id:
            ids = config.get('user', 'benchmark').split()
            if benchmark in ids:
                ids.remove(benchmark)
            ids.insert(0, benchmark)
            benchmark = ' '.join(ids)
        if len(benchmark.split()) > 1:
            print(('Setting new benchmarks in userconfig to be: %s.' %
                    (benchmark)))
        else:
            print(('Setting new benchmark in userconfig to be: %s.' %
                    (benchmark)))
        config.set('user', 'benchmark', benchmark)
        userconfig = open(userconfig, 'w')
        config.write(userconfig)
        userconfig.close()