Commit Graph

165 Commits

Author SHA1 Message Date
Xavier Delaruelle
9598a480ac Enable is-used mfcmd in modulerc
Make is-used modulefile command available from a modulerc evaluation
context.
2021-08-19 06:49:28 +02:00
Xavier Delaruelle
68ac915765 Enable system mfcmd in modulerc
Fully enable the system modulefile command in modulerc, whatever the
underlying module evaluation mode (unload, display, whatis, etc).
2021-08-19 06:29:19 +02:00
Xavier Delaruelle
7a516a8ad9 ts: add tests for 'refresh' subcmd 2021-08-14 19:36:22 +02:00
Xavier Delaruelle
237755f9fb ts/doc: add try-load test/doc on 'module-info command' 2021-08-13 07:53:54 +02:00
Xavier Delaruelle
1846866ff3 ts: add new ref count tests on *use/*-path subcmds 2021-08-11 15:28:39 +02:00
Xavier Delaruelle
8aea89634a ts: no ref count on most Modules-specific env var 2021-08-07 13:34:53 +02:00
Xavier Delaruelle
155a3194cc ts: adapt tests for __MODULES_LMNOTUASKED removal 2021-08-07 13:34:21 +02:00
Xavier Delaruelle
1f75963064 ts: update reference to renamed __MODULES_LM* vars 2021-07-24 14:06:09 +02:00
Xavier Delaruelle
91bb6f7dcb ts: adapt existing interp tests now variant are checked 2021-06-21 20:43:10 +02:00
Xavier Delaruelle
40d252ac87 ts: update existing tests to check 'edit' 2021-04-25 22:22:01 +02:00
Xavier Delaruelle
2bcb6a75fb ts: update existing tests to check 'sh-to-mod' 2020-06-01 20:59:50 +02:00
Xavier Delaruelle
fe23209539 Sync env var changes across Tcl sub-interpreters
Ensure environment variable change at the Tcl interpreter level is
propagated to every sub-interpreters used to evaluate modulefiles or
modulercs.

Tcl by default maintain the `::env` array in sync across all started
interpreters. But in some cases, it appears a change occuring in master
interpreter is not correctly propagated when the variable is later on
updated in sub-interpreter.

Fixes #342
2020-05-10 15:54:16 +02:00
Xavier Delaruelle
a77022e5d1 Rework version target inclusion in getModules result
Rework loop walking the symbolic version target to include all elements
recursively contained in directory targeted by symbolic version. Now
using dir_list structure to walk path rather querying the whole
found_list with modEq test procedure.
2020-03-29 18:48:56 +02:00
Xavier Delaruelle
2273640cd5 Add ref in res to version target not in res but not searched
Enable resolution of default module in module sub-directory when this
default symbol targets an hidden directory (whose name starts with a dot
character).

Adapt getModules procedure to add reference, in the directory description
returned as result, for symbolic version targets that are hidden, not
included in returned result but excluded from search made.

Fixes #331
2020-03-29 08:20:49 +02:00
Xavier Delaruelle
d8a58feeeb ts: test alias/symver/virtual hidden modules in 20/067 2020-03-29 08:20:16 +02:00
Xavier Delaruelle
79bbf9e0b7 Cache getModules results
Introduce a memory cache for the results build up by getModules
procedure. Done in order to reuse these results if next searches are
identical, which happens in whatis/search context.

As a side effect a module resolution cannot be changed by the evaluation
of a modulefile sharing same root name, as the initial module resolution
to find this modulefile to evaluation has cached resolution result.

This side effect should not however impact more than the project
testsuite as module resolution should not be defined within a modulefile
but within modulerc files.
2019-12-31 13:58:04 +01:00
Xavier Delaruelle
82ec191dc2 ts: adapt tests for #294 and #295 fixes 2019-09-20 21:12:58 +02:00
Xavier Delaruelle
cbb4b7c611 ts: add modulefiles.2 test modulepath repository
And make it a repository for additional test modulefiles that do not
need to take part in the global avail tests made over the main
repository (modulefiles) and who could mixed with others (like other and
other2).
2019-08-27 21:07:55 +02:00
Xavier Delaruelle
5b4831873e Args after var name are values on {append,prepend,remove}-path
Fix argument parsing for the `append-path`, `prepend-path` and
`remove-path` modulefile commands to consider every arguments found
after the variable name as variable values and not command option even
if argument starts with `-` character.

Fixes #278.
2019-06-28 21:42:58 +02:00
Xavier Delaruelle
38eeac41e4 ts: test 'config' sub-command 2019-05-20 20:36:56 +02:00
Xavier Delaruelle
68b9eddaf1 Fix escaping of '?' character in shell alias
Fixes #275.
2019-05-15 08:14:10 +02:00
Xavier Delaruelle
bf3d971feb ts: test 'clear' sub-command 2019-05-03 14:01:34 +02:00
Xavier Delaruelle
84ed76fa4f Raise error when bad option passed to {append,prepend,remove}-path
Raise an error when an invalid option is set on append-path,
prepend-path or remove-path modulefile command.

Fixes #249.
2019-04-25 18:54:27 +02:00
Xavier Delaruelle
ef576c5fd9 Trim function body passed to set-function cmd
Trim any whitespace, newline or ';' characters at the beginning or end
of the function body passed to set-function modulefile command to
correctly define shell function whatever the writing style used.
2018-12-24 13:59:13 +01:00
Xavier Delaruelle
11a7de5f2a ts: check puts is linked to correct interp 2018-10-23 07:37:00 +02:00
Xavier Delaruelle
e58e12b28f ts: fix tests based on modulecmd.tcl content
As 'adopt minimal escaping style' change the piece of string searched by
some tests.
2018-10-21 10:48:06 +02:00
Xavier Delaruelle
20aada54aa Fix 'system' to run cmd through shell
system modulefile command is intended to the command passed to it trough
shell, like done on compatibility version.

So update system procedure to find correct shell on the current platform
and run command through it.

Doing so, shell commands with backticks for instance are correctly run.

Fixes #205
2018-10-20 19:51:31 +02:00
Ben Bowers
3dc5ecee89 added set-function and unset-function commands
fixed linelength and tabs/spaces

adding set-function/unset-function documentation

adding tests for set-function/unset-function

fixed failing test for function modulefile additions
2018-10-17 09:45:33 +02:00
Xavier Delaruelle
2e813720e8 Fix args pass on 'system' modfile command
Correctly transmit the arguments along with the command to execute. Need
to use 'eval' for the underlying command to get its multiple args and
not one joined string.

Fixes #201
2018-10-15 07:21:32 +02:00
Xavier Delaruelle
702f6f1816 Check version set in modulefile magic cookie
Magic cookie at the beginning of modulefiles may sometimes set a version
number, for instance '#Module1.0'. Until now this version number was
about a modulefile standard version. However there is no known
modulefile API versioning and new modulefile commands are added along
new Modules releases.

So the idea here is to match this version number optionally set on magic
cookie and compare it to the modulecmd.tcl release version. If
modulefile sets a version number greater than modulecmd.tcl version,
this modulefile is not evaluated like when no magic cookie is set at
all.

Add specific tests in 20-locate suite and adapt modulefile man page and
MIGRATING doc.

Fixes #171
2018-09-08 19:10:38 +02:00
Xavier Delaruelle
aa8c94720d Handle default version sets on an hidden modulefile
When looking for the default version of a given modulefile, if this
default is set on an hidden modulefile, this hidden modulefile were not
found as the initial modulefile search were not looking for hidden
modulefiles.

When this situation is now spotted, modulefile search is started again
with inclusion of hidden files.

Add a test for this situation in 20-locate/067-hidden.

Fixes #177
2018-07-13 16:49:43 +02:00
Xavier Delaruelle
95c97ef5f4 Define shell alias with special chars escaped
When producing code to output shell alias definition, escaping of
special characters was missing until now in renderSettings procedure.

Code to bake shell alias has been fixed to work in a similar way than
for environment variable with full range of shell special characters
escaped.

Translation of $n/$* in !!:n/!* on csh-like shells is maintained for
compatibility with v3. To improve this compatibility, a \ prior to $
disables translation on csh (like with v3), then after \$ is translated
in $ for all shells.

Adapt testsuite to use value escaping over expected output result for
shell alias (like done for environment variable). Adapt consequently all
shell alias tests in 50-cmds/07*.

Add test in 50-cmds/076-alias-sub to demonstrate escaping of complex
shell alias. Use modulefile from this new test within install testsuite
to garanty shell alias produce is effective on shell sessions. Check
availability of tools used by this alias (grep, tr, awk) to determine if
install test can be launched on current system.

Fixes #165
2018-05-20 15:55:35 +02:00
Xavier Delaruelle
855f6d2827 Move 'module' to the per-mode evaluation interp
'module' modulefile command targets module procedure on load and unload
modes of modulefile evaluation. reportCmd is targeted on display mode.
For other modes a nop is targeted.

'module' command is now disabled on help, test and whatis mode which
stabilizes evaluation on these modes. On Modules v3, module command was
also disabled on all these query evaluation modes.
2018-04-24 15:17:44 +02:00
Xavier Delaruelle
27a447aa24 Dedicate a modfile interp for each evaluation mode 2018-04-18 11:31:37 +02:00
Xavier Delaruelle
9f8b418fe0 Keep track of cleared env var in g_clearedEnvVars
When unsetting (clearing) an environment variable in 'unset-env'
procedure, keep track of it in a g_clearedEnvVars array to be able to
distinguish later on, in 'getenv' procedure, if variable is equal to an
empty string or if it has been unset (cleared).
2018-04-16 16:28:13 +02:00
Xavier Delaruelle
2e8fed2b28 Add valifundef arg to getenv procedure
Allow to define value to return if variable name passed to the getenv
procedure is undef.

Add a description of 'getenv' command in the modulefile man page.
2018-04-16 07:54:52 +02:00
Xavier Delaruelle
85a45a7d11 Make getenv return value on help/test/whatis modes 2018-04-16 06:46:50 +02:00
Xavier Delaruelle
8532f8ebfd Make unsetenv alter ::env() on display/help/test/whatis modes
Like previously done for 'remove-path', set the variable passed to
'unsetenv' procedure in ::env() array to make accurate value
available for later use during the modulefile evaluation.

Add 50-cmds/039-unsetenv-env test to check this ::env() array change
over all evaluation mode. Adapt 50-cmds/350-allin to check this change
against 'whatis' mode.
2018-04-15 11:17:47 +02:00
Xavier Delaruelle
f2af9db133 Make remove-path alter ::env() on display/help/test/whatis modes
Like previously done for 'append-path', set the variable passed to
'remove-path' procedure in ::env() array to make accurate value
available for later use during the modulefile evaluation.

As a side effect as remove-path command is now evaluated on help, test,
display and whatis modes, invalid argument on this command will raise
error. Previously arguments were not parsed so no error raised.

Add 50-cmds/069-remove-env test to check this ::env() array change over
all evaluation mode. Adapt 50-cmds/350-allin to check this change
against 'whatis' mode.
2018-04-14 16:19:52 +02:00
Xavier Delaruelle
7ce4bb87d9 ts: add tests to 50-cmds/028-setenv-refcount
Test load and unload mode on modulefiles where setenv and append-path
commands play on same variable. Check both ways: setenv then append-path
or appen-path then setenv.
2018-04-14 14:47:31 +02:00
Xavier Delaruelle
46ffd34f0d Make append/prepend-path alter ::env() on display/help/test/whatis modes
Like previously done for 'setenv', set the variable passed to
'append-path' and 'prepend-path' procedures in ::env() array to make it
available for later use during the modulefile evaluation.

As a side effect as append-path/prepend-path commands are now evaluated
on help, test, display and whatis modes, invalid argument on these
commands will raise error. Previously arguments were not parsed so no
error raised.

Add 50-cmds/049-append-env and 50-cmds/059-prepend-env tests to check
this ::env() array change over all evaluation mode. Adapt
50-cmds/350-allin to check this change against 'whatis' mode.
2018-04-08 08:42:04 +02:00
Xavier Delaruelle
e91f1b1f43 Make setenv alter ::env() on help/test/whatis modes
Set the variable passed to 'setenv' procedure in ::env() array to make
it available for later use during the modulefile evaluation.

Add 50-cmds/029-setenv-env tests to check this ::env() array change over
all evaluation mode. Adapt 50-cmds/350-allin to check this change
against 'whatis' mode.

Fixes #160
2018-04-07 14:44:21 +02:00
Xavier Delaruelle
530da8f26e ts: empty mod cmd call check in 50/151-module-onlytop 2018-04-01 13:49:12 +02:00
Xavier Delaruelle
e43876bcea Report error when empty name passed to getPathToModule
Triggered with 'module load ""' call in modulefile. Helps to know what
is going on.
2018-03-16 07:04:10 +01:00
Xavier Delaruelle
44e8fe2fd7 testsuite: add 'cmd' to the test shell list 2018-03-15 06:00:57 +01:00
Xavier Delaruelle
a127870f18 Call real 'puts' command in caller context
To be able to 'puts' content on opened channels, the 'puts' command
should be executed from the modulefile interpreter context. Elsewhere,
master interpreter does not know about the channels opened in its
sub-interpreters.

Adapt interpreter setup to add a command renaming step, to avoid the
puts modulefile alias to overwrite the original puts command. puts
modulefile alias now also pass the caller interpreter reference as first
argument to be able to execute the original puts command, renamed _puts,
within context of this caller interpreter.

Handle wrong argument number error in putsModfileCmd to report an error
for 'puts' command rather '_puts' which should not be known by users.

Add non-regression test to check puts command against opened channel.

Fixes #157
2018-03-01 15:27:04 +01:00
Xavier Delaruelle
02cfadf969 testsuite: bad ref counter tests in 50-cmds/040-append 2018-02-26 19:01:13 +01:00
Xavier Delaruelle
abc2ddb9cc testsuite: display/exit 0 tests in 50-cmds/140-system 2018-02-25 21:40:10 +01:00
Xavier Delaruelle
1601b670fb testsuite: large val append test in 50-cmds/040-append 2018-02-25 20:57:06 +01:00
Xavier Delaruelle
13950abb3e testsuite: alias def loop test in 20-locate/040-alias 2018-02-24 11:47:44 +01:00