def test():
    from TestRunner import TestRunner

    stages = ["LEG", "DP"]
    metrics = ["HPWL", "TNS", "WNS"]
    experiment = BaseExperiment("HippocrateDP experiment", "HippocrateDP.cfg",
                                "IWLS_GP_Hippocrate.list", metrics, stages)

    testRunner = TestRunner()
    testRunner.Append(experiment)
    testRunner.Run()
Exemple #2
0
def testmain(info=None, start=1, testMode=None):
    """ main for test runner """
    daemon = None
    test_list = []

    # load test list
    if len(sys.argv) <= start:
        testFile = info.get_config('test_list', '', "scripts/test_list.yml")
        print("no test files given, using %s" % testFile)
        with open(testFile, 'r') as fd:
            test_load = load(fd, Loader=Loader)
        test_list = test_load['test_list']
    else:
        for k in range(start, len(sys.argv)):
            test_list.append(sys.argv[k])
    print("Test list: " + str(test_list))
    # add the multi instance module name to the Maloo test set name
    if len(test_list) > 1:
        info.set_config('setDirectiveFromConfig', 'addTestSetName', "yes")
    # load and start daemon if required
    use_daemon = info.get_config("use_daemon", "")
    if use_daemon:
        daemon = import_daemon(use_daemon, info)
        rc = daemon.launch_process()
        if rc:
            return rc
    # load test object and start the testing
    if testMode == "littleChief":
        tester = MultiRunner(info, test_list)
    else:
        tester = TestRunner(info, test_list)
    rc = tester.run_testcases()
    if daemon:
        daemon.stop_process()
    if rc == 0:
        print("All tests passed\n")
    else:
        print("This run had test failures\n")
    return rc
Exemple #3
0
def runtest(config: Config, workdir: Path, results_dir: Path):
    print(f"========== Grading {workdir.name}")

    (workdir / config["output_dir"]).mkdir(exist_ok=True, parents=True)
    secret_files = []
    with (results_dir / f"{workdir.name}.txt").open("w", encoding="utf-8") as logfile:
        if "build" in config:
            logfile.write(utils.box_text("Build Step") + "\n")
            # copy files from project root to build location
            if "required_files" in config["build"]:
                for file in config["build"]["required_files"]:
                    (workdir / file["dest"]).mkdir(exist_ok=True, parents=True)
                    try:
                        copy(
                            Path(".config") / file["file"], Path(workdir / file["dest"])
                        )
                    except FileNotFoundError as ex:
                        raise click.FileError(ex.filename, "are you sure it exists?")
                    if file.get("secret"):
                        secret_files.append(Path(workdir / file["dest"] / file["file"]))

            if "commands" in config["build"]:
                for command in config["build"]["commands"]:
                    br = TestResult(test_type="build", cmd=command)
                    command = shlex.split(command)
                    br.retval, br.stdout, br.stderr = utils.run_command(
                        command, cwd=workdir
                    )
                    logfile.write(br.log(config["output"]["build"]))

        # loop through and run all tests
        test_runner = TestRunner(logfile, workdir, config)
        test_runner.run_all()
        test_runner.log()

        for file in secret_files:
            file.unlink()
Exemple #4
0
from Algorithms import AlgorithmType
from TestRunner import TestRunner
from Utils import File

dir_path = File.get_current_dir()  # Get current dir
File.change_dir(
    dir_path)  # Change the working directory so we can read the file

ncolors, colours = File.read_file(
    'colours.txt')  # Total number of colours and list of colours

tr = TestRunner(colours)

# Requirement 1
tr.add_run_configuration(AlgorithmType.GREEDY_CONSTRUCTIVE, 100, 30)
tr.add_run_configuration(AlgorithmType.GREEDY_CONSTRUCTIVE, 500, 30)

# Requirement 2
tr.add_run_configuration(AlgorithmType.HILL_CLIMBING, 100, 30)
tr.add_run_configuration(AlgorithmType.HILL_CLIMBING, 500, 30)

# Requirement 3
# #   - 30 starts
# #   - Compute mean, median, STD
tr.add_run_configuration(AlgorithmType.MULTI_START_HC, 100, 30)
tr.add_run_configuration(AlgorithmType.MULTI_START_HC, 500, 30)
#
# # Requirement 4
# #   - 30 starts
# #   - Compute mean, median, STD
# IMPORTANT: Time required for DELTA SORT: ~16 minutes. #
#Client

from TestRunner import TestRunner

if __name__ == '__main__':
    testRunner = TestRunner()
    testRunner.runAll()
Exemple #6
0
from sys import argv
from TestRunner import TestRunner
"""
Please implement TestRunner class (check requirements in TestRunner.py). 
It should get module name as input and execute all methods from this module that name starts from 'test_'

Please use TestClass from test_class.py as an example of this test class.

So for this test class execution should look like this:

/Users/avolkov/work/virtual_env_37/bin/python3.7 run.py suites.test_class.TestClass
pass: 2 |error: 1 |fail: 1 |skipped: 1 

Process finished with exit code 0
"""

if __name__ == '__main__':
    file_name = argv[0]
    tr = TestRunner(file_name)
    tr.process_tests()
    print(tr.get_result())
Exemple #7
0
import os
from TestRunner import TestRunner
import unittest


class MyTestCase(unittest.TestCase):
    def test_A(self):
        """A simple test that should PASS."""
        self.assertTrue(True)

    def test_B(self):
        """A simple test FAILURE."""
        self.assertFalse(True)

    @staticmethod
    def test_C():
        """A simple ERROR raising test."""
        assert 1 + 'a' == 32


if __name__ == '__main__':
    test_suite = unittest.TestLoader().loadTestsFromTestCase(MyTestCase)
    fp = os.path.join(os.path.dirname(__file__), "test.html")
    runner = TestRunner(stream=fp,
                        title="My test report sample",
                        description="This is a sample test case.")
    runner.run(test_suite)
from TestRunner import TestRunner
from scipy.optimize import minimize
import numpy as np

test_runner = TestRunner()
test_runner.optimise(maxiter=2000)
test_runner.draw_plot()