Add FAST=1 env that can be used to run just some fast tests for quick testing

This commit is contained in:
David Dworken 2022-09-27 22:03:37 -07:00
parent e91e6ab237
commit 2bdfe3d64f

View File

@ -24,6 +24,10 @@ import (
"github.com/ddworken/hishtory/shared"
)
func skipSlowTests() bool {
return os.Getenv("FAST") != ""
}
func TestMain(m *testing.M) {
defer shared.RunTestServer()()
cmd := exec.Command("go", "build", "-o", "/tmp/client")
@ -113,6 +117,9 @@ func (z zshTester) ShellName() string {
var shellTesters []shellTester = []shellTester{bashTester{}, zshTester{}}
func TestParameterized(t *testing.T) {
if skipSlowTests() {
shellTesters = shellTesters[:1]
}
for _, tester := range shellTesters {
t.Run("testRepeatedCommandThenQuery/"+tester.ShellName(), func(t *testing.T) { testRepeatedCommandThenQuery(t, tester) })
t.Run("testRepeatedCommandAndQuery/"+tester.ShellName(), func(t *testing.T) { testRepeatedCommandAndQuery(t, tester) })
@ -592,6 +599,9 @@ func testUpdate(t *testing.T, tester shellTester) {
if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
t.Skip("skipping on linux/arm64 which is unsupported")
}
if skipSlowTests() {
t.Skip("skipping slow tests")
}
// Set up
defer shared.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -1772,6 +1782,9 @@ func fuzzTest(t *testing.T, tester shellTester, input string) {
}
func FuzzTestMultipleUsers(f *testing.F) {
if skipSlowTests() {
f.Skip("skipping slow tests")
}
// Format:
// $Op = $Key;$Device|$Command\n
// $Key;$Device|$Command\n$Op