-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic install test #29
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Basic install of zopen | ||
# | ||
|
||
fail(){ echo "$@"; exit 8; } | ||
WORKDIR="$1" | ||
|
||
zopenenv="${WORKDIR}/zopen-env-$(basename "$0")" | ||
[ -e "${zopenenv}" ] && echo "Clearing existing work env" && rm -rf "${zopenenv}" | ||
|
||
mkdir -p "${zopenenv}" | ||
zopen_tool_binary=$(whence zopen) | ||
zopen init -y --re-init "${zopenenv}" #specify re-init to ensure an env | ||
echo "Rc=$?" | ||
|
||
echo "Testing if zopen was installed at: ${zopenenv}/usr/local/zopen" | ||
[ ! -e "${zopenenv}/usr/local/zopen" ] && echo "File system not available" && exit 8 | ||
echo "Testing source of the zopen-config file" | ||
[ ! -e "${zopenenv}/etc/zopen-config" ] && echo "xopen configuration not available" && exit 8 | ||
|
||
echo "Testing source of configuration file" | ||
# shellcheck disable=SC1091 | ||
. "${zopenenv}/etc/zopen-config" | ||
[ -z "${ZOPEN_ROOTFS}" ] && echo "zopen required envvar ZOPEN_ROOTFS not set" && exit 8 | ||
|
||
echo "Testing the zopen version is set correctly (according to zopen-config)" | ||
zopen_binary=$(whence zopen) | ||
[ ! "${zopen_binary}" = "${zopenenv}/usr/local/bin/zopen" ] && echo "Incorrectly sourced zopen-config" && exit 8 | ||
|
||
echo "Hardcoding test meta into PATH" | ||
# Hac..fix to ensure we use the test meta | ||
export PATH="$(dirname "${zopen_tool_binary}"):${PATH}" | ||
zopen_binary=$(whence zopen) | ||
|
||
[ ! "${zopen_binary}" = "${zopen_tool_binary}" ] && echo "Could not reset to use test meta" && exit 8 | ||
|
||
zopen list --installed | ||
|
||
echo "Installing which [zopen install -y which]" | ||
if ! zopen install -y which; then | ||
fail "Error installing 'which' packages" | ||
fi | ||
|
||
echo "Testing functionality of which" | ||
whichWhich=$(which which) | ||
if [ ! "${whichWhich}" = "${zopenenv}/usr/local/bin/which" ]; then | ||
fail "Wrong which was used: expected: '${zopenenv}/usr/local/bin/which'; actual: '${whichWhich}'" | ||
fi | ||
|
||
echo "Running basic upgrade test [zopen upgrade]" | ||
if ! zopen upgrade; then | ||
fail "Basic upgrade test failed. See previous errors" | ||
fi | ||
|
||
echo "Testing removal [zopen remove which]" | ||
if ! zopen remove which; then | ||
fail "Error during removal of the 'which' package" | ||
fi | ||
if "${zopenenv}/usr/local/bin/which" which; then | ||
fail "The 'which' command should not be available at '${zopenenv}/usr/local/bin/which'" | ||
fi | ||
if ! installList=$(zopen list --installed --no-header --no-version); then | ||
fail "List command [--installed --no-header --no-version] failed" | ||
fi | ||
installedOk=$(echo "${installList}" | grep "which ") | ||
if [ -n "${installedOk}" ]; then | ||
fail "Package 'which' was listed as installed" | ||
fi | ||
|
||
echo "Testing removal of already removed / not installed package [zopen remove which]" | ||
if ! zopen remove which; then | ||
# Note that zopen remove of a non-installed package is not in itself an | ||
# error as it is reporting correctly (that it can't install something that | ||
# is not installed) | ||
fail "Removal of a non-installed package resulted in an error" | ||
|
||
fi | ||
|
||
echo "Test non-valid package [zopen install -y foobar]" | ||
if zopen install -y foobar; then | ||
fail "Attempt to install non-existant package did not fail" | ||
fi | ||
|
||
echo "Test valid package with port suffix [zopen install -y whichport]" | ||
if zopen install -y whichport; then | ||
fail "Attempt to install incorrect package (with port suffix) did not fail" | ||
fi | ||
|
||
echo "Test mis-tagged package [zopen install -y xz%dummytag]" | ||
if zopen install -y xz%dummytag; then | ||
fail | ||
fi | ||
|
||
echo "Test bad tagged, missing package [zopen install -y %25]" | ||
if zopen install -y %25; then | ||
fail | ||
fi | ||
|
||
echo "Test tagged package [zopen install -y xz%25]" | ||
if zopen install -y xz%25; then | ||
fail | ||
fi | ||
|
||
echo "Test not-found versioned package [zopen install -y which=1.2.3.4.5]" | ||
if zopen install -y which=1.2.3.4.5; then | ||
fail "Attempt to install non-existent version of package did not fail" | ||
fi | ||
|
||
echo "Test versioned package [zopen install -y which=2.21.20230328_102133]" | ||
if ! zopen install -y which=2.21.20230328_102133; then | ||
fail "Install of known available version (which 2.21.20230328_102133) failed" | ||
fi | ||
|
||
echo "Test odd versioning [zopen install -y =1.2.3.4]" | ||
if zopen install -y =1.2.3.4; then | ||
fail "Install of versioned package with no package name did not fail" | ||
fi | ||
|
||
[ -e "${zopenenv}" ] && echo "Clearing existing work env" && rm -rf "${zopenenv}" | ||
exit 0 | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add another
zopen remove which
test where we expect it to fail because it's no longer installed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make sense - let me add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, I added some tests for the patch I did on zopen install findutilsport addressing my recent changes.