Skip to content

Commit

Permalink
Post-review edits
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
  • Loading branch information
jandubois committed May 1, 2023
1 parent e43a256 commit be2bc51
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
15 changes: 15 additions & 0 deletions bats/tests/helpers/info.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load load.bash

# This file exists to print information about the configuration just once, e.g.
#
# bats test/helpers/info.bash tests/*
#
# This can't be done during normal `load` operation because then it would be
# printed for every single test run.

# The info output is wrapped in a dummy test because bats doesn't execute
# files that don't contain at least a single test case.

@test "info" {
echo "Using '$RD_LOCATION' install; resources '$PATH_RESOURCES'" >&3
}
15 changes: 6 additions & 9 deletions bats/tests/helpers/load.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
set -o errexit -o nounset -o pipefail

# Get absolute path names for current and top directories
PATH_BATS_HELPERS=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd
)
PATH_BATS_ROOT=$(
cd "$PATH_BATS_HELPERS/../.."
pwd
)
absolute_path() {
(cd "$1"; pwd)
}

PATH_BATS_HELPERS=$(absolute_path "$(dirname "${BASH_SOURCE[0]}")")
PATH_BATS_ROOT=$(absolute_path "$PATH_BATS_HELPERS/../..")

# Use fatal() to abort loading helpers; don't run any tests
fatal() {
Expand Down
28 changes: 16 additions & 12 deletions bats/tests/helpers/paths.bash
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# PATH_BATS_ROOT and PATH_BATS_HELPERS are already set by load.bash

PATH_REPO_ROOT=$(
# We are running with `set -o errexit`, so no need for explicit error checking
# shellcheck disable=SC2164
cd "$PATH_BATS_ROOT/.."
pwd
)
PATH_REPO_ROOT=$(absolute_path "$PATH_BATS_ROOT/..")

inside_repo_clone() {
[ -d "$PATH_REPO_ROOT/pkg/rancher-desktop" ]
}

set_path_resources() {
local system=$1
Expand All @@ -18,15 +17,20 @@ set_path_resources() {
RD_LOCATION=system
elif [ -d "$user" ]; then
RD_LOCATION=user
elif [ -d "$PATH_REPO_ROOT/pkg/rancher-desktop" ]; then
# dist and npm only work when inside a repo clone
elif inside_repo_clone; then
if [ -d "$dist" ]; then
RD_LOCATION=dist
else
RD_LOCATION=npm
fi
else
fatal "Could not locate Rancher Desktop installation"
(
echo "Couldn't locate Rancher Desktop in"
echo "- \"$system\""
echo "- \"$user\""
echo "and 'npm run dev' is unavailable outside repo clone"
) >&3
exit 1
fi
fi
if using_npm_run_dev; then
Expand All @@ -50,14 +54,14 @@ if is_macos; then
PATH_EXTENSIONS="$PATH_APP_HOME/extensions"
LIMA_HOME="$PATH_APP_HOME/lima"

DIST_ARCH="mac"
ELECTRON_DIST_ARCH="mac"
if is_macos arm64; then
DIST_ARCH="mac-arm64"
ELECTRON_DIST_ARCH="mac-arm64"
fi
set_path_resources \
"/Applications/Rancher Desktop.app" \
"$HOME/Applications/Rancher Desktop.app" \
"$PATH_REPO_ROOT/dist/$DIST_ARCH/Rancher Desktop.app" \
"$PATH_REPO_ROOT/dist/$ELECTRON_DIST_ARCH/Rancher Desktop.app" \
"Contents/Resources/resources"
fi

Expand Down

0 comments on commit be2bc51

Please sign in to comment.