Skip to content

Commit

Permalink
Make sure that the Lua tests happen just when Lmod is available
Browse files Browse the repository at this point in the history
  • Loading branch information
damianam committed Aug 9, 2017
1 parent f9ae312 commit d86cd97
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,33 +1290,34 @@ def test_backup_modules(self):
self.assertTrue(re.search(warning, stderr, re.M))
self.assertTrue(re.search(diff, stderr, re.M))

# Test also with lua syntax. In particular, that the backup is not hidden
args = common_args + ['--module-syntax=Lua']

toy_mod = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0-deps.lua')
warning = "WARNING: Old module file found. Backing it up in .* No differences found"
# Test also with lua syntax if Lmod is available. In particular, that the backup is not hidden
if isinstance(self.modtool, Lmod):
args = common_args + ['--module-syntax=Lua']

self.eb_main(args, do_build=True, raise_error=True)
self.assertTrue(os.path.exists(toy_mod))
self.mock_stderr(True)
self.eb_main(args + ['--backup-modules'], do_build=True, raise_error=True)
stderr = self.get_stderr()
self.mock_stderr(False)
self.assertTrue(os.path.exists(toy_mod))
self.assertTrue(os.path.exists(os.path.join(os.path.dirname(toy_mod), os.path.basename(toy_mod)+'.bck')))
self.assertTrue(re.search(warning, stderr, re.M))
toy_mod = os.path.join(self.test_installpath, 'modules', 'all', 'toy', '0.0-deps.lua')
warning = "WARNING: Old module file found. Backing it up in .* No differences found"

warning = "WARNING: Old module file found. Backing it up in .* Diff is:"
diff = "some difference\n"
with open(toy_mod, "a") as fh:
fh.write(diff)
self.mock_stderr(True)
self.eb_main(args + ['--backup-modules'], do_build=True, raise_error=True, verbose=True)
stderr = self.get_stderr()
self.mock_stderr(False)
self.assertTrue(os.path.exists(os.path.join(os.path.dirname(toy_mod), os.path.basename(toy_mod)+'.bck_0')))
self.assertTrue(re.search(warning, stderr, re.M))
self.assertTrue(re.search(diff, stderr, re.M))
self.eb_main(args, do_build=True, raise_error=True)
self.assertTrue(os.path.exists(toy_mod))
self.mock_stderr(True)
self.eb_main(args + ['--backup-modules'], do_build=True, raise_error=True)
stderr = self.get_stderr()
self.mock_stderr(False)
self.assertTrue(os.path.exists(toy_mod))
self.assertTrue(os.path.exists(os.path.join(os.path.dirname(toy_mod), os.path.basename(toy_mod)+'.bck')))
self.assertTrue(re.search(warning, stderr, re.M))

warning = "WARNING: Old module file found. Backing it up in .* Diff is:"
diff = "some difference\n"
with open(toy_mod, "a") as fh:
fh.write(diff)
self.mock_stderr(True)
self.eb_main(args + ['--backup-modules'], do_build=True, raise_error=True, verbose=True)
stderr = self.get_stderr()
self.mock_stderr(False)
self.assertTrue(os.path.exists(os.path.join(os.path.dirname(toy_mod), os.path.basename(toy_mod)+'.bck_0')))
self.assertTrue(re.search(warning, stderr, re.M))
self.assertTrue(re.search(diff, stderr, re.M))

def test_package(self):
"""Test use of --package and accompanying package configuration settings."""
Expand Down

0 comments on commit d86cd97

Please sign in to comment.