#!/usr/bin/env python3
"""Control: replace one language's stripper with a naive regex and let the
real oracle judge each file. Usage: naive.py <oss-strip-comments.py> <ext> <regex> <file>..."""
import importlib.util, pathlib, re, sys
spec = importlib.util.spec_from_file_location("strip", sys.argv[1])
s = importlib.util.module_from_spec(spec); spec.loader.exec_module(s)
ext, rx = sys.argv[2], re.compile(sys.argv[3], re.M)
s.STRIPPERS[ext] = (lambda t: rx.sub("", t), s.STRIPPERS[ext][1])
caught = 0
for f in map(pathlib.Path, sys.argv[4:]):
    try:
        s.strip_text(f, f.read_text())
        print(f"passed  {f}")
    except SystemExit as e:
        caught += 1
        print(e)
print(f"{caught} of {len(sys.argv) - 4} caught")
