rm -rf .lake/build
lake build

for f in LeanCheckerTests/*.lean; do
    module="LeanCheckerTests.$(basename "$f" .lean)"
    # Check for --fresh mode test
    if [[ -f "$f.fresh" ]]; then
        capture_only "$f" \
          lake env leanchecker --fresh "$module"
        check_exit_is_fail
        check_out_file
    # Check for normal mode test
    elif [[ -f "$f.out.expected" ]]; then
        # Expect failure with specific output
        capture_only "$f" \
          lake env leanchecker "$module"
        check_exit_is_fail
        check_out_file
    else
        # No expected output files - expect success (exit 0)
        run lake env leanchecker "$module"
    fi
done
