Skip to content

Commit 36c9fda

Browse files
committed
chore: Export BASE_DIR environment variable
New users to `asdf` who wish to contribute will run into the following errors when running `./scripts/test.bash`: ``` ✗ help should show dummy plugin help specific to version when version is present [7] (from function `setup_asdf_dir' in file test/test_helpers.bash, line 16, from function `setup' in test file test/help_command.bats, line 6) `setup_asdf_dir' failed mkdir: cannot create directory ‘/w spacetest_help_should_show_dummy_plugin_help_specific_to_version_when_version_is_present’: Permission denied ``` This is due to paths within the various test suites relying on the `BASE_DIR` environment variable, which is not set by default. This pull request modifies `scripts/test.bash` to correctly export `BASE_DIR` Note: I am a long-time asdf user, who would like to contribute to the project and noticed this while setting up my dev environment on an up-to-date Arch Linux system. My intention is to work on this issue: #2042
1 parent a28559b commit 36c9fda

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

scripts/test.bash

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env bash
22

33
set -euo pipefail
4-
IFS=$'\n\t'
54

65
print.info() {
76
printf '[INFO] %s\n' "$1"
@@ -11,18 +10,21 @@ print.error() {
1110
printf '[ERROR] %s\n' "$1" >&2
1211
}
1312

14-
{
15-
repo_dir=$(git rev-parse --show-toplevel)
16-
current_dir=$(pwd -P)
17-
if [ "$repo_dir" != "$current_dir" ]; then
18-
print.error "This scripts requires execution from the repository root directory."
19-
printf "\t%s\t%s\n" "Repo root dir:" "$repo_dir"
20-
printf "\t%s\t%s\n\n" "Current dir:" "$current_dir"
21-
exit 1
22-
fi
23-
}
13+
BASE_DIR="$(git rev-parse --show-toplevel)"
14+
readonly BASE_DIR
15+
export BASE_DIR
16+
17+
current_dir="$(pwd -P)"
18+
readonly current_dir
19+
20+
if [[ $BASE_DIR != "$current_dir" ]]; then
21+
print.error "This script requires execution from the repository root directory."
22+
printf "\t%s\t%s\n" "asdf repo root dir:" "$BASE_DIR" >&2
23+
printf "\t%s\t%s\n\n" "current dir:" "$current_dir" >&2
24+
exit 1
25+
fi
2426

25-
test_directory="./test"
27+
readonly test_directory="$BASE_DIR/test"
2628
bats_options=(--timing --print-output-on-failure)
2729

2830
if command -v parallel >/dev/null; then
@@ -35,5 +37,5 @@ else
3537
print.info "For faster test execution, install GNU parallel."
3638
fi
3739

38-
print.info "Running Bats in directory '${test_directory}' with options:" "${bats_options[@]}"
40+
print.info "Running Bats in directory '${test_directory}' with options: '${bats_options[*]}'"
3941
bats "${bats_options[@]}" "${test_directory}"

0 commit comments

Comments
 (0)