Repository navigation
Run bash script tests under sh and add ShellSpec specs for bootstrap-salt.sh - #2143
Merged
Merged
Conversation
The script is POSIX sh and Debian/Ubuntu run it under dash, so a bashism would pass tests that run the extracted functions under bash. Use "sh" by default; BOOTSTRAP_TEST_SHELL overrides it (e.g. "dash"). On Windows, Git's sh has no default PATH for "env -i", which the script relies on, so skip unless BOOTSTRAP_TEST_SHELL is set explicitly.
Add ShellSpec specs that load functions from bootstrap-salt.sh by extracting them, since the script cannot be sourced without running. Cover __rewrite_repo_url and the RHEL repository install (with mocked fetch and yum, including the existing-file and -F paths), and the version and string helpers. Run them under dash and bash in a new test-shell CI job (ShellSpec 0.28.1, pinned), required by the pipeline status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Phases 1 and 2 covered the PowerShell script. This PR improves how the bash script's functions are tested. Two things were weak: the function-level pytest tests ran under bash even though the script is POSIX sh, and there was no way to test a function with its package manager and network calls mocked.
Changes
What issues does this PR fix or reference?
Phase 3 of #2139