Simpler interface to inject `source ...` in each prepare/test
When working on Lmod, I've found the need to source /etc/profile.d/modules.sh which is not sourced by default because the scripts are not run as interactive mode.
The proposal here would be to possibly have prepare step that would inject a prepare (and maybe finish) scriplet that would be run for all shell environments, e.g.
/plan:
prepare:
- how: shell-env
pre-script: |
source /etc/profile.d/modules.sh
module load openmpi
- how: shell
script: |
echo $MPI_HOME
/test:
test: echo $MPI_HOME
Here the subsequent steps would be expecting to have the module load command before the main scriplets. The would of course be an issue of how to handle the other non-shell steps, but for now limiting the scope to shell(-like) scripts should be helpful enough.
As a workaround, for tests, we can use fmf inheritance and adjustment, but it can get messy, particularly if we want to handle the prepare steps also.
A related issue would be to expose the flags used when running the scripts to enable interactive mode when needed. The issue here though would still be relevant, because you might still want an easy place to source some environment setup.
Summary from the hacking session: An environment variable similar to TMT_PLAN_ENVIRONMENT_FILE could be introduced, perhaps TMT_PLAN_SOURCE_FILE, which, if present, would be sourced at the beginning of the prepare, finish and test scripts. Explicitly limit first areas where the sourcing would be enabled/available, extend later if needed.