Skip to content

Commit 3d26860

Browse files
committed
Make test directory modifcation easier
Many of the tests used relative paths for determining the test directories. This made verification of output very difficult if the directory were to change. I plan to add tests for directories that have spaces and additional character patterns and this will allow these tests to be added easier.
1 parent ce6724b commit 3d26860

15 files changed

+43
-41
lines changed

test/branch-all.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ clone-foo-and-bar
1212

1313
(
1414
cd $OWNER/foo
15-
git subrepo clone --quiet ../../../$UPSTREAM/bar one
16-
git subrepo clone --quiet ../../../$UPSTREAM/bar two
15+
git subrepo clone --quiet $UPSTREAM/bar one
16+
git subrepo clone --quiet $UPSTREAM/bar two
1717
add-new-files two/file
1818
)
1919

test/clone.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ clone-foo-and-bar
2828
{
2929
clone_output="$(
3030
cd $OWNER/foo
31-
git subrepo clone ../../../$UPSTREAM/bar
31+
git subrepo clone $UPSTREAM/bar
3232
)"
3333

3434
# Check output is correct:
3535
is "$clone_output" \
36-
"Subrepo '../../../tmp/upstream/bar' (master) cloned into 'bar'." \
36+
"Subrepo '$UPSTREAM/bar' (master) cloned into 'bar'." \
3737
'subrepo clone command output is correct'
3838

3939
remote_output="$(
@@ -50,7 +50,7 @@ clone-foo-and-bar
5050

5151
clone_output_empty="$(
5252
cd $OWNER/empty
53-
catch git subrepo clone ../../../$UPSTREAM/bar
53+
catch git subrepo clone $UPSTREAM/bar
5454
)"
5555

5656
# Check output is correct:
@@ -74,7 +74,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
7474
foo_clone_commit="$(cd $OWNER/foo; git rev-parse HEAD^)"
7575
bar_head_commit="$(cd $OWNER/bar; git rev-parse HEAD)"
7676
test-gitrepo-comment-block
77-
test-gitrepo-field "remote" "../../../$UPSTREAM/bar"
77+
test-gitrepo-field "remote" "$UPSTREAM/bar"
7878
test-gitrepo-field "branch" "master"
7979
test-gitrepo-field "commit" "$bar_head_commit"
8080
test-gitrepo-field "parent" "$foo_clone_commit"

test/encode.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ source test/setup
66

77
use Test::More
88

9-
109
export round=0
1110
test_round() {
1211
clone-foo-and-bar
@@ -19,12 +18,12 @@ test_round() {
1918

2019
clone_output="$(
2120
cd $OWNER/foo
22-
git subrepo clone ../../../$UPSTREAM/bar -- "$normalize_dir"
21+
git subrepo clone $UPSTREAM/bar -- "$normalize_dir"
2322
)"
2423

2524
# Check output is correct:
2625
is "$clone_output" \
27-
"Subrepo '../../../tmp/upstream/bar' (master) cloned into '$normalize_dir'." \
26+
"Subrepo '$UPSTREAM/bar' (master) cloned into '$normalize_dir'." \
2827
'subrepo clone command output is correct'
2928

3029
test-exists "$OWNER/foo/$normalize_dir/"
@@ -42,7 +41,7 @@ test_round() {
4241
cd $OWNER/foo
4342
git subrepo pull -- "$normalize_dir"
4443
)" \
45-
"Subrepo '$normalize_dir' pulled from '../../../tmp/upstream/bar' (master)." \
44+
"Subrepo '$normalize_dir' pulled from '$UPSTREAM/bar' (master)." \
4645
'subrepo pull command output is correct'
4746
}
4847

@@ -61,7 +60,7 @@ test_round() {
6160
cd $OWNER/foo
6261
git subrepo push -- "$normalize_dir"
6362
)" \
64-
"Subrepo '$normalize_dir' pushed to '../../../tmp/upstream/bar' (master)." \
63+
"Subrepo '$normalize_dir' pushed to '$UPSTREAM/bar' (master)." \
6564
'subrepo push command output is correct'
6665
}
6766
}
@@ -86,6 +85,7 @@ test_round '_under_scores_'
8685
test_round '.str%a\nge...'
8786
test_round '~////......s:a^t?r a*n[g@{e.lock'
8887

88+
8989
done_testing
9090

9191
teardown

test/error.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ clone-foo-and-bar
1414
{
1515
is "$(
1616
cd $OWNER/bar
17-
git subrepo --quiet clone ../../../$UPSTREAM/foo
17+
git subrepo --quiet clone $UPSTREAM/foo
1818
add-new-files foo/file
1919
git subrepo --quiet branch foo
2020
catch git subrepo branch foo
@@ -129,7 +129,7 @@ clone-foo-and-bar
129129
cd $OWNER/bar
130130
touch me
131131
git add me
132-
catch git subrepo clone ../../../$UPSTREAM/foo
132+
catch git subrepo clone $UPSTREAM/foo
133133
)" \
134134
"git-subrepo: Can't clone subrepo. Working tree has changes." \
135135
"Error OK: check no working tree changes"

test/fetch.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ subrepo-clone-bar-into-foo
2424
cd $OWNER/foo
2525
git subrepo fetch bar
2626
)" \
27-
"Fetched 'bar' from '../../../tmp/upstream/bar' (master)." \
27+
"Fetched 'bar' from '$UPSTREAM/bar' (master)." \
2828
'subrepo fetch command output is correct'
2929
}
3030

test/gitignore.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ subrepo-clone-bar-into-foo
3232
cd $OWNER/foo
3333
git subrepo pull bar
3434
)" \
35-
"Subrepo 'bar' pulled from '../../../tmp/upstream/bar' (master)." \
35+
"Subrepo 'bar' pulled from '$UPSTREAM/bar' (master)." \
3636
'subrepo pull command output is correct'
3737
}
3838

@@ -49,7 +49,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
4949
foo_pull_commit="$(cd $OWNER/foo; git rev-parse HEAD^)"
5050
bar_head_commit="$(cd $OWNER/bar; git rev-parse HEAD)"
5151
test-gitrepo-comment-block
52-
test-gitrepo-field "remote" "../../../$UPSTREAM/bar"
52+
test-gitrepo-field "remote" "$UPSTREAM/bar"
5353
test-gitrepo-field "branch" "master"
5454
test-gitrepo-field "commit" "$bar_head_commit"
5555
test-gitrepo-field "parent" "$foo_pull_commit"

test/pull-message.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ subrepo-clone-bar-into-foo
2323
cd $OWNER/foo
2424
git subrepo pull -m 'Hello World' bar
2525
)" \
26-
"Subrepo 'bar' pulled from '../../../tmp/upstream/bar' (master)." \
26+
"Subrepo 'bar' pulled from '$UPSTREAM/bar' (master)." \
2727
'subrepo pull command output is correct'
2828
}
2929

@@ -47,7 +47,7 @@ subrepo-clone-bar-into-foo
4747
cd $OWNER/foo
4848
GIT_EDITOR='echo cowabunga >' git subrepo pull -e bar
4949
)" \
50-
"Subrepo 'bar' pulled from '../../../tmp/upstream/bar' (master)." \
50+
"Subrepo 'bar' pulled from '$UPSTREAM/bar' (master)." \
5151
'subrepo pull command output is correct'
5252
}
5353

@@ -71,7 +71,7 @@ subrepo-clone-bar-into-foo
7171
cd $OWNER/foo
7272
GIT_EDITOR=true git subrepo pull -e -m original bar
7373
)" \
74-
"Subrepo 'bar' pulled from '../../../tmp/upstream/bar' (master)." \
74+
"Subrepo 'bar' pulled from '$UPSTREAM/bar' (master)." \
7575
'subrepo pull command output is correct'
7676
}
7777

test/pull-new-branch.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
2121
foo_pull_commit=$(cd "$OWNER/foo"; git rev-parse HEAD^)
2222
bar_head_commit=$(cd "$OWNER/bar"; git rev-parse HEAD)
2323
test-gitrepo-comment-block
24-
test-gitrepo-field remote "../../../$UPSTREAM/bar"
24+
test-gitrepo-field remote "$UPSTREAM/bar"
2525
test-gitrepo-field branch master
2626
test-gitrepo-field commit "$bar_head_commit"
2727
test-gitrepo-field parent "$foo_pull_commit"
@@ -37,7 +37,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
3737
foo_pull_commit=$(cd "$OWNER/foo"; git rev-parse HEAD^)
3838
bar_head_commit=$(cd "$OWNER/bar"; git rev-parse HEAD)
3939
test-gitrepo-comment-block
40-
test-gitrepo-field remote "../../../$UPSTREAM/bar"
40+
test-gitrepo-field remote "$UPSTREAM/bar"
4141
test-gitrepo-field branch branch1
4242
test-gitrepo-field commit "$bar_head_commit"
4343
test-gitrepo-field parent "$foo_pull_commit"

test/pull.t

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ subrepo-clone-bar-into-foo
2323
cd $OWNER/foo
2424
git subrepo pull bar
2525
)" \
26-
"Subrepo 'bar' pulled from '../../../tmp/upstream/bar' (master)." \
26+
"Subrepo 'bar' pulled from '$UPSTREAM/bar' (master)." \
2727
'subrepo pull command output is correct'
2828
}
2929

@@ -40,7 +40,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
4040
foo_pull_commit="$(cd $OWNER/foo; git rev-parse HEAD^)"
4141
bar_head_commit="$(cd $OWNER/bar; git rev-parse HEAD)"
4242
test-gitrepo-comment-block
43-
test-gitrepo-field "remote" "../../../$UPSTREAM/bar"
43+
test-gitrepo-field "remote" "$UPSTREAM/bar"
4444
test-gitrepo-field "branch" "master"
4545
test-gitrepo-field "commit" "$bar_head_commit"
4646
test-gitrepo-field "parent" "$foo_pull_commit"
@@ -63,7 +63,7 @@ gitrepo=$OWNER/foo/bar/.gitrepo
6363
{
6464
is "$(
6565
cd $OWNER/foo
66-
git subrepo pull bar
66+
git subrepo pull bar
6767
)" \
6868
"Subrepo 'bar' is up to date." \
6969
'subrepo detects that we dont need to pull'

test/push-new-branch.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ clone-foo-and-bar
1414
cd $OWNER/foo
1515

1616
# Clone the subrepo into a subdir
17-
git subrepo clone ../../../$UPSTREAM/bar
17+
git subrepo clone $UPSTREAM/bar
1818

1919
# Make a commit:
2020
add-new-files bar/FooBar
@@ -29,7 +29,7 @@ clone-foo-and-bar
2929

3030
# Test the output:
3131
is "$message" \
32-
"Subrepo 'bar' pushed to '../../../tmp/upstream/bar' (newbar)." \
32+
"Subrepo 'bar' pushed to '$UPSTREAM/bar' (newbar)." \
3333
'First push message is correct '
3434
}
3535

0 commit comments

Comments
 (0)