diff --git a/.github/workflows/ubuntu.yaml b/.github/workflows/ubuntu.yaml index 69266ac57..29ad76fe8 100644 --- a/.github/workflows/ubuntu.yaml +++ b/.github/workflows/ubuntu.yaml @@ -25,8 +25,8 @@ jobs: strategy: matrix: os-version: - - '16.04' - '18.04' + - '20.04' python-version: - '2.7' - '3.6' diff --git a/src/rez/tests/test_shells.py b/src/rez/tests/test_shells.py index 28f56e57d..b170f6733 100644 --- a/src/rez/tests/test_shells.py +++ b/src/rez/tests/test_shells.py @@ -11,6 +11,7 @@ from rez.tests.util import TestBase, TempdirMixin, per_available_shell, \ install_dependent from rez.bind import hello_world +from rez.config import config import unittest import subprocess import tempfile @@ -180,19 +181,23 @@ def test_rcfile(self): self.assertEqual(_stdout(p), "Hello Rez World!") os.remove(path) - @per_available_shell() + @per_available_shell(exclude=["cmd", "powershell", "pwsh", "csh", "tcsh"]) @install_dependent() def test_rez_env_output(self): + target_shell = config.default_shell # overridden by test util + def _test(txt): # Assumes that the shell has an echo command, build-in or alias binpath = os.path.join(system.rez_bin_path, "rez-env") - args = [binpath, "--", "echo", txt] + args = [binpath, "--shell", target_shell, "--", "echo", txt] process = subprocess.Popen( args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True ) sh_out = process.communicate() + if sh_out[1]: + raise Exception("Command %r failed:\n%s" % (txt, sh_out[1])) self.assertEqual(sh_out[0].strip(), txt) # please note - it's no coincidence that there are no substrings like diff --git a/src/rez/tests/util.py b/src/rez/tests/util.py index 66a678627..42c988fa9 100644 --- a/src/rez/tests/util.py +++ b/src/rez/tests/util.py @@ -198,8 +198,10 @@ def wrapper(self, *args, **kwargs): return decorator -def per_available_shell(): +def per_available_shell(exclude=None): """Function decorator that runs the function over all available shell types.""" + exclude = exclude or [] + def decorator(func): @functools.wraps(func) def wrapper(self, *args, **kwargs): @@ -216,6 +218,10 @@ def wrapper(self, *args, **kwargs): ] for shell in shells: + if not only_shell and shell in exclude: + print("\nshell excluded from this test: %s..." % shell) + continue + print("\ntesting in shell: %s..." % shell) config.override("default_shell", shell)