Add more comprehensive support for test sharding

This commit is contained in:
David Dworken 2024-02-10 16:44:53 -08:00
parent 93d2b47f7d
commit 8e7b078f03
No known key found for this signature in database
3 changed files with 79 additions and 124 deletions

View File

@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, macos-14]
tests: [BASIC, TUI]
test_shards: ["0", "1", "2", "3", "4"]
fail-fast: false
steps:
- uses: actions/checkout@v4
@ -70,7 +70,7 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
go install gotest.tools/gotestsum@bc98120
SPLIT_TESTS=${{ matrix.tests }} make test
NUM_TEST_SHARDS=5 CURRENT_SHARD_NUM=${{ matrix.test_shards }} make test
- name: Extra Delay
run: |

View File

@ -9,6 +9,7 @@ import (
"path"
"regexp"
"runtime"
"strconv"
"strings"
"sync"
"testing"
@ -57,63 +58,88 @@ func TestMain(m *testing.M) {
var shellTesters []shellTester = []shellTester{bashTester{}, zshTester{}}
var shardNumberAllocator int = 0
func markTestForSharding(t *testing.T, testShardNumber int) {
numTestShardsStr := os.Getenv("NUM_TEST_SHARDS")
currentShardNumberStr := os.Getenv("CURRENT_SHARD_NUM")
if numTestShardsStr != "" && currentShardNumberStr != "" {
numTestShards, err := strconv.Atoi(numTestShardsStr)
require.NoError(t, err)
currentShardNumber, err := strconv.Atoi(currentShardNumberStr)
require.NoError(t, err)
if testShardNumber%numTestShards != currentShardNumber {
t.Skip("Skipping sharded test")
}
}
}
func wrapTestForSharding(test func(t *testing.T)) func(t *testing.T) {
shardNumberAllocator += 1
return func(t *testing.T) {
testShardNumber := shardNumberAllocator
markTestForSharding(t, testShardNumber)
test(t)
}
}
func TestParam(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) })
t.Run("testRepeatedEnableDisable/"+tester.ShellName(), func(t *testing.T) { testRepeatedEnableDisable(t, tester) })
t.Run("testExcludeHiddenCommand/"+tester.ShellName(), func(t *testing.T) { testExcludeHiddenCommand(t, tester) })
t.Run("testUpdate/head->release/"+tester.ShellName(), func(t *testing.T) { testUpdateFromHeadToRelease(t, tester) })
t.Run("testUpdate/prev->release/"+tester.ShellName(), func(t *testing.T) { testUpdateFromPrevToRelease(t, tester) })
t.Run("testUpdate/prev->release/prod/"+tester.ShellName(), func(t *testing.T) { testUpdateFromPrevToReleaseViaProd(t, tester) })
t.Run("testUpdate/prev->current/"+tester.ShellName(), func(t *testing.T) { testUpdateFromPrevToCurrent(t, tester) })
t.Run("testAdvancedQuery/"+tester.ShellName(), func(t *testing.T) { testAdvancedQuery(t, tester) })
t.Run("testIntegration/"+tester.ShellName(), func(t *testing.T) { testIntegration(t, tester, Online) })
t.Run("testIntegration/offline/"+tester.ShellName(), func(t *testing.T) { testIntegration(t, tester, Offline) })
t.Run("testIntegrationWithNewDevice/"+tester.ShellName(), func(t *testing.T) { testIntegrationWithNewDevice(t, tester) })
t.Run("testHishtoryBackgroundSaving/"+tester.ShellName(), func(t *testing.T) { testHishtoryBackgroundSaving(t, tester) })
t.Run("testDisplayTable/"+tester.ShellName(), func(t *testing.T) { testDisplayTable(t, tester) })
t.Run("testTableDisplayCwd/"+tester.ShellName(), func(t *testing.T) { testTableDisplayCwd(t, tester) })
t.Run("testTimestampsAreReasonablyCorrect/"+tester.ShellName(), func(t *testing.T) { testTimestampsAreReasonablyCorrect(t, tester) })
t.Run("testRequestAndReceiveDbDump/"+tester.ShellName(), func(t *testing.T) { testRequestAndReceiveDbDump(t, tester) })
t.Run("testInstallViaPythonScript/"+tester.ShellName(), func(t *testing.T) { testInstallViaPythonScript(t, tester) })
t.Run("testExportWithQuery/"+tester.ShellName(), func(t *testing.T) { testExportWithQuery(t, tester) })
t.Run("testHelpCommand/"+tester.ShellName(), func(t *testing.T) { testHelpCommand(t, tester) })
t.Run("testReuploadHistoryEntries/"+tester.ShellName(), func(t *testing.T) { testReuploadHistoryEntries(t, tester) })
t.Run("testHishtoryOffline/"+tester.ShellName(), func(t *testing.T) { testHishtoryOffline(t, tester) })
t.Run("testInitialHistoryImport/"+tester.ShellName(), func(t *testing.T) { testInitialHistoryImport(t, tester) })
t.Run("testLocalRedaction/"+tester.ShellName(), func(t *testing.T) { testLocalRedaction(t, tester, Online) })
t.Run("testLocalRedaction/offline/"+tester.ShellName(), func(t *testing.T) { testLocalRedaction(t, tester, Offline) })
t.Run("testRemoteRedaction/"+tester.ShellName(), func(t *testing.T) { testRemoteRedaction(t, tester) })
t.Run("testMultipleUsers/"+tester.ShellName(), func(t *testing.T) { testMultipleUsers(t, tester) })
t.Run("testConfigGetSet/"+tester.ShellName(), func(t *testing.T) { testConfigGetSet(t, tester) })
t.Run("testHandleUpgradedFeatures/"+tester.ShellName(), func(t *testing.T) { testHandleUpgradedFeatures(t, tester) })
t.Run("testCustomColumns/"+tester.ShellName(), func(t *testing.T) { testCustomColumns(t, tester) })
t.Run("testUninstall/"+tester.ShellName(), func(t *testing.T) { testUninstall(t, tester) })
t.Run("testPresaving/"+tester.ShellName(), func(t *testing.T) { testPresaving(t, tester, tester.ShellName()) })
t.Run("testPresavingOffline/"+tester.ShellName(), func(t *testing.T) { testPresavingOffline(t, tester) })
t.Run("testPresavingDisabled/"+tester.ShellName(), func(t *testing.T) { testPresavingDisabled(t, tester) })
t.Run("testControlR/online/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Online) })
t.Run("testControlR/offline/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Offline) })
t.Run("testTabCompletion/"+tester.ShellName(), func(t *testing.T) { testTabCompletion(t, tester, tester.ShellName()) })
t.Run("testRepeatedCommandThenQuery/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testRepeatedCommandThenQuery(t, tester) }))
t.Run("testRepeatedCommandAndQuery/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testRepeatedCommandAndQuery(t, tester) }))
t.Run("testRepeatedEnableDisable/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testRepeatedEnableDisable(t, tester) }))
t.Run("testExcludeHiddenCommand/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testExcludeHiddenCommand(t, tester) }))
t.Run("testUpdate/head->release/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testUpdateFromHeadToRelease(t, tester) }))
t.Run("testUpdate/prev->release/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testUpdateFromPrevToRelease(t, tester) }))
t.Run("testUpdate/prev->release/prod/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testUpdateFromPrevToReleaseViaProd(t, tester) }))
t.Run("testUpdate/prev->current/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testUpdateFromPrevToCurrent(t, tester) }))
t.Run("testAdvancedQuery/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testAdvancedQuery(t, tester) }))
t.Run("testIntegration/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testIntegration(t, tester, Online) }))
t.Run("testIntegration/offline/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testIntegration(t, tester, Offline) }))
t.Run("testIntegrationWithNewDevice/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testIntegrationWithNewDevice(t, tester) }))
t.Run("testHishtoryBackgroundSaving/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testHishtoryBackgroundSaving(t, tester) }))
t.Run("testDisplayTable/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testDisplayTable(t, tester) }))
t.Run("testTableDisplayCwd/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testTableDisplayCwd(t, tester) }))
t.Run("testTimestampsAreReasonablyCorrect/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testTimestampsAreReasonablyCorrect(t, tester) }))
t.Run("testRequestAndReceiveDbDump/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testRequestAndReceiveDbDump(t, tester) }))
t.Run("testInstallViaPythonScript/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testInstallViaPythonScript(t, tester) }))
t.Run("testExportWithQuery/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testExportWithQuery(t, tester) }))
t.Run("testHelpCommand/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testHelpCommand(t, tester) }))
t.Run("testReuploadHistoryEntries/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testReuploadHistoryEntries(t, tester) }))
t.Run("testHishtoryOffline/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testHishtoryOffline(t, tester) }))
t.Run("testInitialHistoryImport/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testInitialHistoryImport(t, tester) }))
t.Run("testLocalRedaction/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testLocalRedaction(t, tester, Online) }))
t.Run("testLocalRedaction/offline/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testLocalRedaction(t, tester, Offline) }))
t.Run("testRemoteRedaction/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testRemoteRedaction(t, tester) }))
t.Run("testMultipleUsers/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testMultipleUsers(t, tester) }))
t.Run("testConfigGetSet/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testConfigGetSet(t, tester) }))
t.Run("testHandleUpgradedFeatures/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testHandleUpgradedFeatures(t, tester) }))
t.Run("testCustomColumns/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testCustomColumns(t, tester) }))
t.Run("testUninstall/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testUninstall(t, tester) }))
t.Run("testPresaving/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testPresaving(t, tester, tester.ShellName()) }))
t.Run("testPresavingOffline/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testPresavingOffline(t, tester) }))
t.Run("testPresavingDisabled/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testPresavingDisabled(t, tester) }))
t.Run("testControlR/online/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Online) }))
t.Run("testControlR/offline/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Offline) }))
t.Run("testTabCompletion/"+tester.ShellName(), wrapTestForSharding(func(t *testing.T) { testTabCompletion(t, tester, tester.ShellName()) }))
}
t.Run("testTabCompletion/fish", func(t *testing.T) { testTabCompletion(t, zshTester{}, "fish") })
t.Run("testPresaving/fish", func(t *testing.T) { testPresaving(t, zshTester{}, "fish") })
t.Run("testControlR/fish", func(t *testing.T) { testControlR(t, bashTester{}, "fish", Online) })
t.Run("testTui/search/online", func(t *testing.T) { testTui_search(t, Online) })
t.Run("testTui/search/offline", func(t *testing.T) { testTui_search(t, Offline) })
t.Run("testTui/general/online", func(t *testing.T) { testTui_general(t, Online) })
t.Run("testTui/general/offline", func(t *testing.T) { testTui_general(t, Offline) })
t.Run("testTui/scroll", testTui_scroll)
t.Run("testTui/resize", testTui_resize)
t.Run("testTui/delete", testTui_delete)
t.Run("testTui/color", testTui_color)
t.Run("testTui/errors", testTui_errors)
t.Run("testTui/ai", testTui_ai)
t.Run("testTui/defaultFilter", testTui_defaultFilter)
t.Run("testTabCompletion/fish", wrapTestForSharding(func(t *testing.T) { testTabCompletion(t, zshTester{}, "fish") }))
t.Run("testPresaving/fish", wrapTestForSharding(func(t *testing.T) { testPresaving(t, zshTester{}, "fish") }))
t.Run("testControlR/fish", wrapTestForSharding(func(t *testing.T) { testControlR(t, bashTester{}, "fish", Online) }))
t.Run("testTui/search/online", wrapTestForSharding(func(t *testing.T) { testTui_search(t, Online) }))
t.Run("testTui/search/offline", wrapTestForSharding(func(t *testing.T) { testTui_search(t, Offline) }))
t.Run("testTui/general/online", wrapTestForSharding(func(t *testing.T) { testTui_general(t, Online) }))
t.Run("testTui/general/offline", wrapTestForSharding(func(t *testing.T) { testTui_general(t, Offline) }))
t.Run("testTui/scroll", wrapTestForSharding(testTui_scroll))
t.Run("testTui/resize", wrapTestForSharding(testTui_resize))
t.Run("testTui/delete", wrapTestForSharding(testTui_delete))
t.Run("testTui/color", wrapTestForSharding(testTui_color))
t.Run("testTui/errors", wrapTestForSharding(testTui_errors))
t.Run("testTui/ai", wrapTestForSharding(testTui_ai))
t.Run("testTui/defaultFilter", wrapTestForSharding(testTui_defaultFilter))
// Assert there are no leaked connections
assertNoLeakedConnections(t)
@ -121,7 +147,6 @@ func TestParam(t *testing.T) {
func testIntegration(t *testing.T, tester shellTester, onlineStatus OnlineStatus) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Run the test
@ -130,7 +155,6 @@ func testIntegration(t *testing.T, tester shellTester, onlineStatus OnlineStatus
func testIntegrationWithNewDevice(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Run the test
@ -240,7 +264,6 @@ func installWithOnlineStatus(t testing.TB, tester shellTester, onlineStatus Onli
func testBasicUserFlow(t *testing.T, tester shellTester, onlineStatus OnlineStatus) string {
// Test install
tagAsBasicTest(t)
userSecret := installWithOnlineStatus(t, tester, onlineStatus)
assertOnlineStatus(t, onlineStatus)
@ -341,7 +364,6 @@ echo thisisrecorded`)
func testAdvancedQuery(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Install hishtory
@ -565,22 +587,18 @@ func updateToHead(t *testing.T, tester shellTester) string {
}
func testUpdateFromHeadToRelease(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
testGenericUpdate(t, tester, installFromHead, updateToRelease)
}
func testUpdateFromPrevToRelease(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
testGenericUpdate(t, tester, installFromPrev, updateToRelease)
}
func testUpdateFromPrevToCurrent(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
testGenericUpdate(t, tester, installFromPrev, updateToHead)
}
func testUpdateFromPrevToReleaseViaProd(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
defer testutils.BackupAndRestoreEnv("HISHTORY_SERVER")()
os.Setenv("HISHTORY_SERVER", "https://api.hishtory.dev")
testGenericUpdate(t, tester, installFromPrev, updateToRelease)
@ -630,7 +648,6 @@ func testGenericUpdate(t *testing.T, tester shellTester, installInitialVersion f
func testRepeatedCommandThenQuery(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -671,7 +688,6 @@ echo mycommand-3`)
func testRepeatedCommandAndQuery(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -697,7 +713,6 @@ func testRepeatedCommandAndQuery(t *testing.T, tester shellTester) {
func testRepeatedEnableDisable(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -729,7 +744,6 @@ hishtory enable`, i))
func testExcludeHiddenCommand(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -787,7 +801,6 @@ func waitForBackgroundSavesToComplete(t testing.TB) {
func testTimestampsAreReasonablyCorrect(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -808,7 +821,6 @@ func testTimestampsAreReasonablyCorrect(t *testing.T, tester shellTester) {
func testTableDisplayCwd(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -836,7 +848,6 @@ echo other`)
func testHishtoryBackgroundSaving(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Check that we can find the go binary
@ -893,7 +904,6 @@ echo foo`)
func testDisplayTable(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -956,7 +966,6 @@ func testDisplayTable(t *testing.T, tester shellTester) {
func testRequestAndReceiveDbDump(t *testing.T, tester shellTester) {
// Set up
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
secretKey := installHishtory(t, tester, "")
@ -1055,7 +1064,6 @@ echo other`)
}
func TestInstallViaPythonScriptWithCustomHishtoryPath(t *testing.T) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("HISHTORY_PATH")()
altHishtoryPath := ".other-path"
@ -1070,7 +1078,6 @@ func TestInstallViaPythonScriptWithCustomHishtoryPath(t *testing.T) {
}
func TestInstallViaPythonScriptInOfflineMode(t *testing.T) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("HISHTORY_OFFLINE")()
os.Setenv("HISHTORY_OFFLINE", "1")
@ -1085,7 +1092,6 @@ func TestInstallViaPythonScriptInOfflineMode(t *testing.T) {
}
func testInstallViaPythonScript(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
testInstallViaPythonScriptChild(t, tester)
@ -1128,7 +1134,6 @@ func testInstallViaPythonScriptChild(t *testing.T, tester shellTester) {
}
func TestInstallViaPythonScriptFromHead(t *testing.T) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
tester := zshTester{}
@ -1166,7 +1171,6 @@ func TestInstallViaPythonScriptFromHead(t *testing.T) {
func testExportWithQuery(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -1225,7 +1229,6 @@ sleep 1`)
func testHelpCommand(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -1242,7 +1245,6 @@ func testHelpCommand(t *testing.T, tester shellTester) {
func TestStripBashTimePrefix(t *testing.T) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
tester := bashTester{}
installHishtory(t, tester, "")
@ -1288,7 +1290,6 @@ func TestStripBashTimePrefix(t *testing.T) {
func testReuploadHistoryEntries(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Init an initial device
@ -1339,7 +1340,6 @@ func testReuploadHistoryEntries(t *testing.T, tester shellTester) {
func testHishtoryOffline(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Init an initial device
@ -1391,7 +1391,6 @@ func testHishtoryOffline(t *testing.T, tester shellTester) {
func testInitialHistoryImport(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("HISHTORY_SKIP_INIT_IMPORT")()
os.Setenv("HISHTORY_SKIP_INIT_IMPORT", "")
@ -1426,7 +1425,6 @@ hishtory export `+randomCmdUuid[:5]+`
func testLocalRedaction(t *testing.T, tester shellTester, onlineStatus OnlineStatus) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installWithOnlineStatus(t, tester, onlineStatus)
assertOnlineStatus(t, onlineStatus)
@ -1495,7 +1493,6 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
func testRemoteRedaction(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Install hishtory client 1
@ -1551,7 +1548,6 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
func testConfigGetSet(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -1610,7 +1606,6 @@ func clearControlRSearchFromConfig(t testing.TB) {
func testHandleUpgradedFeatures(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -1642,7 +1637,6 @@ func testHandleUpgradedFeatures(t *testing.T, tester shellTester) {
func TestFish(t *testing.T) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
tester := bashTester{}
installHishtory(t, tester, "")
@ -1718,7 +1712,6 @@ func setupTestTui(t testing.TB, onlineStatus OnlineStatus) (shellTester, string,
func testTui_resize(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, userSecret, _ := setupTestTui(t, Online)
@ -1786,7 +1779,6 @@ func testTui_resize(t *testing.T) {
func testTui_scroll(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, userSecret, _ := setupTestTui(t, Online)
@ -1825,7 +1817,6 @@ func testTui_scroll(t *testing.T) {
func testTui_defaultFilter(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, userSecret, _ := setupTestTui(t, Online)
db := hctx.GetDb(hctx.MakeContext())
@ -1879,7 +1870,6 @@ func testTui_color(t *testing.T) {
}
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, _, _ := setupTestTui(t, Online)
tester.RunInteractiveShell(t, ` hishtory config-set highlight-matches false`)
@ -1922,7 +1912,6 @@ func testTui_color(t *testing.T) {
func testTui_delete(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, userSecret, _ := setupTestTui(t, Online)
manuallySubmitHistoryEntry(t, userSecret, testutils.MakeFakeHistoryEntry("echo 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'"))
@ -1965,7 +1954,6 @@ func testTui_delete(t *testing.T) {
func testTui_search(t *testing.T, onlineStatus OnlineStatus) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, _, _ := setupTestTui(t, onlineStatus)
@ -2078,7 +2066,6 @@ func testTui_search(t *testing.T, onlineStatus OnlineStatus) {
func testTui_general(t *testing.T, onlineStatus OnlineStatus) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, _, _ := setupTestTui(t, onlineStatus)
@ -2136,7 +2123,6 @@ func testTui_general(t *testing.T, onlineStatus OnlineStatus) {
func testTui_errors(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
tester, _, _ := setupTestTui(t, Online)
@ -2157,7 +2143,6 @@ func testTui_errors(t *testing.T) {
func testTui_ai(t *testing.T) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("OPENAI_API_KEY")()
os.Setenv("OPENAI_API_KEY", "")
@ -2192,7 +2177,6 @@ func testTui_ai(t *testing.T) {
func testControlR(t *testing.T, tester shellTester, shellName string, onlineStatus OnlineStatus) {
// Setup
tagAsTuiTest(t)
defer testutils.BackupAndRestore(t)()
installWithOnlineStatus(t, tester, onlineStatus)
assertOnlineStatus(t, onlineStatus)
@ -2355,7 +2339,6 @@ func testControlR(t *testing.T, tester shellTester, shellName string, onlineStat
func testCustomColumns(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2404,7 +2387,6 @@ echo bar`)
func testPresavingDisabled(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2429,7 +2411,6 @@ func testPresavingDisabled(t *testing.T, tester shellTester) {
func testPresavingOffline(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("HISHTORY_SIMULATE_NETWORK_ERROR")()
userSecret := installHishtory(t, tester, "")
@ -2472,7 +2453,6 @@ func testPresavingOffline(t *testing.T, tester shellTester) {
func testPresaving(t *testing.T, tester shellTester, shellName string) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
manuallySubmitHistoryEntry(t, userSecret, testutils.MakeFakeHistoryEntry("table_sizing aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
@ -2561,7 +2541,6 @@ func testTabCompletion(t *testing.T, tester shellTester, shellName string) {
}
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2583,7 +2562,6 @@ func testTabCompletion(t *testing.T, tester shellTester, shellName string) {
func testUninstall(t *testing.T, tester shellTester) {
// Setup
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2618,7 +2596,6 @@ echo bar`)
func TestTimestampFormat(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -2656,7 +2633,6 @@ func TestTimestampFormat(t *testing.T) {
func TestSortByConsistentTimezone(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2696,7 +2672,6 @@ func TestSortByConsistentTimezone(t *testing.T) {
func TestZDotDir(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
defer testutils.BackupAndRestoreEnv("ZDOTDIR")()
@ -2731,7 +2706,6 @@ func TestZDotDir(t *testing.T) {
func TestRemoveDuplicateRows(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2784,7 +2758,6 @@ echo foo`)
func TestSetConfigNoCorruption(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2819,7 +2792,6 @@ func TestSetConfigNoCorruption(t *testing.T) {
// Test that the config retrieved from the context is a reference and there are no consistency issues with it getting out of sync
func TestCtxConfigIsReference(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := zshTester{}
defer testutils.BackupAndRestore(t)()
installHishtory(t, tester, "")
@ -2845,7 +2817,6 @@ func TestCtxConfigIsReference(t *testing.T) {
}
func testMultipleUsers(t *testing.T, tester shellTester) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
// Create all our devices
@ -2932,7 +2903,6 @@ func createSyntheticImportEntries(t testing.TB, numSyntheticEntries int) {
func TestImportHistory(t *testing.T) {
// Setup
tagAsBasicTest(t)
tester := bashTester{}
defer testutils.BackupAndRestore(t)()
userSecret := installHishtory(t, tester, "")
@ -2987,7 +2957,6 @@ func BenchmarkImport(b *testing.B) {
}
func TestAugmentedIsOfflineError(t *testing.T) {
tagAsBasicTest(t)
defer testutils.BackupAndRestore(t)()
installHishtory(t, zshTester{}, "")
defer testutils.BackupAndRestoreEnv("HISHTORY_SIMULATE_NETWORK_ERROR")()

View File

@ -366,17 +366,3 @@ func stripRequiredPrefix(t *testing.T, out, prefix string) string {
func stripTuiCommandPrefix(t *testing.T, out string) string {
return stripRequiredPrefix(t, out, "hishtory tquery")
}
func tagAsBasicTest(t *testing.T) {
s := os.Getenv("SPLIT_TESTS")
if s != "" && s != "BASIC" {
t.Skip()
}
}
func tagAsTuiTest(t *testing.T) {
s := os.Getenv("SPLIT_TESTS")
if s != "" && s != "TUI" {
t.Skip()
}
}