chore: improve how test suite interacts with stages (#12913)

The tests need to run with certain environment variables set that only
cmake really knows and that differ between stages. Cmake could just set
the variables directly when running the tests and benchmarks, but that
would leave no good way to manually run a single benchmark. So cmake
generates some stage-specific scripts instead that set the required
environment variables.

Previously, those scripts were sourced directly by the individual
`run_*` scripts, so the env scripts of different stages would overwrite
each other. This PR changes the setup so they can instead be generated
next to each other. This also simplifies the `run_*` scripts themselves
a bit, and makes `tests/bench/build` less of a hack.
This commit is contained in:
Garmelon
2026-03-16 16:20:03 +01:00
committed by GitHub
parent 133fd016b4
commit 49715fe63c
68 changed files with 96 additions and 258 deletions

View File

@@ -20,7 +20,8 @@ CTEST_PARALLEL_LEVEL="$(nproc)" CTEST_OUTPUT_ON_FAILURE=1 \
make -C build/release -j "$(nproc)" test ARGS='--rerun-failed' make -C build/release -j "$(nproc)" test ARGS='--rerun-failed'
# Single test from tests/foo/bar/ (quick check during development) # Single test from tests/foo/bar/ (quick check during development)
cd tests/foo/bar && ./run_test example_test.lean CTEST_PARALLEL_LEVEL="$(nproc)" CTEST_OUTPUT_ON_FAILURE=1 \
make -C build/release -j "$(nproc)" test ARGS=-R testname'
``` ```
## Testing stage 2 ## Testing stage 2

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../../tests/env_test.sh
leanmake --always-make bin leanmake --always-make bin
capture ./build/bin/test hello world capture ./build/bin/test hello world

3
doc/examples/run_test → doc/examples/run_test.sh Executable file → Normal file
View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../tests/env_test.sh
capture_only "$1" \ capture_only "$1" \
lean -Dlinter.all=false "$1" lean -Dlinter.all=false "$1"
check_exit_is_success check_exit_is_success

3
tests/.gitignore vendored
View File

@@ -1,6 +1,5 @@
# Generated by cmake # Generated by cmake
/env_test.sh /with_*_env.sh
/env_bench.sh
# Created by test suite # Created by test suite
*.out.produced *.out.produced

View File

@@ -38,12 +38,15 @@ string(APPEND TEST_VARS " LEANC_OPTS='${LEANC_OPTS}'")
# LEANC_OPTS in CXX is necessary for macOS c++ to find its headers # LEANC_OPTS in CXX is necessary for macOS c++ to find its headers
string(APPEND TEST_VARS " CXX='${CMAKE_CXX_COMPILER} ${LEANC_OPTS}'") string(APPEND TEST_VARS " CXX='${CMAKE_CXX_COMPILER} ${LEANC_OPTS}'")
set(WITH_TEST_ENV "${CMAKE_CURRENT_SOURCE_DIR}/with_stage${STAGE}_test_env.sh")
set(WITH_BENCH_ENV "${CMAKE_CURRENT_SOURCE_DIR}/with_stage${STAGE}_bench_env.sh")
string(APPEND TEST_VARS " TEST_BENCH=") string(APPEND TEST_VARS " TEST_BENCH=")
configure_file(env.sh.in "${CMAKE_CURRENT_SOURCE_DIR}/env_test.sh") configure_file(with_env.sh.in "${WITH_TEST_ENV}")
block() block()
string(APPEND TEST_VARS " TEST_BENCH=1") string(APPEND TEST_VARS " TEST_BENCH=1")
configure_file(env.sh.in "${CMAKE_CURRENT_SOURCE_DIR}/env_bench.sh") configure_file(with_env.sh.in "${WITH_BENCH_ENV}")
endblock() endblock()
###################### ######################
@@ -69,8 +72,8 @@ function(glob_except OUT DIR GLOB)
endfunction() endfunction()
function(check_test_bench_scripts DIR) function(check_test_bench_scripts DIR)
set(RUN_TEST "${DIR}/run_test") set(RUN_TEST "${DIR}/run_test.sh")
set(RUN_BENCH "${DIR}/run_bench") set(RUN_BENCH "${DIR}/run_bench.sh")
set(RUN_TEST_EXISTS FALSE) set(RUN_TEST_EXISTS FALSE)
set(RUN_BENCH_EXISTS FALSE) set(RUN_BENCH_EXISTS FALSE)
@@ -125,10 +128,10 @@ endfunction()
# represents a separate test (or benchmark). The directory may also contain # represents a separate test (or benchmark). The directory may also contain
# additional files or subdirectories required by the individual test files. # additional files or subdirectories required by the individual test files.
# #
# If a run_test script is present, each test file will be added as a test. Tests # If a run_test.sh script is present, each test file will be added as a test. Tests
# can be disabled on a per-file basis by creating a `<file>.no_test` file. # can be disabled on a per-file basis by creating a `<file>.no_test` file.
# #
# If a run_bench script is present, each test file will be added as a benchmark. # If a run_bench.sh script is present, each test file will be added as a benchmark.
# Benchmarks can be disabled on a per-file basis by creating a `<file>.no_bench` # Benchmarks can be disabled on a per-file basis by creating a `<file>.no_bench`
# file. CMake expects the bench script to produce a `<file>.measurements.jsonl` # file. CMake expects the bench script to produce a `<file>.measurements.jsonl`
# file next to the test file. The individual measurements will be combined into # file next to the test file. The individual measurements will be combined into
@@ -160,7 +163,7 @@ function(add_test_pile DIR GLOB)
NAME "${FILE_IN_SOURCE_DIR}" NAME "${FILE_IN_SOURCE_DIR}"
WORKING_DIRECTORY "${DIR}" WORKING_DIRECTORY "${DIR}"
# On Windows, we can't call the file directly, hence we always use bash. # On Windows, we can't call the file directly, hence we always use bash.
COMMAND bash "${RUN_TEST}" "${FILE_IN_DIR}" COMMAND bash "${WITH_TEST_ENV}" "${RUN_TEST}" "${FILE_IN_DIR}"
) )
endif() endif()
@@ -172,7 +175,7 @@ function(add_test_pile DIR GLOB)
WORKING_DIRECTORY "${DIR}" WORKING_DIRECTORY "${DIR}"
COMMAND "${CMAKE_COMMAND}" -E remove -f "${MEASUREMENTS_FILE}" COMMAND "${CMAKE_COMMAND}" -E remove -f "${MEASUREMENTS_FILE}"
# On Windows, we can't call the file directly, hence we always use bash. # On Windows, we can't call the file directly, hence we always use bash.
COMMAND bash "${RUN_BENCH}" "${FILE_IN_DIR}" COMMAND bash "${WITH_BENCH_ENV}" "${RUN_BENCH}" "${FILE_IN_DIR}"
) )
endif() endif()
endforeach() endforeach()
@@ -202,7 +205,7 @@ function(add_test_dir DIR)
NAME "${DIR_IN_SOURCE_DIR}" NAME "${DIR_IN_SOURCE_DIR}"
WORKING_DIRECTORY "${DIR}" WORKING_DIRECTORY "${DIR}"
# On Windows, we can't call the file directly, hence we always use bash. # On Windows, we can't call the file directly, hence we always use bash.
COMMAND bash "${RUN_TEST}" COMMAND bash "${WITH_TEST_ENV}" "${RUN_TEST}"
) )
endif() endif()
@@ -216,7 +219,7 @@ function(add_test_dir DIR)
WORKING_DIRECTORY "${DIR}" WORKING_DIRECTORY "${DIR}"
COMMAND "${CMAKE_COMMAND}" -E remove -f "${MEASUREMENTS_FILE}" COMMAND "${CMAKE_COMMAND}" -E remove -f "${MEASUREMENTS_FILE}"
# On Windows, we can't call the file directly, hence we always use bash. # On Windows, we can't call the file directly, hence we always use bash.
COMMAND bash "${RUN_BENCH}" COMMAND bash "${WITH_BENCH_ENV}" "${RUN_BENCH}"
) )
endif() endif()
endfunction() endfunction()

View File

@@ -4,11 +4,11 @@ This directory contains the lean test and benchmark suite.
The test suite consists of two types of directories: Test directories and test piles. The test suite consists of two types of directories: Test directories and test piles.
A **test directory** is a directory containing a `run_test` and/or a `run_bench` script. A **test directory** is a directory containing a `run_test.sh` and/or a `run_bench.sh` script.
It represents a single test or benchmark, depending on which script is present. It represents a single test or benchmark, depending on which script is present.
The run scripts are executed once with their working directory set to the test directory. The run scripts are executed once with their working directory set to the test directory.
A **test pile** is also a directory containing a `run_test` and/or a `run_bench` script. A **test pile** is also a directory containing a `run_test.sh` and/or a `run_bench.sh` script.
Here however, each file of a directory-specific extension (usually `.lean`) represents a single test or benchmark. Here however, each file of a directory-specific extension (usually `.lean`) represents a single test or benchmark.
The run scripts are executed once for each test file with their working directory set to the pile directory. The run scripts are executed once for each test file with their working directory set to the pile directory.
Often, additional supplementary files are placed next to the test files and interpreted by the run scripts. Often, additional supplementary files are placed next to the test files and interpreted by the run scripts.
@@ -70,11 +70,19 @@ CTEST_PARALLEL_LEVEL="$(nproc)" CTEST_OUTPUT_ON_FAILURE=1 \
make -C build/release -j "$(nproc)" test ARGS="--rerun-failed" make -C build/release -j "$(nproc)" test ARGS="--rerun-failed"
``` ```
Run an individual test by `cd`-ing into its directory and then using Run an individual test using one of these commands:
```sh ```sh
./run_test # in a test directory CTEST_PARALLEL_LEVEL="$(nproc)" CTEST_OUTPUT_ON_FAILURE=1 \
./run_test testfile # in a test pile make -C build/release -j "$(nproc)" test ARGS="-R <regex>"
# For a specific stage
CTEST_PARALLEL_LEVEL="$(nproc)" CTEST_OUTPUT_ON_FAILURE=1 \
make -C build/release/stage1 -j "$(nproc)" test ARGS="-R <regex>"
# Manually, without ctest
tests/with_stage1_test_env.sh path/to/test/directory/run_test.sh
tests/with_stage1_test_env.sh path/to/test/pile/run_test.sh testfile
``` ```
## How to run the bench suite? ## How to run the bench suite?
@@ -95,11 +103,11 @@ make -C build/release -j "$(nproc)" bench-part2 # produces tests/part2.measureme
Make sure not to specify `-j "$(nproc)"` when running the bench suite manually inside `build/release/stage<n>`. Make sure not to specify `-j "$(nproc)"` when running the bench suite manually inside `build/release/stage<n>`.
Run an individual benchmark by `cd`-ing into its directory and then using Run an individual benchmark manually using
```sh ```sh
./run_bench # in a test directory tests/with_stage1_bench_env.sh path/to/test/directory/run_bench.sh
./run_bench testfile # in a test pile tests/with_stage1_bench_env.sh path/to/test/pile/run_bench.sh testfile
``` ```
## How to write a test? ## How to write a test?
@@ -120,7 +128,7 @@ If your test should be part of one of the existing test directories:
Otherwise, create a new test directory or pile: Otherwise, create a new test directory or pile:
1. Decide on a place to put the new directory. 1. Decide on a place to put the new directory.
2. Write a `run_test` and/or `run_bench` script. 2. Write a `run_test.sh` and/or `run_bench.sh` script.
3. Add the directory to the [`CMakeLists.txt`](CMakeLists.txt) file, 3. Add the directory to the [`CMakeLists.txt`](CMakeLists.txt) file,
next to the other tests near the bottom. next to the other tests near the bottom.
4. Document the new directory in this readme file 4. Document the new directory in this readme file
@@ -130,7 +138,7 @@ Otherwise, create a new test directory or pile:
## How to write a benchmark? ## How to write a benchmark?
When writing a benchmark, consider that most benchmarks are also executed as tests. When writing a benchmark, consider that most benchmarks are also executed as tests.
You can check that this is the case if a `run_test` script exists next to the `run_bench` script in the directory. You can check that this is the case if a `run_test.sh` script exists next to the `run_bench.sh` script in the directory.
When run as benchmark, the problem instance should be large enough to result in reliable measurements. When run as benchmark, the problem instance should be large enough to result in reliable measurements.
When run as test, the problem instance should be as small as possible, but large enough to still test the different code paths. When run as test, the problem instance should be as small as possible, but large enough to still test the different code paths.
@@ -167,33 +175,29 @@ Some test directories or test piles strip or modify certain flaky or nondetermin
## How to write a test or bench run script? ## How to write a test or bench run script?
Test and bench scripts must be named `run_test` and `run_bench` respectively. Test and bench scripts must be named `run_test.sh` and `run_bench.sh` respectively.
They must be executable and start with the shebang `#!/usr/bin/env bash`. They are sourced by the `with_*_env.sh` script,
Immediately afterwards, they must source `env_test.sh` or `env_bench.sh` respectively which provides a set of environment variables and definitions.
using a relative path. Because of this, they require no shebang and should not be executable.
The `env_*.sh` files set some build related environment variables, The most notable environment variables are:
plus a set of test suite related environment variables
document at the top of [`CMakeLists.txt`](CMakeLists.txt).
The most notable ones are:
- `TEST_DIR`: Absolute path to the `tests` directory. - `TEST_DIR`: Absolute path to the `tests` directory.
- `SCRIPT_DIR`: Absolute path to the `script` directory. - `SCRIPT_DIR`: Absolute path to the `script` directory.
- `TEST_BENCH`: Set to `1` if we're currently executing a benchmark, unset otherwise. - `TEST_BENCH`: Set to `1` if we're currently executing a benchmark, unset otherwise.
It also sources `"$TEST_DIR/util.sh"`, The definitions come from `util.sh`,
which provides a few utility functions and also uses `set` to set sensible bash defaults. which provides a few utility functions and also uses `set` to set sensible bash defaults.
See `util.sh` for the available utility functions.
The run scripts are always executed with their working directory set to their surrounding directory. The run scripts are always executed with their working directory set to their surrounding directory.
Inside a test pile, `run_test` and `run_bench` receive Inside a test pile, `run_test.sh` and `run_bench.sh` receive
a relative path to the file under test as their first (and only) argument. a relative path to the file under test as their first (and only) argument.
Inside a test directory, they receive no arguments. Inside a test directory, they receive no arguments.
A test succeeds iff the `run_test` script exits with exit code 0. A test succeeds iff the `run_test.sh` script exits with exit code 0.
A benchmark additionally must produce a measurements file: A benchmark additionally must produce a measurements file:
Inside a test pile, `run_bench testfile` is expected to produce a `testfile.measurments.jsonl` file. Inside a test pile, `run_bench.sh` is expected to produce a `<testfile>.measurments.jsonl` file.
Inside a test directory, `run_bench` is expected to produce a `measurements.jsonl` file. Inside a test directory, `run_bench.sh` is expected to produce a `measurements.jsonl` file.
## The `elab*` test pile ## The `elab*` test pile

View File

@@ -22,7 +22,7 @@ def run_stdout(*command: str, cwd: Path | None = None) -> str:
sha = run_stdout("git", "rev-parse", "@", cwd=src_dir).strip() sha = run_stdout("git", "rev-parse", "@", cwd=src_dir).strip()
base_url = f"https://speed.lean-lang.org/lean4-out/{sha}" base_url = f"https://speed.lean-lang.org/lean4-out/{sha}"
report = run_stdout("lakeprof", "report", "-prc", cwd=src_dir) report = (src_dir / "lakeprof_report.txt").read_text()
template = template_file.read_text() template = template_file.read_text()
template = template.replace("__BASE_URL__", json.dumps(base_url)) template = template.replace("__BASE_URL__", json.dumps(base_url))

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_bench.sh
STAGE_THIS="stage$STAGE" STAGE_THIS="stage$STAGE"
STAGE_NEXT="stage$((STAGE + 1))" STAGE_NEXT="stage$((STAGE + 1))"
@@ -17,19 +14,7 @@ echo ">"
echo "> Configuring $STAGE_NEXT..." echo "> Configuring $STAGE_NEXT..."
echo ">" echo ">"
# Building a stage mostly affects files in that stage's build directory.
# However, the bench suite runs inside the source directory for developer UX
# reasons, so some stage-specific bench suite files are generated in the source
# directory (namely the env_*.sh files).
#
# To avoid messing up the rest of the bench suite, we restore those files to
# STAGE_THIS's versions immediately after we configure STAGE_NEXT. Yes, this is
# a big hack, but it allows running the build benchmark as part of the bench
# suite instead of completely separately.
#
# Configuring STAGE_NEXT also builds all stages up to and including STAGE_THIS.
make -C "$BUILD_ROOT" -j"$(nproc)" "$STAGE_NEXT-configure" make -C "$BUILD_ROOT" -j"$(nproc)" "$STAGE_NEXT-configure"
make -C "$BUILD_ROOT" -j"$(nproc)" "$STAGE_THIS-configure"
@@ -66,6 +51,7 @@ echo ">"
# calling lake in its current working directory. # calling lake in its current working directory.
mv lakeprof.log "$SRC_DIR" mv lakeprof.log "$SRC_DIR"
pushd "$SRC_DIR" pushd "$SRC_DIR"
lakeprof report -prc > lakeprof_report.txt
lakeprof report -pj | jq '{metric: "build/lakeprof/longest build path//wall-clock", value: .[-1][2], unit: "s"}' -c >> "$OUT" lakeprof report -pj | jq '{metric: "build/lakeprof/longest build path//wall-clock", value: .[-1][2], unit: "s"}' -c >> "$OUT"
lakeprof report -rj | jq '{metric: "build/lakeprof/longest rebuild path//wall-clock", value: .[-1][2], unit: "s"}' -c >> "$OUT" lakeprof report -rj | jq '{metric: "build/lakeprof/longest rebuild path//wall-clock", value: .[-1][2], unit: "s"}' -c >> "$OUT"
popd popd

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env bash
source ../../env_bench.sh
# This should run in the same environment as run_bench, otherwise `lakeprof`
# will use the `lake` from the global system `elan` install and not the one from
# the current commit.
#
# Once an elan with support for relative toolchains has been widely released and
# been adopted by this repo, this wrapper script should no longer be necessary
# and the upload script can be called directly.
./lakeprof_report_upload.py

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../../env_bench.sh
rm -f measurements.jsonl rm -f measurements.jsonl
# Build dependencies first so their compilation isn't measured. # Build dependencies first so their compilation isn't measured.

View File

@@ -1,5 +1,2 @@
#!/usr/bin/env bash
source ../../../env_test.sh
# Limit threads to avoid exhausting memory with the large thread stack. # Limit threads to avoid exhausting memory with the large thread stack.
LEAN_NUM_THREADS=1 lake test LEAN_NUM_THREADS=1 lake test

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_bench.sh
make -C "$BUILD_DIR" install DESTDIR="$(realpath install)" make -C "$BUILD_DIR" install DESTDIR="$(realpath install)"
python measure_sizes.py "$SRC_DIR" "$BUILD_DIR" install measurements.jsonl python measure_sizes.py "$SRC_DIR" "$BUILD_DIR" install measurements.jsonl
rm -rf install rm -rf install

2
tests/compile/run_bench → tests/compile/run_bench.sh Executable file → Normal file
View File

@@ -1,5 +1,3 @@
#!/usr/bin/env bash
source ../env_bench.sh
source_init "$1" source_init "$1"
if [[ -f "$1.do_compile_bench" ]]; then DO_COMPILE=1 if [[ -f "$1.do_compile_bench" ]]; then DO_COMPILE=1

2
tests/compile/run_test → tests/compile/run_test.sh Executable file → Normal file
View File

@@ -1,5 +1,3 @@
#!/usr/bin/env bash
source ../env_test.sh
source_init "$1" source_init "$1"
if [[ -f "$1.do_compile_test" ]]; then DO_COMPILE=1 if [[ -f "$1.do_compile_test" ]]; then DO_COMPILE=1

View File

@@ -1,5 +1,3 @@
#!/usr/bin/env bash
source ../env_bench.sh
source_init "$1" source_init "$1"
if [[ -f "$1.do_compile_bench" ]]; then DO_COMPILE=1 if [[ -f "$1.do_compile_bench" ]]; then DO_COMPILE=1

View File

@@ -1 +0,0 @@
../compile/run_test

View File

@@ -0,0 +1 @@
../compile/run_test.sh

3
tests/docparse/run_test → tests/docparse/run_test.sh Executable file → Normal file
View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../env_test.sh
# IO.Process.exit (used by the file worker) seems to be incompatible with LSAN # IO.Process.exit (used by the file worker) seems to be incompatible with LSAN
# TODO: investigate or work around # TODO: investigate or work around
export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_leaks=0

3
tests/elab/run_test → tests/elab/run_test.sh Executable file → Normal file
View File

@@ -1,7 +1,4 @@
#!/usr/bin/env bash
source ../env_test.sh
source_init "$1" source_init "$1"
run_before "$1" run_before "$1"
# `--root` to infer same private names as in the server # `--root` to infer same private names as in the server

View File

@@ -1,7 +1,4 @@
#!/usr/bin/env bash
source ../env_bench.sh
source_init "$1" source_init "$1"
run_before "$1" run_before "$1"
TOPIC="elab/$(basename "$1" .lean)" TOPIC="elab/$(basename "$1" .lean)"

View File

@@ -1 +0,0 @@
../elab/run_test

View File

@@ -0,0 +1 @@
../elab/run_test.sh

View File

@@ -1,7 +1,4 @@
#!/usr/bin/env bash
source ../env_test.sh
source_init "$1" source_init "$1"
run_before "$1" run_before "$1"
# `--root` to infer same private names as in the server # `--root` to infer same private names as in the server

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_bench.sh
PREFIX="lake/inundation" PREFIX="lake/inundation"
rm -f measurements.jsonl rm -f measurements.jsonl

View File

@@ -20,8 +20,17 @@ def nag(reason: str, path: Path, fatal: bool = True) -> None:
# Files and directories that will no longer work. # Files and directories that will no longer work.
for file in Path().glob("tests/speedcenter.exec.velcom.yaml"): for pattern in (
nag("removed file", file) "**/*.exit.expected",
"**/*.expected.out",
"**/*.expected.ret",
"**/*.no_interpreter",
"**/run_bench",
"**/run_test",
"tests/speedcenter.exec.velcom.yaml",
):
for file in Path().glob(pattern):
nag("removed file", file)
for dir in ( for dir in (
"tests/bench-radar", "tests/bench-radar",
@@ -39,12 +48,12 @@ for dir in (
nag("removed dir", file) nag("removed dir", file)
for dir in ("tests/lean",): for dir in ("tests/lean",):
for glob in ( for pattern in (
f"{dir}/*.lean", f"{dir}/*.lean",
f"{dir}/*.expected.out", f"{dir}/*.expected.out",
f"{dir}/*.expected.ret", f"{dir}/*.expected.ret",
): ):
for file in Path().glob(glob): for file in Path().glob(pattern):
nag("removed dir", file) nag("removed dir", file)
@@ -63,18 +72,18 @@ for dir in (
"tests/server", "tests/server",
"tests/server_interactive", "tests/server_interactive",
): ):
for glob in ( for pattern in (
f"{dir}/*.no_interpreter", f"{dir}/*.no_interpreter",
f"{dir}/*.expected.out", f"{dir}/*.expected.out",
f"{dir}/*.expected.ret", f"{dir}/*.expected.ret",
): ):
for file in Path().glob(glob): for file in Path().glob(pattern):
nag("old suffix", file) nag("old suffix", file)
# Files that expect a corresponding base file # Files that expect a corresponding base file
for glob, drop in ( for pattern, drop in (
("**/*.no_test", 1), ("**/*.no_test", 1),
("**/*.no_bench", 1), ("**/*.no_bench", 1),
("**/*.do_compile", 1), ("**/*.do_compile", 1),
@@ -96,13 +105,8 @@ for glob, drop in (
("**/*.after.sh", 2), ("**/*.after.sh", 2),
("**/*.out.expected", 2), ("**/*.out.expected", 2),
("**/*.out.ignored", 2), ("**/*.out.ignored", 2),
("**/*.exit.expected", 2),
# Old naming convention
("**/*.no_interpreter", 1),
("**/*.expected.out", 2),
("**/*.expected.ret", 2),
): ):
for file in Path().glob(glob): for file in Path().glob(pattern):
basefile = file basefile = file
for _ in range(drop): for _ in range(drop):
basefile = basefile.with_suffix("") basefile = basefile.with_suffix("")
@@ -117,13 +121,12 @@ for glob, drop in (
# Files that shouldn't be empty # Files that shouldn't be empty
for glob in ( for pattern in (
"**/*.init.sh", "**/*.init.sh",
"**/*.before.sh", "**/*.before.sh",
"**/*.after.sh", "**/*.after.sh",
"**/*.exit.expected",
): ):
for file in Path().glob(glob): for file in Path().glob(pattern):
if file.read_text().strip(): if file.read_text().strip():
continue continue
nag("empty", file) nag("empty", file)
@@ -153,40 +156,14 @@ for file in Path().glob("**/*.no_test"):
# Special rules for certain directories # Special rules for certain directories
for glob in ( for pattern in (
"tests/compile_bench/*.no_bench", "tests/compile_bench/*.no_bench",
"tests/elab/*.exit.expected",
"tests/elab_bench/*.no_bench", "tests/elab_bench/*.no_bench",
"tests/misc_bench/*.no_bench", "tests/misc_bench/*.no_bench",
): ):
for file in Path().glob(glob): for file in Path().glob(pattern):
nag("forbidden", file) nag("forbidden", file)
for file in Path().glob("tests/elab_fail/*.exit.expected"):
if file.read_text().strip() == "0":
nag("must be != 0", file)
# Run scripts sourcing incorrectly
for file in Path().glob("**/run_test"):
if file.is_symlink():
continue
text = file.read_text()
if "env_test.sh" not in text:
nag("no env_test.sh", file)
if "env_bench.sh" in text:
nag("has env_bench.sh", file)
for file in Path().glob("**/run_bench"):
if file.is_symlink():
continue
text = file.read_text()
if "env_bench.sh" not in text:
nag("no env_bench.sh", file)
if "env_test.sh" in text:
nag("has env_test.sh", file)
# File confusion by case insensitive filesystems # File confusion by case insensitive filesystems

3
tests/misc/run_test → tests/misc/run_test.sh Executable file → Normal file
View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../env_test.sh
NAME="$1" NAME="$1"
FILE="$(realpath "$1")" FILE="$(realpath "$1")"
source "$1" source "$1"

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../env_bench.sh
NAME="$1" NAME="$1"
FILE="$(realpath "$1")" FILE="$(realpath "$1")"
OUT="$FILE.measurements.jsonl" OUT="$FILE.measurements.jsonl"

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# LEAN_EXPORTING needs to be defined for .c files included in shared libraries # LEAN_EXPORTING needs to be defined for .c files included in shared libraries
lean --c=SnakeLinter.c SnakeLinter.lean lean --c=SnakeLinter.c SnakeLinter.lean
leanc ${LEANC_OPTS-} -O3 -DNDEBUG -DLEAN_EXPORTING -shared -o SnakeLinter.so SnakeLinter.c leanc ${LEANC_OPTS-} -O3 -DNDEBUG -DLEAN_EXPORTING -shared -o SnakeLinter.so SnakeLinter.c

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# IO.Process.exit (used by the file worker) seems to be incompatible with LSAN # IO.Process.exit (used by the file worker) seems to be incompatible with LSAN
# TODO: investigate or work around # TODO: investigate or work around
export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_leaks=0

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
run lake exe release run lake exe release

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# The test covers the behavior of transitively importing multiple modules # The test covers the behavior of transitively importing multiple modules
# that have a definition with the same name. # that have a definition with the same name.

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
lake build lake build

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
lake build lake build

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# This test covers importing modules which are defined in multiple packages # This test covers importing modules which are defined in multiple packages
# (with the same original package name). # (with the same original package name).

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
LEAN_ABORT_ON_PANIC=1 lake build LEAN_ABORT_ON_PANIC=1 lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
lake exe "path with spaces" lake exe "path with spaces"
# presence of this file should not break process spawn # presence of this file should not break process spawn

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
mkdir -p Rebuild mkdir -p Rebuild

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# Test that Lean will use the specified olean from `setup.json` # Test that Lean will use the specified olean from `setup.json`
lean Dep.lean -o Dep.olean lean Dep.lean -o Dep.olean
lean Test.lean --setup setup.json lean Test.lean --setup setup.json

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
lake build release lake build release

View File

@@ -1,5 +1,2 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
LEAN_ABORT_ON_PANIC=1 lake build LEAN_ABORT_ON_PANIC=1 lake build

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# We need a package test because we need multiple files with imports. # We need a package test because we need multiple files with imports.
# Currently the other package tests all succeed, # Currently the other package tests all succeed,
# but here we need to check for a particular error message. # but here we need to check for a particular error message.

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake exe user_attr

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake exe user_attr

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build rm -rf .lake/build
capture lake build -v capture lake build -v

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
source ../../env_test.sh
rm -rf .lake/build
lake build

View File

@@ -0,0 +1,2 @@
rm -rf .lake/build
lake build

View File

@@ -1,5 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
set -euo pipefail set -euo pipefail
# Deermine shared library extension # Deermine shared library extension

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../../env_test.sh
# This directory contains a unified version of the "ring example" # This directory contains a unified version of the "ring example"
# developed by Kim across the following 4 repositories: # developed by Kim across the following 4 repositories:
# #

3
tests/server/run_test → tests/server/run_test.sh Executable file → Normal file
View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../env_test.sh
run_before "$1" run_before "$1"
capture_only "$1" \ capture_only "$1" \

View File

@@ -1,6 +1,3 @@
#!/usr/bin/env bash
source ../env_test.sh
# IO.Process.exit (used by the file worker) seems to be incompatible with LSAN # IO.Process.exit (used by the file worker) seems to be incompatible with LSAN
# TODO: investigate or work around # TODO: investigate or work around
export ASAN_OPTIONS=detect_leaks=0 export ASAN_OPTIONS=detect_leaks=0

7
tests/with_env.sh.in Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
export ${TEST_VARS}
source "$TEST_DIR/util.sh"
TEST_SCRIPT="$1"; shift
cd "$(dirname "$TEST_SCRIPT")"
source "$(basename "$TEST_SCRIPT")"