Skip to content

modules test not performing loads #436

Description

@ben-bowers

Describe the bug

In an attempt to refactor modulefiles into separate common modulefiles, ModuleTests no longer operate as expected.
Presumably this is because when run in test-mode the dependent modulefiles are not loaded. Since the top level module relies on a setenv from the sub-modulefile, the variable evaluates incorrectly and the test fails.

This may be a feature rather than a bug - but if there is some workaround, that would be helpful to know.

To Reproduce

Steps to reproduce the behavior:

$ module test fake_tool
-------------------------------------------------------------------
Module Specific Test for /home/bbowers/modulefiles/fake_tool:

/fake/bin
Test result: FAIL

For modules v4.3 to v4.7, the output is:

_UNDEFINED_/fake/bin
Test result: FAIL

Location and content of any modulerc or modulefile involved:

$ cat fake_base_path 
#%Module1.0 # -*- tcl -*-
setenv BASE_PATH /home/bbowers

$ cat fake_tool
#%Module1.0 # -*- tcl -*-
module load fake_base_path
set toolpath [getenv BASE_PATH]/fake/bin
prepend-path PATH $toolpath
proc ModulesTest {} {
    global toolpath
    puts stderr $toolpath
    return [file exist $toolpath]
}

Expected behavior

It would be convenient if sub-modulefiles are loaded as part of the module test so that it is possible to refactor common parts of the modulefiles. If that is considered breaking behavior, then maybe a mode that enables loads/prereq during the test?

Error and debugging information

$ module --debug <command1> <arguments>
$ module --debug <command2> <arguments>
...

Modules version and configuration

Tested across several versions:

$ module --version
Modules Release 4.3.1 (2019-09-21)
Modules Release 4.7.1 (2021-04-06)
Modules Release 5.0.0 (2021-09-12)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions