Skip to content

Commit

Permalink
Merge pull request #34 from buildtesters/increase_regtest_spider_class
Browse files Browse the repository at this point in the history
add example modulefiles to be used in regression test to test spider class
  • Loading branch information
shahzebsiddiqui authored Oct 18, 2022
2 parents 97b33af + 2f99800 commit 837cff1
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
.. |codecov| image:: https://codecov.io/gh/buildtesters/lmodule/branch/master/graph/badge.svg
:target: https://codecov.io/gh/buildtesters/lmodule
.. |slack| image:: http://hpcbuildtest.herokuapp.com/badge.svg
:target: https://hpcbuildtest.slack.com

Lmodule (Lmod Module)
---------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import os
import sys

sys.path.insert(0, os.path.abspath(".."))
here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, here)

from lmod import LMODULE_VERSION
from sphinx.ext.apidoc import main as sphinx_apidoc
Expand Down
1 change: 1 addition & 0 deletions tests/modules/core/gcc/.modulerc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module_version("gcc/9.3.0", "default")
2 changes: 2 additions & 0 deletions tests/modules/core/gcc/9.3.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
local gcc_root = pathJoin(os.getenv("LMODULE_MODULE_ROOT"), 'gcc')
prepend_path("MODULEPATH", gcc_root)
2 changes: 2 additions & 0 deletions tests/modules/gcc/openmpi/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#%Module
set ModulesVersion "3.0"
1 change: 1 addition & 0 deletions tests/modules/gcc/openmpi/3.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
help("OpenMPI 3.0")
1 change: 1 addition & 0 deletions tests/modules/gcc/openmpi/3.1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
help("OpenMPI 3.1")
10 changes: 4 additions & 6 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_avail(self):
a.avail("lmod")

def test_collection(self):
cmd = Module(["settarg"],debug=True)
cmd = Module(["settarg"], debug=True)
# save as collection name "settarg"
cmd.save("settarg")
# save as "default" collection
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_test_collection_type_mismatch(self):
raises=TypeError,
)
def test_type_error(self):
a = Module(1)
Module(1)

def test_modules_in_login(self):
a = Module("lmod", debug=True)
Expand All @@ -116,12 +116,10 @@ def test_spider(self):
a = Module()
a.spider()

a = Module('gcc')
a = Module("gcc")
a.spider()
a.spider("gcc")
a.spider(['lmod', 'settarg'])

a.spider(["lmod", "settarg"])

with pytest.raises(TypeError):
a.spider(1)

18 changes: 17 additions & 1 deletion tests/test_spider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
from lmod.spider import Spider

lmodule_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.environ["LMODULE_MODULE_ROOT"] = os.path.join(lmodule_root, "tests", "modules")
module_tree = os.path.join(os.getenv("LMODULE_MODULE_ROOT"), "core")


class TestSpider:
def test_get_spider_trees(self):
Expand All @@ -27,7 +31,7 @@ def test_get_names(self):
def test_get_modules(self):
"""This test will retrieve full canonical module names from ``get_modules`` method which is expected to return a
dictionary"""
a = Spider()
a = Spider(module_tree)
# this will return the full canonical module name which should be a list.
assert isinstance(a.get_modules(), dict)

Expand All @@ -36,3 +40,15 @@ def test_get_parents(self):
a = Spider()
parent_modules = a.get_parents()
assert isinstance(parent_modules, list)

a = Spider(module_tree)
assert "gcc/9.3.0" in a.get_parents()

def test_get_all_versions(self):

a = Spider(module_tree)
openmpi_versions = a.get_all_versions("openmpi")
assert "3.0" in openmpi_versions
assert "3.1" in openmpi_versions

assert not a.get_all_versions("lmod")

0 comments on commit 837cff1

Please sign in to comment.