Skip to content

Commit d5ecb0a

Browse files
committed
Format scripts
1 parent 8989085 commit d5ecb0a

File tree

2 files changed

+70
-70
lines changed

2 files changed

+70
-70
lines changed

test/scripts/test-utils.sh

+68-68
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function get_test_utls_dir {
1212
local script_path="${BASH_SOURCE[0]}"
1313
local script_dir
1414
if [[ -n "$script_path" ]]; then
15-
script_dir="$(cd "$(dirname "$script_path")" > /dev/null && pwd)"
15+
script_dir="$(cd "$(dirname "$script_path")" >/dev/null && pwd)"
1616
else
17-
script_dir="$(cd "$(dirname "$0")" > /dev/null && pwd)"
17+
script_dir="$(cd "$(dirname "$0")" >/dev/null && pwd)"
1818
fi
1919
echo "$script_dir"
2020
}
@@ -54,7 +54,7 @@ export CURRENT_VERSION
5454
export LATEST_STABLE_RELEASE
5555

5656
function print_available_releases {
57-
for release in $(jq -r '.[].tag_name'<<<"$RELEASES"); do
57+
for release in $(jq -r '.[].tag_name' <<<"$RELEASES"); do
5858
echo "$release"
5959
done
6060
}
@@ -73,7 +73,7 @@ function get_package_dir {
7373
exit 1
7474
fi
7575

76-
mkdir -p "$package_dir" || exit 1
76+
mkdir -p "$package_dir" || exit 1
7777
# Clean up old packages
7878
find "$package_dir" -type f -mtime +5 -delete || true
7979

@@ -89,7 +89,7 @@ function nice_time {
8989
result=$?
9090
fi
9191
s=$SECONDS
92-
echo "\"$*\" completed in $((s/60))m:$((s%60))s"
92+
echo "\"$*\" completed in $((s / 60))m:$((s % 60))s"
9393
return $result
9494
}
9595
# Matches $1 with a build version string and sets the following exported variables:
@@ -122,22 +122,22 @@ function get_app_filename {
122122
version="${BUILD_VERSION}${COMMIT_HASH}${TAG:-}"
123123
fi
124124
case $os in
125-
debian*|ubuntu*)
126-
echo "MullvadVPN-${version}_amd64.deb"
127-
;;
128-
fedora*)
129-
echo "MullvadVPN-${version}_x86_64.rpm"
130-
;;
131-
windows*)
132-
echo "MullvadVPN-${version}.exe"
133-
;;
134-
macos*)
135-
echo "MullvadVPN-${version}.pkg"
136-
;;
137-
*)
138-
echo "Unsupported target: $os" 1>&2
139-
return 1
140-
;;
125+
debian* | ubuntu*)
126+
echo "MullvadVPN-${version}_amd64.deb"
127+
;;
128+
fedora*)
129+
echo "MullvadVPN-${version}_x86_64.rpm"
130+
;;
131+
windows*)
132+
echo "MullvadVPN-${version}.exe"
133+
;;
134+
macos*)
135+
echo "MullvadVPN-${version}.pkg"
136+
;;
137+
*)
138+
echo "Unsupported target: $os" 1>&2
139+
return 1
140+
;;
141141
esac
142142
}
143143

@@ -177,19 +177,19 @@ function get_e2e_filename {
177177
version="${BUILD_VERSION}${COMMIT_HASH}"
178178
fi
179179
case $os in
180-
debian*|ubuntu*|fedora*)
181-
echo "app-e2e-tests-${version}-x86_64-unknown-linux-gnu"
182-
;;
183-
windows*)
184-
echo "app-e2e-tests-${version}-x86_64-pc-windows-msvc.exe"
185-
;;
186-
macos*)
187-
echo "app-e2e-tests-${version}-aarch64-apple-darwin"
188-
;;
189-
*)
190-
echo "Unsupported target: $os" 1>&2
191-
return 1
192-
;;
180+
debian* | ubuntu* | fedora*)
181+
echo "app-e2e-tests-${version}-x86_64-unknown-linux-gnu"
182+
;;
183+
windows*)
184+
echo "app-e2e-tests-${version}-x86_64-pc-windows-msvc.exe"
185+
;;
186+
macos*)
187+
echo "app-e2e-tests-${version}-aarch64-apple-darwin"
188+
;;
189+
*)
190+
echo "Unsupported target: $os" 1>&2
191+
return 1
192+
;;
193193
esac
194194
}
195195

@@ -282,38 +282,38 @@ function run_tests_for_os {
282282
test_dir=$(get_test_utls_dir)/..
283283
read -ra test_filters_arg <<<"${TEST_FILTERS:-}" # Split the string by words into an array
284284
pushd "$test_dir"
285-
if [ -n "${TEST_DIST_DIR+x}" ]; then
286-
if [ ! -x "${TEST_DIST_DIR%/}/test-manager" ]; then
287-
executable_not_found_in_dist_error test-manager
288-
fi
289-
test_manager="${TEST_DIST_DIR%/}/test-manager"
290-
runner_dir_flag=("--runner-dir" "$TEST_DIST_DIR")
291-
else
292-
test_manager="cargo run --bin test-manager"
293-
runner_dir_flag=()
285+
if [ -n "${TEST_DIST_DIR+x}" ]; then
286+
if [ ! -x "${TEST_DIST_DIR%/}/test-manager" ]; then
287+
executable_not_found_in_dist_error test-manager
294288
fi
289+
test_manager="${TEST_DIST_DIR%/}/test-manager"
290+
runner_dir_flag=("--runner-dir" "$TEST_DIST_DIR")
291+
else
292+
test_manager="cargo run --bin test-manager"
293+
runner_dir_flag=()
294+
fi
295295

296-
if [ -n "${MULLVAD_HOST+x}" ]; then
297-
mullvad_host_arg=("--mullvad-host" "$MULLVAD_HOST")
298-
else
299-
mullvad_host_arg=()
300-
fi
296+
if [ -n "${MULLVAD_HOST+x}" ]; then
297+
mullvad_host_arg=("--mullvad-host" "$MULLVAD_HOST")
298+
else
299+
mullvad_host_arg=()
300+
fi
301301

302-
if ! RUST_LOG_STYLE=always $test_manager run-tests \
303-
--account "${ACCOUNT_TOKEN:?Error: ACCOUNT_TOKEN not set}" \
304-
--app-package "${APP_PACKAGE:?Error: APP_PACKAGE not set}" \
305-
"${upgrade_package_arg[@]}" \
306-
"${test_report_arg[@]}" \
307-
--package-dir "${package_dir}" \
308-
--vm "$vm" \
309-
--openvpn-certificate "${OPENVPN_CERTIFICATE:-"assets/openvpn.ca.crt"}" \
310-
"${mullvad_host_arg[@]}" \
311-
"${test_filters_arg[@]}" \
312-
"${runner_dir_flag[@]}" \
313-
2>&1 | sed -r "s/${ACCOUNT_TOKEN}/\{ACCOUNT_TOKEN\}/g"; then
314-
echo "Test run failed"
315-
exit 1
316-
fi
302+
if ! RUST_LOG_STYLE=always $test_manager run-tests \
303+
--account "${ACCOUNT_TOKEN:?Error: ACCOUNT_TOKEN not set}" \
304+
--app-package "${APP_PACKAGE:?Error: APP_PACKAGE not set}" \
305+
"${upgrade_package_arg[@]}" \
306+
"${test_report_arg[@]}" \
307+
--package-dir "${package_dir}" \
308+
--vm "$vm" \
309+
--openvpn-certificate "${OPENVPN_CERTIFICATE:-"assets/openvpn.ca.crt"}" \
310+
"${mullvad_host_arg[@]}" \
311+
"${test_filters_arg[@]}" \
312+
"${runner_dir_flag[@]}" \
313+
2>&1 | sed -r "s/${ACCOUNT_TOKEN}/\{ACCOUNT_TOKEN\}/g"; then
314+
echo "Test run failed"
315+
exit 1
316+
fi
317317
popd
318318
}
319319

@@ -335,10 +335,10 @@ function build_current_version {
335335

336336
if [ ! -f "$app_package" ]; then
337337
pushd "$app_dir"
338-
if [[ $(git diff --quiet) ]]; then
339-
echo "WARNING: the app repository contains uncommitted changes, this script will only rebuild the app package when the git hash changes"
340-
fi
341-
./build.sh
338+
if [[ $(git diff --quiet) ]]; then
339+
echo "WARNING: the app repository contains uncommitted changes, this script will only rebuild the app package when the git hash changes"
340+
fi
341+
./build.sh
342342
popd
343343
echo "Moving '$(realpath "$app_dir/dist/$app_filename")' to '$(realpath "$app_package")'"
344344
mv -n "$app_dir"/dist/"$app_filename" "$app_package"
@@ -348,7 +348,7 @@ function build_current_version {
348348

349349
if [ ! -f "$gui_test_bin" ]; then
350350
pushd "$app_dir"/gui
351-
npm run build-test-executable
351+
npm run build-test-executable
352352
popd
353353
echo "Moving '$(realpath "$app_dir/dist/$gui_test_filename")' to '$(realpath "$gui_test_bin")'"
354354
mv -n "$app_dir"/dist/"$gui_test_filename" "$gui_test_bin"

test/test-by-version.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ usage() {
1818
echo " - TEST_REPORT : path to save the test results in a structured format"
1919
}
2020

21-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
21+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2222
cd "$SCRIPT_DIR"
2323

2424
# shellcheck source=test/scripts/test-utils.sh
2525
source "scripts/test-utils.sh"
2626

27-
if [[ ( "$*" == "--help") || "$*" == "-h" ]]; then
27+
if [[ ("$*" == "--help") || "$*" == "-h" ]]; then
2828
usage
2929
exit 0
3030
fi

0 commit comments

Comments
 (0)