Commit Graph

1316 Commits

Author SHA1 Message Date
Xavier Delaruelle
b2bb071782 New year copyright mention update 2018-01-13 16:51:49 +01:00
Xavier Delaruelle
58395a1cf8 Virtual module target may be loaded as is
Adapt similar loaded module detection code and add tests to check
behavior when the target of a virtual module is loaded as is and a
virtual module targeting it is loaded/unloaded/switched/etc.

Also set test cases on module mixing regular and virtual versions,
playing with short or full path name representation.
2018-01-13 16:51:49 +01:00
Xavier Delaruelle
1b13fccb2e Update g_loadedModuleFiles arrays in load/unload cmds
Update the content of the g_loadedModuleFiles cache array right after
loading or unloading a module. Helps subsequent actions to learn the
exact current state, especially in case of single command implying
multiple actions (switch or load/unload of multiple modules)
2018-01-13 16:51:49 +01:00
Xavier Delaruelle
4dad91dbfa Handle _LMFILES_ path var in duplicates mode
Multiple loaded virtual modules may target same file so handling of the
_LMFILES_ path variable is changed to a 'duplicates' mode to ensure a
file entry will always correspond to a module entry in LOADEDMODULES.

Adapt entry removal in _LMFILES_ variable to delete the entry at the
index corresponding to the index of the entry removed in LOADEDMODULES.

Add new test cases to check this duplicate mode entries in all situation
where _LMFILES_ content is involved.
2018-01-13 16:51:49 +01:00
Xavier Delaruelle
0dff2adc9f testsuite: add module-virtual cmd tests 2018-01-13 16:27:49 +01:00
Xavier Delaruelle
ab3959b892 testsuite: add virtual modules location tests 2018-01-13 16:27:49 +01:00
Xavier Delaruelle
a9fe270267 Cache modulefile validity check result
Add in checkValidModule procedure a 'g_modfileValid' global array to
save validity check result of a modulefile at first query, then reuse
this cached result on subsequent queries on same modulefile.
2018-01-13 16:27:49 +01:00
Xavier Delaruelle
e1a1481cac Cache file mtime query results
Add 'getFileMtime' to query file modification time. On first call, cache
the result then use cache on subsequent calls for the same file.
2018-01-13 16:27:49 +01:00
Xavier Delaruelle
66f697287e Find modulepath of virtual module on 'search' cmd
Add 'findModulepathFromModulefile' procedure to get the modulepath
corresponding to a passed modulefile (or modulerc).

Adapt 'search' cmd when looking at module alias target, to correctly
handle virtual modules. Modulepath directory is retrieved, when detecting
a virtual module, from the modulerc file that has defined this virtual
module.
2018-01-13 16:27:49 +01:00
Xavier Delaruelle
0fd6699c77 Handle loaded virtual modules on 'list' cmd
Introduce 'isModuleVirtual' procedure to detect a module is virtual
based on its name and modulefile. A module is stated virtual if its name
cannot be found at end of its modulefile name.

When looking at loaded modules during a 'list' command, treat
specifically virtual modules, almost like full path modules.

Tags on loaded virtual module are not search as once loaded we do not
know anymore from what modulepath directory the virtual module was
coming from.
2018-01-13 16:27:49 +01:00
Xavier Delaruelle
93892647f3 Treat file relative to cwd in source/unsource
So a relative file to source from a modulefile or modulerc, is relative
starting from the directory of the modulefile/modulerc sourcing it.

Add a specific case to treat empty file name by the way.
2018-01-13 16:27:49 +01:00
Xavier Delaruelle
e2bb42a4c7 Specific err on cmdModuleUse when empty dir name 2018-01-13 14:04:35 +01:00
Xavier Delaruelle
7c0e21bc95 Cwd during interp corresponds to modfile dir
Now getAbsolutePath procedure, which make a path passed as argument an
absolute path, check the current path of the interpreted modulefile or
modulerc rather always taking the current path of the module command
execution.

So a modulefile or modulerc can use relative paths based on a
determistic way as it is now based on their location. Previously it was
not possible as relative paths were dependent of the location from where
the module command was executed.

If ModulesCurrentModulefile variable is not empty, getAbsolutePath nows
it is called during a modulefile/modulerc interpretation, so it takes
the directory name of this ModulesCurrentModulefile as current working
directory.
2018-01-13 14:04:35 +01:00
Xavier Delaruelle
261970ce6b Handle ModulesCurrentModulefile in a push/pop fashion
Refactor handling of the ModulesCurrentModulefile public global variable
to get same treatment like ModuleName with a push/pop mechanism.

Then call to the new pushModuleFile and popModuleFile procedures is
gathered in the execute-modulefile and execute-modulerc procedures to
push filename before interpretation and popping it when interpretation
is done.

Change is that ModulesCurrentModulefile is reset after interpretation,
so when this variable is queried in a master interpretation context it
is possible to know if some file is currently being interpreted or not
(value restored to the empty string).
2018-01-13 14:04:35 +01:00
Xavier Delaruelle
26502e2b04 Introduce 'module-virtual' modulefile command
Introduce the virtual module concept with the 'module-virtual'
modulefile command. This new command takes a module name as first
argument and a modulefile location as second argument.

A virtual module stands for this module name associated to a modulefile.
The modulefile is the script interpreted when loading or unloading the
virtual module which appears or can be found with its virtual name.

Like a module aliases, virtual modules are expected to be defined within
modulerc files (at whatever rc level). Virtual modules can be targeted
by aliases or symbolic versions. They also compete with aliases and
regular modules for the implicit default version of a module.

Multiple virtual modules may target the same modulefile, which can
distinguish between these various virtual names by use of the
"[module-info name]" command.

A virtual module cannot be loaded using a full path name (merge of its
module path and its module name) as this file does not exist.

Based on a proof of concept made by Bert Wesarg [1].

[1] https://github.com/bertwesarg/modules-tcl/commit/545e9f
2018-01-13 14:02:44 +01:00
Xavier Delaruelle
3425d25b06 Correctly handle list var when reset interp
When restoring an initial interpreter variable which was a list, issue
occured as the 'slave eval set' was given more than one value argument.
Passing values enclosed in a 'list' fixes the issue.

Improve non-regression tests to ensure expected handling will persist
over times.

Closes #145
2018-01-05 07:45:51 +01:00
Xavier Delaruelle
14386755b4 testsuite: check modulecmd on compat only if inst. 2018-01-04 07:52:10 +01:00
Xavier Delaruelle
9c45a20bb2 doc: desc MODULES_CMD var and modulecmd wrapper 2018-01-04 07:15:37 +01:00
Xavier Delaruelle
a8c2512da2 testsuite: check modulecmd in install suite 2018-01-04 06:59:21 +01:00
Xavier Delaruelle
885e4b6ded install: introduce modulecmd wrapper script
Which execute the module command bin corresponding to active flavor.
2018-01-04 06:30:39 +01:00
Xavier Delaruelle
33941816c0 Expose current modulecmd with MODULES_CMD env var 2018-01-03 08:33:22 +01:00
Xavier Delaruelle
0a48439918 Fix removal of tmp moduleinit.cmake.XXXXXXXXXXXX 2018-01-02 11:07:19 +01:00
Xavier Delaruelle
154f2da690 doc: dsc versioning, Tcl {} and .modspath parse in NEWS 2018-01-02 09:31:46 +01:00
Xavier Delaruelle
832552198f testsuite: esc install path for pager regexp tests 2018-01-02 08:42:11 +01:00
Xavier Delaruelle
4500410b8a install: reinit module code in version modfile
Adapt version modulefile, which is deployed in versioning installation
mode, to re-initialize module command during its unload, to restore the
command of the previously loaded version.

Goes through a full re-initialization to overcome incompatible
definition of the module command between version 3 and 4.

This full re-initialization cannot be attempted on scripting shells,
like Perl or Python, as function re-definition is not a common practice
on these languages.
2017-12-31 13:26:40 +01:00
Xavier Delaruelle
627aee1abf doc: update diff_v3_v4 with 4.1 changes so far 2017-12-30 22:15:06 +01:00
Xavier Delaruelle
8864cd19e1 doc: desc. variable ref support in MODULEPATH 2017-12-30 14:13:36 +01:00
Xavier Delaruelle
2f38385c75 testsuite: fix regexp-tests not escaping modfile paths 2017-12-30 10:58:43 +01:00
Xavier Delaruelle
b1926ff0a4 testsuite: check versioning-specific modfile install 2017-12-30 10:09:54 +01:00
Xavier Delaruelle
c0f0be1258 testsuite: support 3-arg cmd on cmake test script 2017-12-30 09:56:48 +01:00
Xavier Delaruelle
2441251ef1 install: add @VERSION@ pattern
Introduce the '@VERSION@' pattern, combination of Modules release and
build information, for building files to install.

Still rely on @MODULES_RELEASE@ and @MODULES_BUILD@ when these
information are needed prior to ./configure call (dist-related stuff) or
are expected to change after ./configure call (modulecmd.tcl in
dev environment).
2017-12-29 18:55:35 +01:00
Xavier Delaruelle
44ce0d4df5 travis: enable versioning install on some test cases 2017-12-29 17:44:33 +01:00
Xavier Delaruelle
f50e3e40d3 testsuite/travis: adapt modpath in ex cfg if versioning
Adapt defined modulepaths in example testsuite configuration file
(modulerc and .modulespath) depending if versioning installation mode is
enabled or not.
2017-12-29 17:27:52 +01:00
Xavier Delaruelle
3b3ed9d3f7 testsuite/travis: add an empty .modulespath example
Check behavior when .modulespath exists but does not hold any path to
add to MODULEPATH.
2017-12-28 22:08:47 +01:00
Xavier Delaruelle
527e4fbaa0 Correct parsing of init/.modulespath lines w/o comment 2017-12-28 21:42:25 +01:00
Xavier Delaruelle
5d6c6278e5 Fix MODULEPATH init when init/.modulespath empty 2017-12-28 21:42:25 +01:00
Xavier Delaruelle
f61d6b85b3 init: change 'string contains' tests for ksh
Adapt the 'string contains' tests in ksh init script (used to setup
FPATH, PATH and MANPATH without duplicates) to correctly handle paths
containing '+' character, which is detected as a pattern-specific
character on the '=~' test condition previously used.
2017-12-28 21:42:25 +01:00
Xavier Delaruelle
6b81b8a185 install: adapt default modpath if versioning set
If --enable-versioning configure option is set, default modulepath option
is changed  from '$prefix/modulefiles' to
'$baseprefix/$MODULE_VERSION/modulefiles'.

Adapt installation process to handle modulepath containing special '$'
character. Adapt also install testsuite to correctly check these
modulepaths containing variable references.
2017-12-28 21:42:25 +01:00
Xavier Delaruelle
e7d6c48851 Set env var on Tcl with val enclosed in {}
Produce environment variable set code for Tcl shell with value enclosed
in curly braces {} rather double-quote "". Curly braces are more
effective to protect value from interpretation, like if it contains a
dollar character.
2017-12-28 21:42:25 +01:00
Xavier Delaruelle
dbd86817c7 install: deploy MODULE_VERSION and version modfile
When --enable-versioning is set at configure time, deploy the setup of
the MODULE_VERSION and MODULE_VERSION_STACK environment variables in
modulecmd.tcl and in a version-specific modulefile.

This version-specific modulefile is deployed in a @baseprefix@/versions
modulepath directory, which is also created specifically for versioning
installation mode.

MODULE_VERSION and MODULE_VERSION_STACK environment variables setup in
modulecmd.tcl is commented if versioning installation mode is not
enabled rather deleted to guaranty consistency across code coverage
tests (same code line numbering whatever the installation options set).

version-specific modulefile is a bit different than the one used before
<4.0 as now module version is initialized when loading this module by
calling the autoinit action on the modulecmd.tcl script.

These version-specific modulefiles enable to switch from one module
version to another but there is an incompatibility of initialization
between Modules 3.2 and Modules >=4. Switching from Modules 3.2 to
Modules >4 will be possible, but not going back from >4 to version 3.2.
2017-12-28 21:42:25 +01:00
Xavier Delaruelle
10c5d8f2d8 Solve env var reference in MODULEPATH
Restore the ability of C-version to resolve environment variable
reference put in MODULEPATH elements. Path element is registered in
MODULEPATH variable with its variable references. When path entry is
used, variable references are solved to get real path.

Add a 'resolvStringWithEnv' procedure to handle resolution of
environment variable references set in string.

Re-enable non-regression tests of 95-version suite.
2017-12-27 09:23:10 +01:00
Xavier Delaruelle
94075351ad install: add --enable-versioning
Add '--enable-versioning' configure option to append Modules version to
the chosen installation prefix.
2017-12-27 09:23:10 +01:00
Xavier Delaruelle
b9fe7bbb17 testsuite/travis: fix testconfig removal of etcdir 2017-12-24 12:18:02 +01:00
Xavier Delaruelle
42ee418a1d doc: desc. siteconfig.tcl in NEWS 2017-12-23 18:37:35 +01:00
Xavier Delaruelle
a7993020ab testsuite/travis: add an example siteconfig.tcl
Add 'install-testsiteconfig' make target to setup a dummy siteconfig.tcl
file in install_etcdir. Link that to some of the travis checks to run
testsuite with an existing siteconfig.tcl
2017-12-23 18:22:20 +01:00
Xavier Delaruelle
03c333ec91 Transparently bufferize err report before pager init
Define a global g_init_errreport flag to know within report or
reportErrorAndExit procedure if error reporting has been initialized or
not. If not yet initialized, call to output message is saved in a buffer
list.

A 'initErrorReport' procedure is added to switch 'g_init_errreport' flag
and output every messages saved in buffer list.

With this change, it is possible to use reportDebug, reportWarning,
reportErrorAndExit, etc procedures transparently without having to know
if error reporting has been enabled or not. The report procedures can
then be used in siteconfig.tcl extension without messing paging output.

Regarding reportDebug, g_init_errreport enables to know if call has to
be saved since if error report is not initialized, debug mode status is
not yet known.
2017-12-23 18:22:20 +01:00
Xavier Delaruelle
353b9d662c Introduce @etcdir@/siteconfig.tcl script
Add the possibility to setup a site-specific configuration Tcl script
which will be sourced at the start of modulecmd.tcl. This site-specific
Tcl script enables to supersede global variable and procedure definition
made in modulecmd.tcl. This way local adaptations can be made without
editing the modulecmd.tcl script.

'--etcdir' configure option is added to specify the location of the
site-specific configuration script.
2017-12-23 18:22:20 +01:00
Xavier Delaruelle
29b5f925c7 doc: desc work on *-path commands in NEWS 2017-12-22 08:43:01 +01:00
Xavier Delaruelle
a0ecbde160 Improve getReferenceCountArray proc debug message 2017-12-21 06:53:16 +01:00
Xavier Delaruelle
b3d0ae7db0 Always set/unset var when removing path in it
Even if no change on variable value, always set (or unset) this variable
as its relative counter reference variable is always set (or unset).
2017-12-21 06:36:43 +01:00