Cache successful commits
```git-check-assertions run test/git-check-assertions.bats assert_success git checkout HEAD~1 bin run test/git-check-assertions.bats assert_failure assert_output --partial "file exists, but it was expected to be absent" ```
This commit is contained in:
parent
fea90637e3
commit
e647b2599b
4 changed files with 80 additions and 1 deletions
|
|
@ -9,9 +9,14 @@ init_repo() {
|
|||
git init -b "$main_branch"
|
||||
git config user.email "john.doe@example.com"
|
||||
git config user.name "John Doe"
|
||||
|
||||
echo ".git-check-assertions-cache" >>.gitignore
|
||||
git add .gitignore
|
||||
git commit -m "add .git-check-assertions-cache to gitignore"
|
||||
|
||||
touch readme
|
||||
git add readme
|
||||
git commit -m "initial"
|
||||
git commit -m "add readme"
|
||||
}
|
||||
|
||||
setup() {
|
||||
|
|
@ -195,6 +200,57 @@ commit_with_assertion() {
|
|||
assert_size_zero readme
|
||||
}
|
||||
|
||||
@test "should skip cached commits on subsequent runs" {
|
||||
git checkout -b feature
|
||||
commit_with_assertion "touch ../test"
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_success
|
||||
assert_file_exists ../test
|
||||
rm ../test
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_success
|
||||
assert_file_not_exists ../test
|
||||
}
|
||||
|
||||
@test "should not cache failed commits" {
|
||||
git checkout -b feature
|
||||
commit_with_assertion "touch ../test && exit 3"
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_failure
|
||||
assert_file_exists ../test
|
||||
rm ../test
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_failure
|
||||
assert_file_exists ../test
|
||||
}
|
||||
|
||||
@test "should skip cached commits when multiple commits are cached" {
|
||||
git checkout -b feature
|
||||
commit_with_assertion "touch ../test1"
|
||||
commit_with_assertion "touch ../test2"
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_success
|
||||
assert_file_exists ../test1
|
||||
assert_file_exists ../test2
|
||||
rm ../test1 ../test2
|
||||
|
||||
run git-check-assertions
|
||||
|
||||
assert_success
|
||||
assert_file_not_exists ../test1
|
||||
assert_file_not_exists ../test2
|
||||
}
|
||||
|
||||
@test "assertions should run against the version of the code inside of the commit" {
|
||||
git checkout -b feature
|
||||
echo commit1 >readme
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue