Move common BASH test logic to wrapper#7928
Conversation
|
Thanks for your pull request and interest in making D better, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
test/bash_test_wrapper.sh
Outdated
| # duplicate d_do_test output | ||
| echo >> ${output_file} | ||
| echo ============================== >> ${output_file} | ||
| echo Test failed >> ${output_file} |
There was a problem hiding this comment.
It's good to state here which test failed as the tests might run in high parallelism.
ce1fae7 to
d7e3b3e
Compare
503596f to
e7e8b69
Compare
e7e8b69 to
a0d1f08
Compare
wilzbach
left a comment
There was a problem hiding this comment.
I'm strongly voting for this. Redefining the same variables in the bash scripts has become quite a pain.
Thanks a lot @marler8997 for pushing this!
I even have a few idea to make this more useful (a few more default exported variables, a default debug trap, default set -eu o pipefail, ...), but I'm more than happy to do this in a quick follow-up.
| # Test CRLF and mixed line ending handling in D lexer. | ||
|
|
||
| name=`basename $0 .sh` | ||
| dir=${RESULTS_DIR}/compilable |
There was a problem hiding this comment.
yeah, replaced with ${TEST_NAME}
| name=`basename $0 .sh` | ||
| dir=${RESULTS_DIR}/compilable | ||
| fn=${dir}/${name}.d | ||
| fn=${TEST_DIR}/${TEST_NAME}.d |
There was a problem hiding this comment.
In a next step TEST_FILE could be exported as well.
| name=`basename $0 .sh` | ||
| dir=${RESULTS_DIR}/compilable | ||
| output_file=${dir}/${name}.html | ||
| output_file=${RESULTS_DIR}/${TEST_DIR}/${TEST_NAME}.html |
There was a problem hiding this comment.
This seems to be quite frequent enough.
export OUTPUT_FILE="${RESULTS_DIR}/${TEST_DIR}/${TEST_NAME}"
could be part of a next step.
There was a problem hiding this comment.
this one is common enough, I'll add it to this PR
There was a problem hiding this comment.
actually, wait, this is specific to this test only...it has the .html extension
There was a problem hiding this comment.
Yes, that's why export OUTPUT_FILE="${RESULTS_DIR}/${TEST_DIR}/${TEST_NAME}" which allows the user to pick the extension, but yeah, let's think about this in the next step.
There was a problem hiding this comment.
Yeah, I wasn't sure the best variables to expose...there's combinations of the source dir vs results dir and different extensions...we can figure it out in the next step like you said
|
|
||
| # TEST_DIR should be one of compilable, fail_compilation or runnable | ||
| export TEST_DIR=$1 | ||
| export TEST_NAME=$2 |
There was a problem hiding this comment.
There are a few more variables which I frequently need, but I think we can easily go step by step here.
| @@ -0,0 +1,29 @@ | |||
| #!/usr/bin/env bash | |||
|
|
|||
There was a problem hiding this comment.
set -u -o pipefail (doesn't have to be done in this PR)
| output_file=${RESULTS_DIR}/${script_name}.out | ||
| rm -f ${output_file} | ||
|
|
||
| ./${script_name} > ${output_file} 2>&1 |
There was a problem hiding this comment.
A future extension could use source here.
Advantages:
- use a trap, to show the error of the failure
- activate
set -ue -o pipefailby default - activate
set +xby default, redirect the debug log into aXYZ.debugfile and only show it when there's a failure.
Yes, we should do this, but I think your PR is already a good start and makes a good base for future improvements like this one (or the other potential ones I have mentioned). |
|
Ok yeah, we can merge as is and I'll let you enhance it (you're better at BASH anyway) |
|
No one has objected to this change within one week, it's not critical DMD code, but just affects the test suite and we need to move on -> merging. |
This PR creates a wrapper to hold common logic/settings for all BASH tests. Currently, this wrapper will pipe
stdout/stderrto the test output file, and when a failure occurs, will dump the output file with a message saying the test failed (just liked_do_testdoes with.dtests).It also exports common variables to the test script, currently
${TEST_DIR}(i.e. compilable/runnable)${TEST_NAME}being the base name of the test.TODO:
Maybe
set -euo pipefailand/orset -xin wrapper?