Skip to content

Add and use RESULTS_TEST_DIR + OUTPUT_BASE + EXTRA_FILES in the bash scripts of DMD's testsuite#8038

Merged
WalterBright merged 1 commit intodlang:masterfrom
wilzbach:bash-dir
Mar 26, 2018
Merged

Add and use RESULTS_TEST_DIR + OUTPUT_BASE + EXTRA_FILES in the bash scripts of DMD's testsuite#8038
WalterBright merged 1 commit intodlang:masterfrom
wilzbach:bash-dir

Conversation

@wilzbach
Copy link
Copy Markdown
Contributor

Turns out we can save quite a lot when we move the redundant definitions in the bash files to the new wrapper.
This also opens the opportunity to run the shell script in a temporary directory [1] or do other things as now most scripts don't have any hard-coded information anymore.

I'm not fixed about the names EXTRA_FILES could also be named SRC for example.

[1] this would mean e.g. that no manual cleaning of the generated files is necessary anymore, but it's just one potential opportunity. The big motivation of this PR is to remove the redundant declarations and thus let the test scripts focus on what's important: testing and not startup/cleanup code.

CC @marler8997 @timotheecour @CyberShadow

@dlang-bot
Copy link
Copy Markdown
Contributor

dlang-bot commented Mar 15, 2018

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#8038"

@wilzbach
Copy link
Copy Markdown
Contributor Author

There's a bit of an overload with #8025, but the two PRs are independent and pursue different things (here common variables, in #8025 verbose stack trace)

$DMD -c -od=${dir} -Xi=compilerInfo compilable/extra-files/emptymain.d > ${output_file}
rm -f emptymain.json || true
$DMD -c -od=${RESULTS_TEST_DIR} -Xi=compilerInfo ${EXTRA_FILES}/emptymain.d
rm -f emptymain.json
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also: #8025 (comment)

$DMD -m${MODEL} -od${RESULTS_OUTPUT} -I${src} ${src}/main.d ${RESULTS_OUTPUT}/a${LIBEXT} ${RESULTS_OUTPUT}/b${LIBEXT} || exit 1

rm -f ${dir}/{a${LIBEXT} b${LIBEXT} main${EXE} main${OBJ}}
rm -f ${RESULTS_OUTPUT}/{a${LIBEXT} b${LIBEXT} main${EXE} main${OBJ}}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one of the cases where just nuking the RESULTS_OUTPUT folder would make sense (and is probably a good default (if no error happened), but I went with keeping the existing behavior to make reviewing easy.

echo >> ${output_file}
echo "Dependencies file:"
cat ${deps_file}
echo
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdout is redirected to the output by default. See #8025 which makes this even more interesting with a verbose stack trace.

rm -rf "${dir:?}"/"$TEST_NAME"
rm -rf "${RESULTS_OUTPUT}"

echo Success
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is superfluous too, but already removed in #8025

$DMD -g -m${MODEL} -I${src} -of${libname} -lib ${src}${SEP}lib15729.d || exit 1
$DMD -g -m${MODEL} -I${src} -of${dir}${SEP}gdb15729${EXE} ${src}${SEP}gdb15729.d ${libname} || exit 1
$DMD -g -m${MODEL} -I${EXTRA_FILES} -of${RESULTS_OUTPUT}${LIBEXT} -lib ${EXTRA_FILES}${SEP}lib15729.d || exit 1
$DMD -g -m${MODEL} -I${EXTRA_FILES} -of${RESULTS_OUTPUT}${EXE} ${EXTRA_FILES}${SEP}gdb15729.d ${RESULTS_OUTPUT}${LIBEXT} || exit 1
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these || exit 1 should be removed to and be replaced with set -e, but that's a task for another PR.

@wilzbach wilzbach force-pushed the bash-dir branch 3 times, most recently from 6a476f4 to e3bc75a Compare March 15, 2018 15:03
export TEST_DIR=$1 # TEST_DIR should be one of compilable, fail_compilation or runnable
export TEST_NAME=$2 # name of the test, e.g. test12345
export RESULTS_TEST_DIR=${RESULTS_DIR}/${TEST_DIR} # reference to the resulting test_dir folder, e.g .test_results/runnable
export RESULTS_OUTPUT=${RESULTS_TEST_DIR}/${TEST_NAME} # reference to the resulting files without a suffix, e.g. test_results/runnabel/test123
Copy link
Copy Markdown
Contributor

@marler8997 marler8997 Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ${RESULTS_OUTPUT_BASE} ? But it is used quite a bit...maybe it's OK as it is... Or maybe we don't need RESULTS, maybe OUTPUT_PREFIX? or OUTPUT_BASE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea - I went with OUTPUT_BASE, but I don't have any strong preference.

@wilzbach wilzbach changed the title Add and use RESULTS_{TEST_DIR,OUTPUT} + EXTRA_FILES in the bash scripts Add and use RESULTS_TEST_DIR + OUTPUT_BASE + EXTRA_FILES in the bash scripts Mar 15, 2018
@wilzbach wilzbach force-pushed the bash-dir branch 2 times, most recently from 2765d3e to 2631c41 Compare March 15, 2018 18:59
@wilzbach wilzbach added the Review:WIP Work In Progress - not ready for review or pulling label Mar 15, 2018
@wilzbach wilzbach force-pushed the bash-dir branch 2 times, most recently from 9800c01 to 5bd858e Compare March 15, 2018 20:35
@marler8997
Copy link
Copy Markdown
Contributor

(For another PR)
Might be nice to add a README.md to this directory. That explains what variables are available to BASH tests. Maybe move the documentation from the Makefile to the README file and have it explain everything there.

@wilzbach wilzbach removed the Review:WIP Work In Progress - not ready for review or pulling label Mar 16, 2018
@wilzbach wilzbach force-pushed the bash-dir branch 8 times, most recently from 07a3eff to 76734bd Compare March 22, 2018 21:05
@wilzbach
Copy link
Copy Markdown
Contributor Author

(rebased as #8025 with the verbose xtracing is now in)

@ibuclaw
Copy link
Copy Markdown
Member

ibuclaw commented Mar 25, 2018

This also opens the opportunity to run the shell script in a temporary directory

N.B. Many D tests are missing EXTRA_FILES (or maybe EXTRA_SOURCES) also if you are interested in running tests in an isolated temporary directory.

@wilzbach
Copy link
Copy Markdown
Contributor Author

Yes, I'm aware and I don't have plan working on this in the near future though I might look into replacing the bash scripts with D scripts to please the people on Windows, but I don't use/have Windows, so that's not super-high on my priority list.

(anyhow merge conflicts resolved)

@wilzbach wilzbach changed the title Add and use RESULTS_TEST_DIR + OUTPUT_BASE + EXTRA_FILES in the bash scripts Add and use RESULTS_TEST_DIR + OUTPUT_BASE + EXTRA_FILES in the bash scripts of DMD's testsuite Mar 25, 2018
@WalterBright WalterBright merged commit df4a634 into dlang:master Mar 26, 2018
@marler8997
Copy link
Copy Markdown
Contributor

The big disadvantage I see with "D" is it could make the tests suite take a bit longer since D takes a while to compile when compared to the time it takes to interpret a BASH script. But having to run BASH in Windows is something I haven't been able to get working.

@wilzbach wilzbach deleted the bash-dir branch July 1, 2018 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants