Skip to content

Commit

Permalink
fix shellcheck tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Dec 20, 2023
1 parent 858371a commit e585dea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion constructor/osx/run_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ CONDA_EXEC="$PREFIX/conda.exe"

# Check whether the user wants shortcuts or not
# See check_shortcuts.sh script for details
ENABLE_SHORTCUTS="__ENABLE_SHORTCUTS__"
if [[ -f "$PREFIX/pkgs/user_wants_shortcuts" ]]; then # this implies ENABLE_SHORTCUTS==true
shortcuts="__SHORTCUTS__"
elif [[ "__ENABLE_SHORTCUTS__" == "incompatible" ]]; then
elif [[ "$ENABLE_SHORTCUTS" == "incompatible" ]]; then
shortcuts=""
else
shortcuts="--no-shortcuts"
Expand Down
20 changes: 15 additions & 5 deletions tests/test_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ def test_linux_template_processing():
processed = preprocess(template, params)
for template_string in ["#if", "#else", "#endif"]:
if template_string in processed:
errors.append(f"Found '{template_string}' after "
f"processing header.sh with '{params}'.")
errors.append(
f"Found '{template_string}' after " f"processing header.sh with '{params}'."
)

assert not errors

Expand All @@ -120,13 +121,22 @@ def test_osxpkg_scripts_template_processing(arch, check_path_spaces, script):
@pytest.mark.skipif(available_command("shellcheck") is False, reason="requires shellcheck")
@pytest.mark.parametrize("arch", ["x86_64", "arm64"])
@pytest.mark.parametrize("check_path_spaces", [False, True])
@pytest.mark.parametrize("script", sorted(Path(OSX_DIR).glob("*.sh")))
@pytest.mark.parametrize(
"script", [pytest.param(path, id=str(path)) for path in sorted(Path(OSX_DIR).glob("*.sh"))]
)
def test_osxpkg_scripts_shellcheck(arch, check_path_spaces, script):
with script.open() as f:
data = f.read()
processed = preprocess(data, {"arch": arch, "check_path_spaces": check_path_spaces})
processed = preprocess(
data,
{
"arch": arch,
"check_path_spaces": check_path_spaces,
},
)

findings, returncode = run_shellcheck(processed)
print(*findings, sep="\n")
assert findings == []
assert returncode == 0

Expand All @@ -145,7 +155,7 @@ def test_osxpkg_scripts_shellcheck(arch, check_path_spaces, script):
@pytest.mark.parametrize("has_pre_install", [False])
@pytest.mark.parametrize("arch", ["x86_64", "aarch64"])
@pytest.mark.parametrize("check_path_spaces", [True])
@pytest.mark.parametrize("enable_shortcuts", [True])
@pytest.mark.parametrize("enable_shortcuts", ["true"])
def test_template_shellcheck(
osx,
arch,
Expand Down

0 comments on commit e585dea

Please sign in to comment.