| 123456789101112131415161718192021222324252627282930313233343536373839 |
- """Reviewer-owned behavioral checks. Run ONLY inside the documented isolated container."""
- import importlib.util
- import json
- import signal
- import sys
- CASES = [
- ([" Alpha ", "beta", "ALPHA", ""], ["alpha", "beta"]),
- ([None, 3, " "], []),
- (["A", "B", "a", " b "], ["a", "b"]),
- (["x", False, " X "], ["x"]),
- ([], []),
- ([{}, [], True, 0, 1.2], []),
- ([" B ", "a", "b", "A", "c"], ["b", "a", "c"]),
- (["\tALPHA\n", "alpha", "\n"], ["alpha"]),
- (["Ä", "ä", "中文", " 中文 "], ["ä", "中文"]),
- ]
- def main():
- signal.signal(signal.SIGALRM, lambda *_: (_ for _ in ()).throw(TimeoutError("time limit")))
- signal.alarm(10)
- spec = importlib.util.spec_from_file_location("candidate", sys.argv[1])
- module = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(module)
- results = []
- for index, (values, expected) in enumerate(CASES):
- try:
- actual = module.normalize_labels(values)
- results.append({'case': index + 1, 'passed': isinstance(actual, list) and actual == expected})
- except Exception as error:
- results.append({'case': index + 1, 'passed': False, 'error': type(error).__name__})
- passed = sum(item['passed'] for item in results)
- print(json.dumps({'suite': 'reviewer-independent-v1', 'passed': passed, 'total': len(CASES), 'checks': results}))
- return 0 if passed == len(CASES) else 1
- if __name__ == '__main__':
- raise SystemExit(main())
|