Add an option to extend the compiled code after each reducing step
This let me add a test function which called a method in the reduced
code, preventing creduce from eliminating everything entirely.
@@ -83,6 +83,10 @@ reducing.add_argument(
action="store_false",
dest="rustc",
help="Do not attempt to compile the emitted bindings with `rustc`.")
+reducing.add_argument(
+ "--extra-compile-file",
+ type=str,
+ help="")
reducing.add_argument(
"--expect-compile-fail",
action="store_true",
@@ -221,6 +225,10 @@ def run_bindgen(args, bindings):
raise ExitOne()
def run_rustc(args, bindings, test_exe):
+ if args.extra_compile_file:
+ with open(bindings, mode="a") as outfile:
+ with open(args.extra_compile_file, mode="r") as infile:
+ outfile.write(infile.read())
child = run(
["rustc", "--crate-type", "lib", "--test", "-o", test_exe, bindings],
stdout=subprocess.PIPE,
