Commit e97637cd0fe79659a99fd0a466f5adba4e985e6f
1 parent
e0d9ad45ab
Moved common code for creating test plugin repo.
Showing 3 changed files with 25 additions and 58 deletions Inline Diff
tests/.zshenv
1 | # zshrc file written for antigen's tests. Might not be a good one for daily use. | 1 | # zshrc file written for antigen's tests. Might not be a good one for daily use. |
2 | 2 | ||
3 | # See cram's documentation for some of the variables used below. | 3 | # See cram's documentation for some of the variables used below. |
4 | 4 | ||
5 | default_clone="/tmp/antigen-tests-clone-cache" | 5 | default_clone="/tmp/antigen-tests-clone-cache" |
6 | 6 | ||
7 | if [[ ! -d "$default_clone" ]]; then | 7 | if [[ ! -d "$default_clone" ]]; then |
8 | git clone https://github.com/robbyrussell/oh-my-zsh.git "$default_clone" | 8 | git clone https://github.com/robbyrussell/oh-my-zsh.git "$default_clone" |
9 | fi | 9 | fi |
10 | 10 | ||
11 | export ANTIGEN_DEFAULT_REPO_URL="$default_clone" | 11 | export ANTIGEN_DEFAULT_REPO_URL="$default_clone" |
12 | export ADOTDIR="$PWD/dot-antigen" | 12 | export ADOTDIR="$PWD/dot-antigen" |
13 | 13 | ||
14 | rm "$TESTDIR/.zcompdump" | 14 | rm "$TESTDIR/.zcompdump" |
15 | 15 | ||
16 | source "$TESTDIR/../antigen.zsh" | 16 | source "$TESTDIR/../antigen.zsh" |
17 | |||
18 | # A test plugin repository to test out antigen with. | ||
19 | |||
20 | mkdir test-plugin | ||
21 | |||
22 | # A wrapper function over `git` to work with the test plugin repo. | ||
23 | pg () { | ||
24 | git --git-dir test-plugin/.git --work-tree test-plugin "$@" | ||
25 | } | ||
26 | |||
27 | cat > test-plugin/aliases.zsh <<EOF | ||
28 | alias hehe='echo hehe' | ||
29 | EOF | ||
30 | |||
31 | { | ||
32 | pg init | ||
33 | pg add . | ||
34 | pg commit -m 'Initial commit' | ||
35 | } > /dev/null | ||
17 | 36 |
tests/branch-bundle.t
1 | Setup a plugin. | ||
2 | |||
3 | $ mkdir plugin | ||
4 | |||
5 | A git wrapper that works with the plugin's repo. | ||
6 | |||
7 | $ pg () { | ||
8 | > git --git-dir plugin/.git --work-tree plugin "$@" | ||
9 | > } | ||
10 | |||
11 | Setup the plugin repo. | ||
12 | |||
13 | $ pg init | ||
14 | Initialized empty Git repository in .+?/plugin/\.git/? (re) | ||
15 | |||
16 | Master branch content. | ||
17 | |||
18 | $ cat > plugin/aliases.zsh <<EOF | ||
19 | > alias hehe='echo hehe' | ||
20 | > EOF | ||
21 | $ pg add . | ||
22 | $ pg commit -m 'Initial commit' | ||
23 | \[master \(root-commit\) [a-f0-9]{7}\] Initial commit (re) | ||
24 | 1 file changed, 1 insertion(+) | ||
25 | create mode [\d]{6} aliases\.zsh (re) | ||
26 | |||
27 | Branch b1. | 1 | Branch b1. |
28 | 2 | ||
29 | $ pg branch b1 | 3 | $ pg branch b1 |
30 | $ pg checkout b1 | 4 | $ pg checkout b1 |
31 | Switched to branch 'b1' | 5 | Switched to branch 'b1' |
32 | $ cat > plugin/aliases.zsh <<EOF | 6 | $ cat > test-plugin/aliases.zsh <<EOF |
33 | > alias hehe='echo hehe from b1' | 7 | > alias hehe='echo hehe from b1' |
34 | > EOF | 8 | > EOF |
35 | $ pg commit -am 'Change for b1' | 9 | $ pg commit -am 'Change for b1' |
36 | \[b1 [a-f0-9]{7}\] Change for b1 (re) | 10 | \[b1 [a-f0-9]{7}\] Change for b1 (re) |
37 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
38 | 12 | ||
39 | Go back to master. | 13 | Go back to master. |
40 | 14 | ||
41 | $ pg checkout master | 15 | $ pg checkout master |
42 | Switched to branch 'master' | 16 | Switched to branch 'master' |
43 | 17 | ||
44 | Load plugin from b1. | 18 | Load plugin from b1. |
45 | 19 | ||
46 | $ antigen-bundle $PWD/plugin --branch=b1 | 20 | $ antigen-bundle $PWD/test-plugin --branch=b1 |
47 | Cloning into '.+?'\.\.\. (re) | 21 | Cloning into '.+?'\.\.\. (re) |
48 | done. | 22 | done. |
49 | Switched to a new branch 'b1' | 23 | Switched to a new branch 'b1' |
50 | Branch b1 set up to track remote branch b1 from origin. | 24 | Branch b1 set up to track remote branch b1 from origin. |
51 | $ hehe | 25 | $ hehe |
52 | hehe from b1 | 26 | hehe from b1 |
53 | 27 | ||
54 | Load plugin from master. | 28 | Load plugin from master. |
55 | 29 | ||
56 | $ antigen-bundle $PWD/plugin | 30 | $ antigen-bundle $PWD/test-plugin |
57 | Cloning into '.+?'\.\.\. (re) | 31 | Cloning into '.+?'\.\.\. (re) |
58 | done. | 32 | done. |
59 | $ hehe | 33 | $ hehe |
60 | hehe | 34 | hehe |
61 | 35 |
tests/update.t
1 | Setup a plugin. | ||
2 | |||
3 | $ mkdir plugin | ||
4 | |||
5 | A git wrapper that works with the plugin's repo. | ||
6 | |||
7 | $ pg () { | ||
8 | > git --git-dir plugin/.git --work-tree plugin "$@" | ||
9 | > } | ||
10 | |||
11 | Setup the plugin repo. | ||
12 | |||
13 | $ pg init | ||
14 | Initialized empty Git repository in .+?/plugin/\.git/? (re) | ||
15 | |||
16 | Write to the plugin. | ||
17 | |||
18 | $ cat > plugin/aliases.zsh <<EOF | ||
19 | > alias hehe='echo hehe' | ||
20 | > EOF | ||
21 | $ pg add . | ||
22 | $ pg commit -m 'Initial commit' | ||
23 | \[master \(root-commit\) [a-f0-9]{7}\] Initial commit (re) | ||
24 | 1 file changed, 1 insertion(+) | ||
25 | create mode [\d]{6} aliases\.zsh (re) | ||
26 | |||
27 | Load plugin from master. | 1 | Load plugin from master. |
28 | 2 | ||
29 | $ antigen-bundle $PWD/plugin | 3 | $ antigen-bundle $PWD/test-plugin |
30 | Cloning into '.+?'\.\.\. (re) | 4 | Cloning into '.+?'\.\.\. (re) |
31 | done. | 5 | done. |
32 | $ hehe | 6 | $ hehe |
33 | hehe | 7 | hehe |
34 | 8 | ||
35 | Update the plugin. | 9 | Update the plugin. |
36 | 10 | ||
37 | $ cat > plugin/aliases.zsh <<EOF | 11 | $ cat > test-plugin/aliases.zsh <<EOF |
38 | > alias hehe='echo hehe, updated' | 12 | > alias hehe='echo hehe, updated' |
39 | > EOF | 13 | > EOF |
40 | $ pg commit -am 'Updated message' | 14 | $ pg commit -am 'Updated message' |
41 | \[master [a-f0-9]{7}\] Updated message (re) | 15 | \[master [a-f0-9]{7}\] Updated message (re) |
42 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
43 | 17 | ||
44 | Update bundles. | 18 | Update bundles. |
45 | 19 | ||
46 | $ antigen-update | 20 | $ antigen-update |
47 | From .+?/plugin (re) | 21 | From .+?/test-plugin (re) |
48 | [a-z0-9]{7}\.\.[a-z0-9]{7} master -> origin/master (re) | 22 | [a-z0-9]{7}\.\.[a-z0-9]{7} master -> origin/master (re) |
49 | Updating [a-z0-9]{7}\.\.[a-z0-9]{7} (re) | 23 | Updating [a-z0-9]{7}\.\.[a-z0-9]{7} (re) |
50 | Fast-forward | 24 | Fast-forward |
51 | aliases.zsh | 2 +- | 25 | aliases.zsh | 2 +- |
52 | 1 file changed, 1 insertion(+), 1 deletion(-) | 26 | 1 file changed, 1 insertion(+), 1 deletion(-) |
53 | 27 | ||
54 | Confirm there is still only one repository. | 28 | Confirm there is still only one repository. |
55 | 29 | ||
56 | $ ls $ADOTDIR/repos | wc -l | 30 | $ ls $ADOTDIR/repos | wc -l |
57 | 1 | 31 | 1 |
58 | 32 | ||
59 | The new alias should not activate. | 33 | The new alias should not activate. |
60 | 34 | ||
61 | $ hehe | 35 | $ hehe |
62 | hehe | 36 | hehe |
63 | 37 |