CodyKochmann / battle_tested

Fully automated python fuzzer built to test if code actually is production ready in seconds.
MIT License
103 stars 5 forks source link

Use co-routines to organize different tests. #40

Closed CodyKochmann closed 5 years ago

CodyKochmann commented 5 years ago

This is the basic design of the new test runner to allow better organization of different test input types.

def test_worker(fn: Callable, test_inputs: Iterable[Tuple], shared_db: GraphDB):
    for test_number, args in enumerate(test_inputs):
        try:
            # run the test
            out = fn(*args)
        except Exception as ex:
            # record the crash
            success = False
            shared_db(fn).raised = ex 
            shared_db(ex).caused_by = args
        else:
            # record the success
            success = True
            shared_db(fn).succesfull_io = (args, out)
        finally:
            # send back the success status and
            # pause until another test can be ran
            yield test_number, success
CodyKochmann commented 5 years ago

This has been reworked and implemented by yielding defaultdicts containing the fuzz results in a 100% pipeline architecture in the add-lightness branch.