Skip to content

Commit c69b1c9

Browse files
committed
chore(test): run project_open test from any checkout path
1 parent ada449b commit c69b1c9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tests/project_open_test.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ setup_fixture() {
3232
"${ROOT}/deep/a/b/proj/.git"
3333
}
3434

35+
TEST_HOME=""
3536
cleanup() {
3637
[[ -n "${ROOT}" ]] && rm -rf "${ROOT}" "${XDG_CACHE_HOME}"
38+
[[ -n "${TEST_HOME}" ]] && rm -rf "${TEST_HOME}"
3739
}
3840
trap cleanup EXIT
3941

@@ -114,8 +116,14 @@ main() {
114116
setup_fixture
115117
local dotfiles
116118
dotfiles="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
119+
# shell/aliases sources "${HOME}/.dotfiles/shell/os.sh", so point HOME at a
120+
# temp dir whose .dotfiles symlinks to this repo. That lets the test run
121+
# from any checkout path, not only ~/.dotfiles.
122+
TEST_HOME="$(mktemp -d "${TMPDIR:-/tmp}/project_open_home.XXXXXX")"
123+
ln -s "${dotfiles}" "${TEST_HOME}/.dotfiles"
124+
export HOME="${TEST_HOME}"
117125
# shellcheck source=/dev/null
118-
source "${dotfiles}/shell/aliases"
126+
source "${HOME}/.dotfiles/shell/aliases"
119127

120128
test_scan
121129
test_cache

0 commit comments

Comments
 (0)