File tree Expand file tree Collapse file tree 3 files changed +41
-11
lines changed Expand file tree Collapse file tree 3 files changed +41
-11
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ load 'util/init.sh'
126
126
run do-upgrade ' bpm'
127
127
128
128
assert_success
129
- assert_line -e ' git -C /(.*)/tests/.. /pkg/lib/../.. pull'
129
+ assert_line -e ' git -C /(.*)/bpm/source /pkg/lib/../.. pull'
130
130
}
131
131
132
132
@test " upgrade bpm fails when mixing package names" {
Original file line number Diff line number Diff line change @@ -7,26 +7,29 @@ load 'vendor/bats-core/load'
7
7
load ' vendor/bats-assert/load'
8
8
load ' util/test_util.sh'
9
9
10
- export BPM_TEST_DIR=" $BATS_TMPDIR /bpm"
11
- export BPM_CWD=" $BPM_TEST_DIR /cwd"
12
- export BPM_ORIGIN_DIR=" $BPM_TEST_DIR /origin"
13
- export BPM_MODE_TEST=
14
-
15
10
export LANG=" C"
16
11
export LANGUAGE=" C"
17
12
export LC_ALL=" C"
18
13
export XDG_DATA_HOME=
19
- export PATH=" $BPM_ROOT /pkg/bin:$PATH " # TODO
20
14
21
- export PROGRAM_LIB_DIR=" $BATS_TEST_DIRNAME /../pkg/lib"
22
- export BPM_ROOT=" $BATS_TEST_DIRNAME /.."
15
+ # Test-specific
16
+ export BPM_TEST_DIR=" $BATS_TMPDIR /bpm"
17
+ export BPM_CWD=" $BPM_TEST_DIR /cwd"
18
+ export BPM_ORIGIN_DIR=" $BPM_TEST_DIR /origin"
19
+ export BPM_MODE_TEST=
20
+
21
+ # Stub common variables
22
+ test_util.get_bpm_root
23
+ export BPM_ROOT=" $REPLY "
23
24
export BPM_PREFIX=" $BPM_TEST_DIR /cellar"
24
25
export BPM_PACKAGES_PATH=" $BPM_PREFIX /packages"
25
26
export BPM_INSTALL_BIN=" $BPM_PREFIX /bin"
26
27
export BPM_INSTALL_MAN=" $BPM_PREFIX /man"
27
28
export BPM_INSTALL_COMPLETIONS=" $BPM_PREFIX /completions"
29
+ export PROGRAM_LIB_DIR=" $BPM_ROOT /source/pkg/lib"
28
30
29
- for f in " $BPM_ROOT " /pkg/lib/{commands,util}/?* .sh; do
31
+ export PATH=" $BPM_ROOT /source/pkg/bin:$PATH "
32
+ for f in " $BPM_ROOT " /source/pkg/lib/{commands,util}/?* .sh; do
30
33
source " $f "
31
34
done
32
35
Original file line number Diff line number Diff line change 1
1
# shellcheck shell=bash
2
2
# shellcheck disable=SC2164
3
3
4
+ test_util.get_bpm_root () {
5
+ REPLY=
6
+ if ! REPLY=" $(
7
+ while [[ ! -d " .git" && " $PWD " != / ]]; do
8
+ if ! cd ..; then
9
+ printf " %s\n" " Error: Could not cd to BPM directory"
10
+ exit 1
11
+ fi
12
+ done
13
+
14
+ if [[ $PWD == / ]]; then
15
+ printf " %s\n" " Error: Could not find root BPM directory"
16
+ exit 1
17
+ fi
18
+
19
+ # BPM root is the parent directory of 'source', which holds
20
+ # the Git repository
21
+ if ! cd ..; then
22
+ printf " %s\n" " Error: Could not cd to BPM directory"
23
+ exit 1
24
+ fi
25
+ printf " %s" " $PWD "
26
+ ) " ; then
27
+ exit 1
28
+ fi
29
+ }
30
+
4
31
# @description This stubs a command by creating a function for it, which
5
32
# prints the command name and its arguments
6
33
test_util.stub_command () {
@@ -16,7 +43,7 @@ test_util.mock_clone() {
16
43
ensure.non_zero ' destDir' " $destDir "
17
44
18
45
# Be explicit with the 'file' protocol. The upstream "repository"
19
- # is just another (non-bare) Git repository. By default, packages are usually
46
+ # is just another (non-bare) Git repository
20
47
git clone " file://$BPM_ORIGIN_DIR /$srcDir " " $BPM_PACKAGES_PATH /$destDir "
21
48
}
22
49
You can’t perform that action at this time.
0 commit comments