Repository navigation
Use CMake to create temporary test directories eliminating run_test.* - #9405
Conversation
|
This doesn't work on Windows; a cmake configure prints out I'll see if I can get better logs from cmake. |
|
cmake 3.22.1 I'm going to guess the command line may be too long :P So maybe we chunk up the command? Full output: |
|
Lol... oh windows. Reworked so it shards into multiple commands. Can you try again? |
|
(configure succeeded and vscode shows the tests! trying a full build to see if they run) |
|
seems to work for me on windows! |
Are there acceptable levels of overhead when running a single test? |
|
warm cmake configure at head and with this PR are about the same - it's really unfortunate that means ~35-40s per configure, but I don't think this PR changes that much. That's on a configure with the directories already created and no cleared cache; I have no idea why we take that long 😢 |
|
Ah I meant test time, not configure time. We recreate the dirs on each run of ctest. For me, that adds about 0.15s of overhead running ctest. HEAD: $ multitime -n 100 ctest --output-on-failure --test-dir ~/build/iree/default --label-exclude "^vulkan_uses_vk_khr_shader_float16_int8$" -R iree/base/internal/math_test
...
===> multitime results
1: ctest --output-on-failure --test-dir /usr/local/google/home/gcmn/build/iree/default --label-exclude ^vulkan_uses_vk_khr_shader_float16_int8$ -R iree/base/internal/math_test
Mean Std.Dev. Min Median Max
real 0.068 0.005 0.066 0.067 0.110
user 0.050 0.007 0.031 0.050 0.065
sys 0.019 0.007 0.002 0.018 0.038vs with this commit This PR: $ multitime -n 100 ctest --output-on-failure --test-dir ~/build/iree/default --label-exclude "^vulkan_uses_vk_khr_shader_float16_int8$" -R iree/base/internal/math_test
===> multitime results
1: ctest --output-on-failure --test-dir /usr/local/google/home/gcmn/build/iree/default --label-exclude ^vulkan_uses_vk_khr_shader_float16_int8$ -R iree/base/internal/math_test
Mean Std.Dev. Min Median Max
real 0.232 0.032 0.198 0.224 0.385
user 0.075 0.012 0.051 0.074 0.113
sys 0.136 0.011 0.100 0.135 0.161 |
|
I don't perceive any difference when clicking the magic little run test buttons in vscode; ship it! |
| # IREE_*_DISABLE environment variables may used to skip test cases which | ||
| # require both a compiler target backend and compatible runtime HAL driver. | ||
| # | ||
| # These variables may be set by the test environment, typically as a property | ||
| # of some continuous execution test runner or by an individual developer, or | ||
| # here by the build system. | ||
| # | ||
| # Tests which only depend on a compiler target backend or a runtime HAL | ||
| # driver, but not both, should generally use a different method of filtering. | ||
| if(NOT IREE_TARGET_BACKEND_VULKAN_SPIRV OR NOT IREE_HAL_DRIVER_VULKAN) | ||
| set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT "IREE_VULKAN_DISABLE=1") | ||
| endif() |
There was a problem hiding this comment.
FYI I had my eye on some of this when bringing up the web platform tests. The https://github.com/google/iree/blob/main/experimental/web/testing/parse_test_list.py script currently just ignores all ENVIRONMENT properties, but I might want to either omit the environment properties or handle them in some web-specific way.
| # Parse the 'command' list into the source file and its arguments. | ||
| # /path/to/run_test.bat # TODO(scotttodd): replace with `node`? | ||
| # /path/to/test_runner.js # such as iree-check-module.js or test.js | ||
| # arg 1 # such as --driver=local-task | ||
| # arg 2 # such as check_vmvx_op.mlir_module.vmfb | ||
| test_source_absolute_path = test["command"][1] | ||
| test_source_absolute_path = test["command"][0] |
There was a problem hiding this comment.
The TODO about node is still relevant, but I'm fine with dropping it. With a native test you can just run the test executable directly, but with JavaScript you either want to run the test under nodejs via node script.js or in a web browser (I'm rusty on specifics there though).
Thanks for updating this array indices here :)
There was a problem hiding this comment.
I was also looking at the android stuff and thinking about whether we should still have something like Bazel's "--run_under" that allows us to prepend every test command with some wrapper. It's just that for "normal" desktop platforms we'd have the runner be the empty string.
|
Looks like this broke the |
|
Thanks Scott. Fix in #9438 |
This behavior, introduced in #9405, is broken on Android, where we don't do this temp directory registration: https://buildkite.com/iree/iree-test-android/builds/6452 Triggered a run of the android test pipeline on this PR: https://buildkite.com/iree/iree-test-android/builds/6458
…iree-org#9405) We create a `CTEST_CUSTOM_PRE_TEST` command to create a fresh temporary directory for each test before ctest runs any tests. This allows us to delete all our `run_test.*` custom test wrappers that add extra indirection and wreak havoc on debuggers and similar tooling. Fixes iree-org#5147 Somewhat tangentially, this unifies variable names as `TMPDIR` rather than `TMP_DIR` because that was causing me some pain in the world of CMake silently continuing past undefined variables. Note that this *doesn't* get rid the custom shell wrappers for android testing. I still think we could do better here, but I'm calling that out of scope. We could also do more to simplify and deduplicate test setup (e.g. a common `add_iree_test` that does all the things we repeat in every test rule). Alternatives considered: We could use test fixtures instead, which would allow only creating the directory before each test run (and avoid creating directories for any tests not run), but each fixture setup or teardown task is itself a test, which would mean the test logs would be filled with spam of at least double the number of actual tests. I did not find any way to have some tests marked as "hidden" or similar. We could only register and create directories for tests that actually need them, but this is more fiddly and error-prone. Additionally, creating a directory for every test matches the behavior of Bazel, which is nice to have. Creating a directory for every test currently adds about 0.15s of overhead to a run of `ctest` on my machine. The global property for recording all test temporary directories is gross, but it seemed like the least bad way. There's a `TESTS` property, but it's directory scoped. I looked at traversing the directory tree after all tests were registered and aggregating these directory-scoped variables, but this ends up traversing even hidden (e.g. build) directories. Another option would be to use a custom `add_subdirectory` that collects the tests that were added back into the current directory's scope. Since we already need to do some setup for each test, it seemed better to hook in there.
…#9438) This behavior, introduced in iree-org#9405, is broken on Android, where we don't do this temp directory registration: https://buildkite.com/iree/iree-test-android/builds/6452 Triggered a run of the android test pipeline on this PR: https://buildkite.com/iree/iree-test-android/builds/6458
We create a
CTEST_CUSTOM_PRE_TESTcommand to create a fresh temporarydirectory for each test before ctest runs any tests. This allows us to
delete all our
run_test.*custom test wrappers that add extraindirection and wreak havoc on debuggers and similar tooling.
Fixes #5147
Somewhat tangentially, this unifies variable names as
TMPDIRratherthan
TMP_DIRbecause that was causing me some pain in the world ofCMake silently continuing past undefined variables.
Note that this doesn't get rid the custom shell wrappers for android
testing. I still think we could do better here, but I'm calling that
out of scope. We could also do more to simplify and deduplicate test
setup (e.g. a common
add_iree_testthat does all the things we repeatin every test rule).
Alternatives considered:
We could use test fixtures instead, which would allow only creating the
directory before each test run (and avoid creating directories for any
tests not run), but each fixture setup or teardown task is itself a
test, which would mean the test logs would be filled with spam of at
least double the number of actual tests. I did not find any way to have
some tests marked as "hidden" or similar.
We could only register and create directories for tests that actually
need them, but this is more fiddly and error-prone. Additionally,
creating a directory for every test matches the behavior of Bazel,
which is nice to have. Creating a directory for every test currently
adds about 0.15s of overhead to a run of
cteston my machine.The global property for recording all test temporary directories is
gross, but it seemed like the least bad way. There's a
TESTSproperty, but it's directory scoped. I looked at traversing the
directory tree after all tests were registered and aggregating these
directory-scoped variables, but this ends up traversing even hidden
(e.g. build) directories. Another option would be to use a custom
add_subdirectorythat collects the tests that were added back intothe current directory's scope. Since we already need to do some setup
for each test, it seemed better to hook in there.