From 28b49d5d2f312cb832e9ce11b47a718f336ed0c9 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Mon, 11 Dec 2023 11:11:27 +0100 Subject: unit tests: replace /bin/bash with /bin/sh (#41495) --- lib/spack/spack/test/cmd/build_env.py | 4 ++-- lib/spack/spack/test/cmd/ci.py | 2 +- lib/spack/spack/test/compilers/basics.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/test/cmd/build_env.py b/lib/spack/spack/test/cmd/build_env.py index 286fcd5e11..9a302a159c 100644 --- a/lib/spack/spack/test/cmd/build_env.py +++ b/lib/spack/spack/test/cmd/build_env.py @@ -25,7 +25,7 @@ def test_error_when_multiple_specs_are_given(): assert "only takes one spec" in output -@pytest.mark.parametrize("args", [("--", "/bin/bash", "-c", "echo test"), ("--",), ()]) +@pytest.mark.parametrize("args", [("--", "/bin/sh", "-c", "echo test"), ("--",), ()]) @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_build_env_requires_a_spec(args): output = build_env(*args, fail_on_error=False) @@ -35,7 +35,7 @@ def test_build_env_requires_a_spec(args): _out_file = "env.out" -@pytest.mark.parametrize("shell", ["pwsh", "bat"] if sys.platform == "win32" else ["bash"]) +@pytest.mark.parametrize("shell", ["pwsh", "bat"] if sys.platform == "win32" else ["sh"]) @pytest.mark.usefixtures("config", "mock_packages", "working_env") def test_dump(shell_as, shell, tmpdir): with tmpdir.as_cwd(): diff --git a/lib/spack/spack/test/cmd/ci.py b/lib/spack/spack/test/cmd/ci.py index 84e9e66bf0..2695b7381f 100644 --- a/lib/spack/spack/test/cmd/ci.py +++ b/lib/spack/spack/test/cmd/ci.py @@ -2000,7 +2000,7 @@ spack: install_script = os.path.join(working_dir.strpath, "install.sh") with open(install_script, "w") as fd: - fd.write("#!/bin/bash\n\n#fake install\nspack install blah\n") + fd.write("#!/bin/sh\n\n#fake install\nspack install blah\n") spack_info_file = os.path.join(working_dir.strpath, "spack_info.txt") with open(spack_info_file, "w") as fd: diff --git a/lib/spack/spack/test/compilers/basics.py b/lib/spack/spack/test/compilers/basics.py index 910c9e87d9..fa19d507bb 100644 --- a/lib/spack/spack/test/compilers/basics.py +++ b/lib/spack/spack/test/compilers/basics.py @@ -253,8 +253,8 @@ def test_get_compiler_link_paths_load_env(working_env, monkeypatch, tmpdir): gcc = str(tmpdir.join("gcc")) with open(gcc, "w") as f: f.write( - """#!/bin/bash -if [[ $ENV_SET == "1" && $MODULE_LOADED == "1" ]]; then + """#!/bin/sh +if [ "$ENV_SET" = "1" ] && [ "$MODULE_LOADED" = "1" ]; then echo '""" + no_flag_output + """' @@ -699,8 +699,8 @@ def test_compiler_get_real_version(working_env, monkeypatch, tmpdir): gcc = str(tmpdir.join("gcc")) with open(gcc, "w") as f: f.write( - """#!/bin/bash -if [[ $CMP_ON == "1" ]]; then + """#!/bin/sh +if [ "$CMP_ON" = "1" ]; then echo "$CMP_VER" fi """ @@ -745,8 +745,8 @@ def test_compiler_get_real_version_fails(working_env, monkeypatch, tmpdir): gcc = str(tmpdir.join("gcc")) with open(gcc, "w") as f: f.write( - """#!/bin/bash -if [[ $CMP_ON == "1" ]]; then + """#!/bin/sh +if [ "$CMP_ON" = "1" ]; then echo "$CMP_VER" fi """ @@ -799,7 +799,7 @@ def test_compiler_flags_use_real_version(working_env, monkeypatch, tmpdir): gcc = str(tmpdir.join("gcc")) with open(gcc, "w") as f: f.write( - """#!/bin/bash + """#!/bin/sh echo "4.4.4" """ ) # Version for which c++11 flag is -std=c++0x -- cgit v1.2.3-70-g09d2