First, thanks for clipmenu -- it has upped my clipboard game significantly :)
While working on a different PR, I ran the clipmenu test suite and was surprised to find that it clobbered my clipboard cache. This PR is my attempt to isolate the test suite from the user's existing state; the PR also introduces some miscellaneous additional changes.
Summary of changes:
Introduce a test fixtures hierarchy. The fixtures directory contains a bin path with executables that replace the executables previously dynamically generated in tests/test-clipmenu and tests/test-perf.
Prepend the test/fixtures/bin directory and the clipmenu repository toplevel directory to PATH. This makes it possible to run (say) clipctl cache-dir and be confident that the selected clipctl executable is <toplevel>/clipctl.
Put all generated assets (including the clipboard cache file) into a shared temporary directory (tempdir=$(mktemp -d)). This simplifies end-of-test filesystem cleanup (just recursively remove tempdir).
Add a cleanup function that runs as a trap on the EXIT pseudo-signal. This function recursively removes the above-mentioned tempdir, and also provides a cleanup_pre hook for running code prior to removing the temporary directory hierarchy. tests/test-clipmenu uses cleanup_pre to print the contents of the temporary file used for capturing the mocked-up launchers' output.
Consolidated common test setup (including some of the things mentioned above) into the file tests/setup.sh, and source this file from tests/test-clipmenu and tests/test-perf.
In tests/test-perf, ensure that we always generate 1500 clipboard files. Previously, if NO_RECREATE was in effect and a previous test run generated fewer that 1500 clipboard files (say, the test run was interrupted during the generation stage), subsequent runs with NO_RECREATE in effect would not generate the remaining needed files.
Print a diagnostic message in the cleanup trap function when a test script failed. The diagnostic message includes the command that failed, to aid in debugging.
Use a dynamically-assigned BASH_XTRACEFD in the test/fixtures/bin/clipmenu-perf wrapper rather than using the default stderr file descriptor.
Define a PS4 that results in xtrace displaying additional execution context -- filename, line number, and (if applicable) shell function.
Thanks again for clipmenu, and thanks in advance for your consideration.
First, thanks for
clipmenu
-- it has upped my clipboard game significantly :)While working on a different PR, I ran the
clipmenu
test suite and was surprised to find that it clobbered my clipboard cache. This PR is my attempt to isolate the test suite from the user's existing state; the PR also introduces some miscellaneous additional changes.Summary of changes:
bin
path with executables that replace the executables previously dynamically generated intests/test-clipmenu
andtests/test-perf
.test/fixtures/bin
directory and theclipmenu
repository toplevel directory toPATH
. This makes it possible to run (say)clipctl cache-dir
and be confident that the selectedclipctl
executable is<toplevel>/clipctl
.tempdir=$(mktemp -d)
). This simplifies end-of-test filesystem cleanup (just recursively removetempdir
).cleanup
function that runs as atrap
on theEXIT
pseudo-signal. This function recursively removes the above-mentionedtempdir
, and also provides acleanup_pre
hook for running code prior to removing the temporary directory hierarchy.tests/test-clipmenu
usescleanup_pre
to print the contents of the temporary file used for capturing the mocked-up launchers' output.tests/setup.sh
, and source this file fromtests/test-clipmenu
andtests/test-perf
.tests/test-perf
, ensure that we always generate 1500 clipboard files. Previously, ifNO_RECREATE
was in effect and a previous test run generated fewer that 1500 clipboard files (say, the test run was interrupted during the generation stage), subsequent runs withNO_RECREATE
in effect would not generate the remaining needed files.cleanup
trap function when a test script failed. The diagnostic message includes the command that failed, to aid in debugging.BASH_XTRACEFD
in thetest/fixtures/bin/clipmenu-perf
wrapper rather than using the defaultstderr
file descriptor.PS4
that results inxtrace
displaying additional execution context -- filename, line number, and (if applicable) shell function.Thanks again for
clipmenu
, and thanks in advance for your consideration.