if __package__ is None or __package__ == "": from Fuzzer import ProgramRunner else: from .Fuzzer import ProgramRunner if __name__ == "__main__": f = GrammarCoverageFuzzer(autopep8_grammar, max_nonterminals=5) for i in range(20): invocation = "autopep8" + f.fuzz() print("$ " + invocation) args = invocation.split() autopep8 = ProgramRunner(args) result, outcome = autopep8.run() if result.stderr != "": print(result.stderr, end="") if __name__ == "__main__": print(open("foo.py").read(), end="") import os if __name__ == "__main__": os.remove("foo.py") # ## Classes for Fuzzing Configuration Options
LS_EBNF_GRAMMAR = { '<start>': ['-<options>'], '<options>': ['<option>*'], '<option>': srange("ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1") } if __name__ == "__main__": assert is_valid_grammar(LS_EBNF_GRAMMAR) LS_GRAMMAR = convert_ebnf_grammar(LS_EBNF_GRAMMAR) if __package__ is None or __package__ == "": from Fuzzer import ProgramRunner else: from .Fuzzer import ProgramRunner if __name__ == "__main__": f = GrammarCoverageFuzzer(LS_GRAMMAR, max_nonterminals=3) while len(f.max_expansion_coverage() - f.expansion_coverage()) > 0: invocation = f.fuzz() print("ls", invocation, end="; ") args = invocation.split() ls = ProgramRunner(["ls"] + args) ls.run() print() # ### Exercise 2: Caching if __name__ == "__main__": print('\n### Exercise 2: Caching')