def test_passed(self): e = Executor() g = make_test( "test_core.cc", DUMMYPATH, [ "[==========] Running 1 test from 1 test case.", "[----------] Global test environment set-up.", "[----------] 1 test from core", "[ RUN ] core.ok", "[ OK ] core.ok (0 ms)", "[----------] 1 test from core (1 ms total)", "", "[----------] Global test environment tear-down", "[==========] 1 test from 1 test case ran. (1 ms total)", "[ PASSED ] 1 test.", ], ) results = e.test([g]) assert results == { "total_runtime": 0.001, "total_passed": 1, "total_failed": 0, "failures": [], }
def test_filter(self): e = Executor() g = make_test( "test_core.cc", DUMMYPATH, [ "[==========] Running 1 test from 1 test case.", "[----------] Global test environment set-up.", "[----------] 1 test from core", "[ RUN ] core.ok", "test_core.cc:12: Failure", "Value of: 2", "Expected: ok()", "Which is: 42", "[ FAILED ] core.ok (0 ms)", "[----------] 1 test from core (0 ms total)", "", "[----------] Global test environment tear-down", "[==========] 1 test from 1 test case ran. (0 ms total)", "[ PASSED ] 0 tests.", "[ FAILED ] 1 test, listed below:", "[ FAILED ] core.ok", "", " 1 FAILED TEST", ], ) e.test([g]) assert e.test_filter() == {DUMMYPATH: ["core.ok"]} e.clear_filter() assert e.test_filter() == {}
def test_mixed_results(self): e = Executor() g = make_test( "test_core.cc", DUMMYPATH, [ "[==========] Running 2 tests from 1 test case.", "[----------] Global test environment set-up.", "[----------] 2 test from core", "[ RUN ] core.test", "[ OK ] core.test (0 ms)", "[ RUN ] core.ok", "test_core.cc:12: Failure", "Value of: 2", "Expected: ok()", "Which is: 42", "[ FAILED ] core.ok (0 ms)", "[----------] 2 tests from core (1 ms total)", "", "[----------] Global test environment tear-down", "[==========] 2 tests from 1 test case ran. (1 ms total)", "[ PASSED ] 1 test.", "[ FAILED ] 1 test, listed below:", "[ FAILED ] core.ok", "", " 1 FAILED TEST", ], ) results = e.test([g]) assert results == { "total_runtime": 0.001, "total_passed": 1, "total_failed": 1, "failures": [ [ "core.ok", [ "test_core.cc:12: Failure", "Value of: 2", "Expected: ok()", "Which is: 42", ], [], FAILED, ] ], }
def test_filter(self): e = Executor() g = make_test('test_core.cc', DUMMYPATH, [ '[==========] Running 1 test from 1 test case.', '[----------] Global test environment set-up.', '[----------] 1 test from core', '[ RUN ] core.ok', 'test_core.cc:12: Failure', 'Value of: 2', 'Expected: ok()', 'Which is: 42', '[ FAILED ] core.ok (0 ms)', '[----------] 1 test from core (0 ms total)', '', '[----------] Global test environment tear-down', '[==========] 1 test from 1 test case ran. (0 ms total)', '[ PASSED ] 0 tests.', '[ FAILED ] 1 test, listed below:', '[ FAILED ] core.ok', '', ' 1 FAILED TEST', ]) e.test([g]) assert e.test_filter() == {DUMMYPATH: ['core.ok']} e.clear_filter() assert e.test_filter() == {}
def test_windows_seh_crash(self): e = Executor() g = make_test( "test_core.cc", DUMMYPATH, [ "[==========] Running 1 test from 1 test case.", "[----------] Global test environment set-up.", "[----------] 1 test from core", "[ RUN ] core.ok", "unknown file: error: SEH exception with code 0xc0000005 thrown in" " the test body", "[ FAILED ] core.ok (0 ms)", "[----------] 1 test from core (1 ms total)", "", "[----------] Global test environment tear-down", "[==========] 1 test from 1 test case ran. (1 ms total)", "[ PASSED ] 0 tests.", "[ FAILED ] 1 test, listed below:", "[ FAILED ] core.ok", "", " 1 FAILED TEST", ], ) results = e.test([g]) assert results == { "total_runtime": 0.001, "total_passed": 0, "total_failed": 1, "failures": [ [ "core.ok", [ "SEH Exception", "unknown file: error: SEH exception with code " "0xc0000005 thrown in the test body", ], [], CRASHED, ] ], }
def test_mixed_results(self): e = Executor() g = make_test('test_core.cc', DUMMYPATH, [ '[==========] Running 2 tests from 1 test case.', '[----------] Global test environment set-up.', '[----------] 2 test from core', '[ RUN ] core.test', '[ OK ] core.test (0 ms)', '[ RUN ] core.ok', 'test_core.cc:12: Failure', 'Value of: 2', 'Expected: ok()', 'Which is: 42', '[ FAILED ] core.ok (0 ms)', '[----------] 2 tests from core (1 ms total)', '', '[----------] Global test environment tear-down', '[==========] 2 tests from 1 test case ran. (1 ms total)', '[ PASSED ] 1 test.', '[ FAILED ] 1 test, listed below:', '[ FAILED ] core.ok', '', ' 1 FAILED TEST', ]) results = e.test([g]) assert results == { 'total_runtime': 0.001, 'total_passed': 1, 'total_failed': 1, 'failures': [[ 'core.ok', [ 'test_core.cc:12: Failure', 'Value of: 2', 'Expected: ok()', 'Which is: 42', ], [], FAILED ]] }
def test_passed(self): e = Executor() g = make_test('test_core.cc', DUMMYPATH, [ '[==========] Running 1 test from 1 test case.', '[----------] Global test environment set-up.', '[----------] 1 test from core', '[ RUN ] core.ok', '[ OK ] core.ok (0 ms)', '[----------] 1 test from core (1 ms total)', '', '[----------] Global test environment tear-down', '[==========] 1 test from 1 test case ran. (1 ms total)', '[ PASSED ] 1 test.', ]) results = e.test([g]) assert results == { 'total_runtime': 0.001, 'total_passed': 1, 'total_failed': 0, 'failures': [] }
def test_windows_seh_crash(self): e = Executor() g = make_test('test_core.cc', DUMMYPATH, [ '[==========] Running 1 test from 1 test case.', '[----------] Global test environment set-up.', '[----------] 1 test from core', '[ RUN ] core.ok', 'unknown file: error: SEH exception with code 0xc0000005 thrown in' ' the test body', '[ FAILED ] core.ok (0 ms)', '[----------] 1 test from core (1 ms total)', '', '[----------] Global test environment tear-down', '[==========] 1 test from 1 test case ran. (1 ms total)', '[ PASSED ] 0 tests.', '[ FAILED ] 1 test, listed below:', '[ FAILED ] core.ok', '', ' 1 FAILED TEST', ]) results = e.test([g]) assert results == { 'total_runtime': 0.001, 'total_passed': 0, 'total_failed': 1, 'failures': [[ 'core.ok', [ 'SEH Exception', 'unknown file: error: SEH exception with code ' '0xc0000005 thrown in the test body', ], [], CRASHED ]] }
def create_monitor(watch_path=None, patterns=None, **kwargs): """Creates a monitor and its subordinate objects. By default, one reporter object is created to output to the terminal. An optional IRC reporter may be created if irc_server is provided. :param watch_path: (optional) the root of the source tree, either relative or absolute. If not provided, the current working directory is assumed to be the root of the source tree. :param patterns: (optional) a list of file names or patterns that identify the files to be tracked. By default, all files are tracked unless this list is specified and not empty. :param build_path: (optional) the desired build path. May be relative. If not provided, it will be generated from the watch path. :param generator: (optional) the cmake build system generator :param defines: (optional) list of var=val strings for CMake's -D option :param irc_server: (optional) the IRC server host if an IRC reporter is required. :param irc_port (optional) the IRC server port. Has no meaning without irc_server. :param irc_channel (optional) the IRC channel to join once connected. Has no meaning without irc_server. :param irc_nick (optional) the IRC nickname to use once connected. Has no meaning without irc_server. """ build_config = kwargs.pop("config", None) generator = kwargs.pop("generator", None) watch_path = make_watch_path(watch_path) build_path = make_build_path(kwargs.pop("build_path", None), watch_path, build_config) term = Terminal(stream=sys.stdout) exclusions = kwargs.pop("exclude", []) watcher = Watcher(watch_path, build_path, patterns, exclusions, term) run_tests = kwargs.pop("test", False) defines = kwargs.pop("define", []) clean = kwargs.pop("clean", False) if run_tests: if defines is None: defines = [] defines.append("ENABLE_TESTS=ON") builder = create_builder(watch_path, build_path, generator, build_config, defines, term, clean) reporters = [TerminalReporter(watch_path, build_path)] irc_server = kwargs.pop("irc_server", None) if irc_server: irc = IRCClient( (kwargs.pop("irc_channel", None) or "#{}-{}".format(__progname__, os.path.basename(watch_path))), (kwargs.pop("irc_nick", None) or "{}_{}".format(platform.system(), build_config)), irc_server, kwargs.pop("irc_port", None), ) # print('{}@{}:{}/{}'.format( # irc._nickname, irc.server.host, irc.server.port, irc.channel) # ) r = IRCReporter(irc) reporters.append(r) executor = Executor() if run_tests else None return Monitor(watcher, builder, executor, reporters)