Skip to content

Commit

Permalink
vgrep [no grep args]: print matches
Browse files Browse the repository at this point in the history
`vgrep` should print previously cached results when it's run without
grep arguments.  At some yet unknown point in time, we regressed on
it which is calling for regression tests that are now added

Fixes: #132
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Nov 13, 2020
1 parent 42e7222 commit 6793b54
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions test/simple.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,50 @@ load helpers
run_vgrep --no-git f
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]

run_vgrep
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]
}

@test "Simple search and --no-ripgrep" {
run_vgrep --no-ripgrep f
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]

run_vgrep
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]
}

@test "Simple search and --no-git --no-ripgrep" {
run_vgrep --no-git --no-ripgrep f
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]

run_vgrep
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]
}

@test "Simple search and --no-header" {
run_vgrep --no-header f
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]

run_vgrep
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]
}

@test "Simple search and --no-less" {
run_vgrep --no-less f
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]

run_vgrep --no-less
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "0" ]]
}

# Check that all grep tools are used when expected
Expand Down
8 changes: 5 additions & 3 deletions vgrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ func main() {
os.Exit(1)
}

// Execute the specified command and/or jump directly into the
// interactive shell.
v.commandParse()
if haveToRunCommand {
v.commandParse()
} else {
v.commandPrintMatches([]int{})
}
v.waiter.Wait()
os.Exit(0)
}
Expand Down

0 comments on commit 6793b54

Please sign in to comment.