Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New testsuite based on Git's test-lib.sh #220

Draft
wants to merge 155 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
f9d44e5
migrate prove tests to bats
djpohly Feb 5, 2017
413646d
Bats tests for help command
djpohly Feb 5, 2017
bb2fa3a
add tests for version command
djpohly Feb 5, 2017
5757185
add tests for list command
djpohly Feb 5, 2017
7167d7e
update command list from vcsh source
djpohly Feb 5, 2017
90a549f
getting started on init tests
djpohly Feb 5, 2017
45b7975
use git-rev-parse --resolve-git-dir
djpohly Feb 5, 2017
2176590
skip failing doc test
djpohly Feb 7, 2017
49749a1
better unit tests for list and part of init
djpohly Feb 7, 2017
a6e5a2a
clone local test repo as its own rule
djpohly Feb 7, 2017
13d129e
updated init tests
djpohly Feb 8, 2017
6aa774f
add some clone tests
djpohly Feb 8, 2017
f1d20a4
switch "$VCSH" to $VCSH
djpohly Feb 8, 2017
d4fa0c6
probably just paranoia, add export anyway
djpohly Feb 8, 2017
60fb540
add rename tests
djpohly Feb 8, 2017
c893ff4
add some status tests
djpohly Feb 8, 2017
37e32ba
add init toplevel test
djpohly Feb 19, 2017
8289bd1
make bats tests executable themselves
djpohly Feb 23, 2017
4f1e8f3
Merge branch 'bats' of github:djpohly/vcsh into bats
djpohly Feb 24, 2017
2cb9fd2
use prove for parallel testing
djpohly Feb 24, 2017
87a5df0
check for prove again
djpohly Feb 25, 2017
39b0a4b
move tests back to default t/*.t
djpohly Feb 25, 2017
65ea97e
for now, skip tests that fail on existing bugs
djpohly Feb 25, 2017
a3130b0
add explanations to skipped tests
djpohly Feb 25, 2017
cb03dae
set $TERM explicitly for color test
djpohly Feb 25, 2017
9e2c839
add tests for run and enter
djpohly Feb 25, 2017
493e26d
add tests for foreach command
djpohly Feb 25, 2017
8c2c4dc
additional rename tests
djpohly Feb 25, 2017
9a22ae6
add tests for delete command
djpohly Feb 25, 2017
ce2437f
add abbreviation tests
djpohly Feb 25, 2017
e0a5325
better description
djpohly Feb 25, 2017
307c13b
pre-set committer/author name and email
djpohly Feb 25, 2017
f8ef498
further tests for status command
djpohly Feb 25, 2017
7484244
add tests for which command
djpohly Feb 25, 2017
b5dd2ed
tests for list-tracked command
djpohly Feb 25, 2017
e4bcecc
tests for list-tracked-by (deprecated)
djpohly Feb 26, 2017
4bbf1ff
add tests for commit
djpohly Feb 26, 2017
cac5636
more of the old tests are replaced now
djpohly Feb 26, 2017
56b8067
tests for pull, almost there!
djpohly Feb 26, 2017
ca9244e
tests for push
djpohly Feb 26, 2017
6be27c1
squelch messages from older gits
djpohly Feb 26, 2017
d811740
Update Travis script for new tests
djpohly Feb 26, 2017
345bb3d
update Travis indicator in README
djpohly Feb 26, 2017
cc9d00e
assert(): fail more verbosely when testing
djpohly Feb 27, 2017
1bac18a
add verbose assert_file function
djpohly Feb 27, 2017
b8c12c9
use "! <pipeline> || false"
djpohly Feb 27, 2017
d383e84
this test now fails unless skipped
djpohly Feb 27, 2017
95214ca
add and use assert_grep
djpohly Feb 27, 2017
eb40264
Merge branch 'master' into bats
djpohly Feb 27, 2017
ec4c89d
convert help.t to Git's test-lib
djpohly May 5, 2017
d0f3315
move test-lib tests to *.sh
djpohly May 5, 2017
63640ff
more progress on test-lib-ifying tests
djpohly May 5, 2017
34b4f10
easy approach: split bats test into many test-lib
djpohly May 6, 2017
1a00254
split and convert clone tests
djpohly May 6, 2017
d4769f6
update tests to use more test-lib idioms
djpohly May 6, 2017
dd5d302
use test_env where needed
djpohly May 7, 2017
01d1e9f
start converting delete tests
djpohly May 7, 2017
3f0de0f
finish converting delete tests
djpohly May 9, 2017
cd93c5e
convert list tests
djpohly May 9, 2017
23fdc17
back to *.t to distinguish from test-lib.sh
djpohly May 9, 2017
648dc7f
move bats tests to *.bats
djpohly May 9, 2017
3e720b7
fix `make test'
djpohly May 9, 2017
6feeb0b
remove git-specific environment vars
djpohly May 9, 2017
1038fbb
fix trash directory names
djpohly May 9, 2017
b200d0f
exclude ./output from find in init-umask
djpohly May 9, 2017
529f491
Makefile cleanup (phony, prereqs target)
djpohly May 9, 2017
3d71f43
this branch no longer uses bats
djpohly May 9, 2017
bf658df
convert remaining old test
djpohly May 10, 2017
f5c5e6d
convert status tests
djpohly May 10, 2017
3eca9f5
update rename tests
djpohly May 12, 2017
6432a5c
convert version tests
djpohly May 12, 2017
08b9632
combine version tests
djpohly May 12, 2017
5a02888
convert which tests
djpohly May 12, 2017
f8fc9a4
convert commit tests
djpohly May 12, 2017
fa952f0
add some writemes to remember
djpohly May 12, 2017
b4ceabc
convert debug test
djpohly May 12, 2017
2ac65ae
convert foreach tests
djpohly May 12, 2017
e1bb020
convert run/enter tests
djpohly May 12, 2017
ead5a89
convert pull tests
djpohly May 13, 2017
19604e7
convert push tests
djpohly May 13, 2017
29c7ba4
only list-untracked test so far
djpohly May 13, 2017
fa58893
update list-tracked tests
djpohly May 13, 2017
31245c2
fix commit test #3
djpohly May 15, 2017
afee94e
Merge branch 'bats' into git-test-lib
djpohly May 15, 2017
9241d64
use test-lib idiom for help abbrev test
djpohly May 15, 2017
46621d2
fix expected output on commit tests
djpohly May 15, 2017
74b631b
remove remaining \$ in test descriptions
djpohly May 15, 2017
59c131a
fix testing for failed pushes
djpohly May 15, 2017
4d19683
finish switching .sh to .t in test-lib.sh
djpohly May 15, 2017
d9cbd29
allow `make test TEST_ARGS=...'
djpohly May 15, 2017
eceaf45
remove extra templates argument in test-lib
djpohly May 16, 2017
66f64cc
touch-ups to test-lib
djpohly May 16, 2017
0cd5916
rename4: remove dependency on TESTREPO
djpohly May 16, 2017
440ffcb
list3: remove dependency on TESTREPO
djpohly May 16, 2017
8fb934d
recombine run-enter, remove TESTREPO dependency
djpohly May 16, 2017
d6f6fc7
condense status tests
djpohly May 16, 2017
4013942
remove foreach dependency on TESTREPO
djpohly May 17, 2017
d714f07
remove push dependency on TESTREPO
djpohly May 17, 2017
9cd857e
remove pull dependency on TESTREPO
djpohly May 17, 2017
c2bc535
remove last of TESTREPO dependencies
djpohly May 17, 2017
1e5ed6d
condense foreach tests
djpohly May 17, 2017
194e56e
condense init tests
djpohly May 17, 2017
51bcbd9
condense list tests
djpohly May 18, 2017
518aaf2
condense delete tests
djpohly May 18, 2017
ffdc9a2
condense rename tests
djpohly May 19, 2017
1456ddb
condense which tests
djpohly May 19, 2017
2b713a9
condense clone tests
djpohly May 19, 2017
a66c08d
condense commit tests
djpohly May 19, 2017
bf00875
consolidate list-tracked tests
djpohly May 19, 2017
859b9bd
ignore results and trash directories
djpohly May 19, 2017
f2f55bc
consolidate push and pull tests
djpohly May 19, 2017
0eebc71
update badge to this branch
djpohly May 19, 2017
dc262fb
remove some vestigial helper functions
djpohly May 25, 2017
3b75941
s/assert_grep/test_grep/ to match convention
djpohly May 25, 2017
d5368fc
rename to environment.sh
djpohly May 25, 2017
078fb4d
convert over some old list-untracked tests
djpohly May 25, 2017
60cae6a
add empty repo tests for list-untracked
djpohly Jun 21, 2017
38d5276
add test_setup function for setup tasks
djpohly Jul 24, 2017
0b2c905
use test_when_finished and test_setup for clone.t
djpohly Jul 24, 2017
e233440
use test_setup some more
djpohly Jul 24, 2017
6159490
some more use of test_setup
djpohly Jul 24, 2017
72e08ac
add and start using vcsh_temp_{clone,repo}
djpohly Dec 19, 2017
fda3f55
make sure test_grep output goes to &3
djpohly Dec 19, 2017
bf7a049
update list-untracked tests
djpohly Dec 19, 2017
b29a1de
use test_setup in pull.t
djpohly Dec 19, 2017
84a7042
remove changeable string from expected result
djpohly Dec 22, 2017
b434e59
fix up status.t color test, use test_setup
djpohly Dec 22, 2017
2d65e59
remove color test for now
djpohly Dec 22, 2017
45eadba
update test-lib from git
djpohly Dec 22, 2017
a4390cb
more consistent use of test_setup
djpohly Dec 22, 2017
a2949c1
Merge branch 'master' into git-test-lib
djpohly Dec 22, 2017
804207c
don't mix quoting when avoidable
djpohly Dec 22, 2017
d7a912c
set push.default globally
djpohly Dec 22, 2017
42d355e
allow vcsh_temp_repo to create multiple repos
djpohly Dec 22, 2017
2350e07
ensure all parts of vcsh_temp_* succeed
djpohly Dec 22, 2017
64a5206
use test_setup consistently in commit.t
djpohly Dec 22, 2017
59f781e
these commits were part of their respective tests
djpohly Dec 22, 2017
f10cc41
more appropriate gitignore/gitattributes tests
djpohly Dec 22, 2017
c43daa8
remove changeable string from push test
djpohly Dec 22, 2017
9e26e19
make tests dash-friendly
djpohly Dec 23, 2017
6d0a3c5
switch /bin/bash to /bin/sh in tests
djpohly Dec 23, 2017
8b94f1d
add external-vars tests
djpohly Dec 23, 2017
fb0732b
nuke vcsh_testrepo
djpohly Dec 23, 2017
468649c
add test for help as default command
djpohly Dec 24, 2017
a0f0c3b
test both -v and -d options
djpohly Dec 24, 2017
5114b06
start some configfiles tests
djpohly Dec 24, 2017
8b05dc4
add tests for GIT_WORKTREE
djpohly Dec 24, 2017
38432ca
add missing command abbreviation tests
djpohly Dec 24, 2017
6e755db
fix whitespace errors
djpohly Dec 24, 2017
30cfff6
use test_env more faithfully
djpohly Dec 24, 2017
96c3e0d
make sure clone doesn't overwrite existing files
djpohly Dec 24, 2017
6055226
remove stray test_pause
djpohly Dec 24, 2017
b0f2992
remove vestigial check for socat
djpohly Dec 25, 2017
4ebaa45
add test for cloning empty repo
djpohly Dec 25, 2017
fb95d58
add some write-gitignore tests
djpohly Dec 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
language: perl
before_install:
- cpanm Shell::Command
- cpanm Test::Most
- apt-get moo
install:
- sudo apt-get update
- sudo apt-get install cowsay git ruby-ronn
sudo: false
language: bash
before_script:
- echo '-v' > "$HOME/.proverc"
script:
- make test
after_script:
- make moo
notifications:
email:
on_success: change
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DOCDIR=$(DOCDIR_PREFIX)/$(self)
ZSHDIR=$(PREFIX)/share/zsh/vendor-completions
RONN ?= ronn

.PHONY: all install manpages clean uninstall purge test moo

self=vcsh
manpages=$(self).1
all=test manpages
Expand Down Expand Up @@ -44,8 +46,7 @@ purge: uninstall
rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR)

test:
@if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi
@if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi
$(MAKE) -C t/

moo:
@which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..."
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
vcsh - Version Control System for $HOME - multiple Git repositories in $HOME

[![Build Status](https://travis-ci.org/RichiH/vcsh.svg?branch=master)](https://travis-ci.org/RichiH/vcsh)
[![Build Status](https://travis-ci.org/djpohly/vcsh.svg?branch=git-test-lib)](https://travis-ci.org/djpohly/vcsh)


# Index
Expand Down
2 changes: 2 additions & 0 deletions t/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/test-results/
/trash directory.*/
17 changes: 0 additions & 17 deletions t/000-tear-env.t

This file was deleted.

19 changes: 0 additions & 19 deletions t/001-setup-env.t

This file was deleted.

55 changes: 0 additions & 55 deletions t/100-init.t

This file was deleted.

39 changes: 0 additions & 39 deletions t/300-add.t

This file was deleted.

19 changes: 0 additions & 19 deletions t/950-delete.t

This file was deleted.

17 changes: 0 additions & 17 deletions t/999-tear-env.t

This file was deleted.

10 changes: 10 additions & 0 deletions t/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: all test test-prereq

all: test

test-prereq:
@if ! which git > /dev/null; then echo "'git' not found, exiting..." ; exit 1; fi
@if ! which prove > /dev/null; then echo "'prove' not found; not running tests"; exit 1; fi

test: test-prereq
prove $(filter -j%,$(MAKEFLAGS)) --timer *.t :: $(TEST_ARGS)
125 changes: 125 additions & 0 deletions t/clone.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/sh

test_description='Clone command'

. ./test-lib.sh
. "$TEST_DIRECTORY/environment.sh"

test_setup 'Create upstream repos' \
'test_create_repo empty &&

test_create_repo repo &&
test_commit -C repo A &&
git -C repo checkout -b branchb &&
test_commit -C repo A2 &&
git -C repo checkout master &&

test_create_repo repo2 &&
test_commit -C repo2 B &&

git clone --bare repo2 repo3.git'

test_expect_success 'Clone requires a remote' \
'test_must_fail $VCSH clone'

test_expect_success 'Warn about cloning empty repo' \
'test_when_finished "doit | $VCSH delete empty" &&
test_might_fail $VCSH clone empty 2>&1 | test_grep "remote is empty"'

test_expect_success 'Clone refuses to overwrite existing files' \
'echo success >A.t &&
test_when_finished "rm -f A.t" &&
test_might_fail $VCSH clone repo temp &&
test_when_finished "doit | $VCSH delete temp" &&
echo success >expected &&
test_cmp expected A.t'

test_expect_success 'Clone uses existing repo name by default' \
'$VCSH clone ./repo &&
test_when_finished "doit | $VCSH delete repo" &&
echo "repo" >expected &&
$VCSH list >output &&

$VCSH clone ./repo3.git &&
test_when_finished "doit | $VCSH delete repo3" &&
echo "repo3" >>expected &&
$VCSH list >output &&
test_cmp expected output'

test_expect_success 'Clone honors specified repo name' \
'$VCSH clone ./repo foo &&
test_when_finished "doit | $VCSH delete foo" &&
echo foo >expected &&
$VCSH list >output &&
test_cmp expected output'

test_expect_success 'Clone defaults to HEAD of given remote' \
'$VCSH clone ./repo foo &&
test_when_finished "doit | $VCSH delete foo" &&
git -C repo rev-parse HEAD >expected &&
$VCSH foo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone can be abbreviated "clon"' \
'$VCSH clon ./repo a &&
test_when_finished "doit | $VCSH delete a" &&
echo a >expected &&
$VCSH list >output &&
test_cmp expected output'

test_expect_success 'Clone can be abbreviated "clo"' \
'$VCSH clo ./repo b &&
test_when_finished "doit | $VCSH delete b" &&
echo b >expected &&
$VCSH list >output &&
test_cmp expected output'

test_expect_success 'Clone can be abbreviated "cl"' \
'$VCSH cl ./repo c &&
test_when_finished "doit | $VCSH delete c" &&
echo c >expected &&
$VCSH list >output &&
test_cmp expected output'

test_expect_success 'Clone honors -b option before remote' \
'$VCSH clone -b branchb ./repo &&
test_when_finished "doit | $VCSH delete repo" &&
git -C repo rev-parse branchb >expected &&
$VCSH repo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone honors -b option before remote and repo name' \
'$VCSH clone -b branchb ./repo foo &&
test_when_finished "doit | $VCSH delete foo" &&
git -C repo rev-parse branchb >expected &&
$VCSH foo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone honors -b option after remote' \
'$VCSH clone ./repo -b branchb &&
test_when_finished "doit | $VCSH delete repo" &&
git -C repo rev-parse branchb >expected &&
$VCSH repo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone honors -b option between remote and repo name' \
'$VCSH clone ./repo -b branchb foo &&
test_when_finished "doit | $VCSH delete foo" &&
git -C repo rev-parse branchb >expected &&
$VCSH foo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone honors -b option after repo name' \
'$VCSH clone ./repo foo -b branchb &&
test_when_finished "doit | $VCSH delete foo" &&
git -C repo rev-parse branchb >expected &&
$VCSH foo rev-parse HEAD >output &&
test_cmp expected output'

test_expect_success 'Clone -b option clones only one branch' \
'$VCSH clone -b branchb ./repo foo &&
test_when_finished "doit | $VCSH delete foo" &&
$VCSH foo show-ref --heads >output &&
test_line_count = 1 output'

test_done
Loading