From 1cd8a67b52855b2e5325bca382438c5f9ffe94fe Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 22 Dec 2022 17:42:40 +0100 Subject: [PATCH] ts: optionally build cache files to run tests When TESTSUITE_ENABLE_MODULECACHE environment variable is set, cache file is built for all modulepaths of the testsuite. Tests are run using the cache files to resolve available modules. --- .cirrus.yml | 1 + .github/workflows/linux_tests.yaml | 1 + script/mt | 2 +- testsuite/modules.00-init/010-environ.exp | 2 +- testsuite/modules.00-init/060-build_cache.exp | 31 +++++++++++++++++++ .../051-cache-buffer-bytes.exp | 3 ++ testsuite/modules.70-maint/220-config.exp | 2 ++ testsuite/modules.99-finish/999-cleanup.exp | 29 +++++++++++++++++ 8 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 testsuite/modules.00-init/060-build_cache.exp create mode 100644 testsuite/modules.99-finish/999-cleanup.exp diff --git a/.cirrus.yml b/.cirrus.yml index 2920e074..8187f32d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -121,6 +121,7 @@ task: LC_ALL: C TEST_SPECIFIC_CONFIG: install-testmodspath-wild EXTRATEST_SOURCESH: y + TESTSUITE_ENABLE_MODULECACHE: 1 container: image: ubuntu:focal cpu: 1 diff --git a/.github/workflows/linux_tests.yaml b/.github/workflows/linux_tests.yaml index d9ef4274..def77020 100644 --- a/.github/workflows/linux_tests.yaml +++ b/.github/workflows/linux_tests.yaml @@ -181,6 +181,7 @@ jobs: COVERAGE_MULTILIB: y EXTRA_SCRIPT_PRETEST: make install-testsiteconfig-1 && export TESTSUITE_ENABLE_SITECONFIG=1 EXTRA_SCRIPT_POSTTEST: unset TESTSUITE_ENABLE_SITECONFIG + TESTSUITE_ENABLE_MODULECACHE: 1 steps: - uses: actions/checkout@v3 with: diff --git a/script/mt b/script/mt index e71008b7..5061c837 100755 --- a/script/mt +++ b/script/mt @@ -71,7 +71,7 @@ fi # make target target=test testserie=modules -setuptestfiles=(00/005 00/006 00/010 00/050 00/080 00/085) +setuptestfiles=(00/005 00/006 00/010 00/050 00/060 00/080 00/085) if [ $# -gt 0 ]; then if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo_usage diff --git a/testsuite/modules.00-init/010-environ.exp b/testsuite/modules.00-init/010-environ.exp index 5a215a65..de94e8c8 100644 --- a/testsuite/modules.00-init/010-environ.exp +++ b/testsuite/modules.00-init/010-environ.exp @@ -29,7 +29,7 @@ if { $verbose > 0 } { foreach var [concat [array names env -glob TESTSUITE_*]\ [list TESTSUITE TS0 TS1 TS2 TS3 TS4 TS4 TS6 TS7 TS8 TS9]] { # preserve variable externally set to configure testsuite run - if {$var ne {TESTSUITE_ENABLE_SITECONFIG}} { + if {$var ni {TESTSUITE_ENABLE_SITECONFIG TESTSUITE_ENABLE_MODULECACHE}} { unsetenv_var $var } } diff --git a/testsuite/modules.00-init/060-build_cache.exp b/testsuite/modules.00-init/060-build_cache.exp new file mode 100644 index 00000000..3720d39d --- /dev/null +++ b/testsuite/modules.00-init/060-build_cache.exp @@ -0,0 +1,31 @@ +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: modules.00-init/%M% +# Revision: %I% +# First Edition: 2022/12/22 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite testsequence +# Command: +# Modulefiles: +# Sub-Command: +# +# Comment: %C{ +# Build cache for testsuite modulepaths +# }C% +# +############################################################################## + +if {[info exists env(TESTSUITE_ENABLE_MODULECACHE)]} { + foreach mp [glob $env(TESTSUITEDIR)/modulefiles*] { + if {[string first { } $mp] == -1} { + send_user "\tBuilding cachefile $mp\n" + testouterr_cmd sh "cachebuild $mp" OK [msg_create $mp/.modulecache] + } + } + setenv_var MODULES_CACHE_BUFFER_BYTES 1000000 +} diff --git a/testsuite/modules.30-cache/051-cache-buffer-bytes.exp b/testsuite/modules.30-cache/051-cache-buffer-bytes.exp index 4a1e0ef7..52febae6 100644 --- a/testsuite/modules.30-cache/051-cache-buffer-bytes.exp +++ b/testsuite/modules.30-cache/051-cache-buffer-bytes.exp @@ -22,6 +22,9 @@ skip_if_quick_mode +# unset buffer size variable that may be set if module cache are prebuilt +unsetenv_var MODULES_CACHE_BUFFER_BYTES + # ensure avail tests are made using in depth mode setenv_var MODULES_AVAIL_INDEPTH 1 diff --git a/testsuite/modules.70-maint/220-config.exp b/testsuite/modules.70-maint/220-config.exp index 36c7c24d..7b6dd5bc 100644 --- a/testsuite/modules.70-maint/220-config.exp +++ b/testsuite/modules.70-maint/220-config.exp @@ -28,6 +28,8 @@ unsetenv_var MODULERCFILE unsetenv_var MODULES_TAG_COLOR_NAME unsetenv_var MODULES_MCOOKIE_CHECK unsetenv_var MODULES_MCOOKIE_VERSION_CHECK +# cache buffer size may be set if cache files have been prebuilt +unsetenv_var MODULES_CACHE_BUFFER_BYTES unsetenv_var MODULES_AVAIL_OUTPUT unsetenv_var MODULES_AVAIL_TERSE_OUTPUT unsetenv_var MODULES_LIST_OUTPUT diff --git a/testsuite/modules.99-finish/999-cleanup.exp b/testsuite/modules.99-finish/999-cleanup.exp new file mode 100644 index 00000000..43b17e89 --- /dev/null +++ b/testsuite/modules.99-finish/999-cleanup.exp @@ -0,0 +1,29 @@ +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: modules.99-finish/%M% +# Revision: %I% +# First Edition: 2022/12/22 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite testsequence +# Command: +# Modulefiles: +# Sub-Command: +# +# Comment: %C{ +# Cleans out after end of all tests +# }C% +# +############################################################################## + +# delete cache files created for tests +if {[info exists env(TESTSUITE_ENABLE_MODULECACHE)]} { + foreach mpcache [glob $env(TESTSUITEDIR)/modulefiles*/.modulecache] { + send_user "\tDeleting cachefile $mpcache\n" + file delete $mpcache + } +}