-
Notifications
You must be signed in to change notification settings - Fork 249
Pass CMake details to e2e tests via a configuration file #7713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,10 +66,6 @@ function(add_e2e_test) | |||||||
| "CONSTITUTION;ADDITIONAL_ARGS;CONFIGURATIONS" | ||||||||
| ) | ||||||||
|
|
||||||||
| if(NOT PARSED_ARGS_CONSTITUTION) | ||||||||
| set(PARSED_ARGS_CONSTITUTION ${CCF_NETWORK_TEST_DEFAULT_CONSTITUTION}) | ||||||||
| endif() | ||||||||
|
|
||||||||
| if(BUILD_END_TO_END_TESTS) | ||||||||
| if(PROFILE_TESTS) | ||||||||
| set(PYTHON_WRAPPER | ||||||||
|
|
@@ -86,24 +82,32 @@ function(add_e2e_test) | |||||||
| set(PYTHON_WRAPPER ${PYTHON}) | ||||||||
| endif() | ||||||||
|
|
||||||||
| # For fast e2e runs, tick node faster than default value (except for | ||||||||
| # instrumented builds which may process ticks slower). | ||||||||
| if(SAN) | ||||||||
| set(NODE_TICK_MS 10) | ||||||||
| else() | ||||||||
| set(NODE_TICK_MS 1) | ||||||||
| endif() | ||||||||
|
|
||||||||
| if(NOT PARSED_ARGS_PERF_LABEL) | ||||||||
| set(PARSED_ARGS_PERF_LABEL ${PARSED_ARGS_NAME}) | ||||||||
| endif() | ||||||||
|
|
||||||||
| # Build the command line. Global defaults (binary_dir, log_level, | ||||||||
| # worker_threads, tick_ms, default_constitution) are now provided by the | ||||||||
| # e2e_config.json generated at configure time and consumed by e2e_args.py. | ||||||||
| # Only test-specific args remain here. | ||||||||
| set(E2E_CMD | ||||||||
| ${PYTHON_WRAPPER} ${PARSED_ARGS_PYTHON_SCRIPT} --label | ||||||||
| ${PARSED_ARGS_NAME} | ||||||||
| ) | ||||||||
|
|
||||||||
| # Constitution: only pass on CLI when explicitly overridden for this test. | ||||||||
| # Otherwise e2e_args.py falls back to default_constitution from config. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a question mark over whether we want test-specific overrides in the config as defaults, for when one decides to manually My sense is "yes, that would be a nice QoL improvement", but I can see that it means the defaults will vary test to test also, for the same CLI, which can be surprising. Another scheme may be to still capture a single configuration for all tests, but only grab generic defaults there that must come from CMake (directories, san_is_enabled), and have each test configure its defaults explicitly in the Python file, using the config. I think this is probably the better scheme in the longer run, because it minimises the size of the CMake-to-Python interface, as well as the amount of test-related-CMake. The more stuff lives on the Python side, the easier it is to tweak without a round-trip through ninja. |
||||||||
| if(PARSED_ARGS_CONSTITUTION) | ||||||||
| list(APPEND E2E_CMD ${PARSED_ARGS_CONSTITUTION}) | ||||||||
| endif() | ||||||||
|
|
||||||||
| if(PARSED_ARGS_ADDITIONAL_ARGS) | ||||||||
| list(APPEND E2E_CMD ${PARSED_ARGS_ADDITIONAL_ARGS}) | ||||||||
| endif() | ||||||||
|
|
||||||||
| add_test( | ||||||||
| NAME ${PARSED_ARGS_NAME} | ||||||||
| COMMAND | ||||||||
| ${PYTHON_WRAPPER} ${PARSED_ARGS_PYTHON_SCRIPT} -b . --label | ||||||||
| ${PARSED_ARGS_NAME} ${CCF_NETWORK_TEST_ARGS} ${PARSED_ARGS_CONSTITUTION} | ||||||||
| ${PARSED_ARGS_ADDITIONAL_ARGS} --tick-ms ${NODE_TICK_MS} | ||||||||
| COMMAND ${E2E_CMD} | ||||||||
| CONFIGURATIONS ${PARSED_ARGS_CONFIGURATIONS} | ||||||||
|
||||||||
| CONFIGURATIONS ${PARSED_ARGS_CONFIGURATIONS} | |
| CONFIGURATIONS ${PARSED_ARGS_CONFIGURATIONS} | |
| WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "binary_dir": "@CMAKE_BINARY_DIR@", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know if we need an explicit |
||
| "log_level": "@TEST_LOGGING_LEVEL@", | ||
| "worker_threads": @WORKER_THREADS@, | ||
| "tick_ms": @NODE_TICK_MS@, | ||
| "default_constitution": @DEFAULT_CONSTITUTION_JSON@ | ||
| } | ||
|
Comment on lines
+1
to
+7
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSON generation here does not escape file paths correctly. On Windows (and any environment where paths may contain backslashes), the resulting
DEFAULT_CONSTITUTION_JSONcan produce invalid JSON (e.g.,\\n,\\t,\\uXXXXescapes, etc.). Consider generating JSON using a JSON-aware mechanism (e.g., CMakestring(JSON ...)if available) or at minimum normalizing paths to forward slashes (e.g.,file(TO_CMAKE_PATH ...)) and escaping backslashes/quotes before inserting into JSON.