Revert all tmpfs related commits, since running in a tmpfs doesn't seem to meaningfully improve test reliability

This commit is contained in:
David Dworken 2023-09-04 18:03:46 -07:00
parent 9b06e6980a
commit 25eae144d8
No known key found for this signature in database
3 changed files with 10 additions and 28 deletions

View File

@ -34,23 +34,15 @@ jobs:
# Set a consistent hostname so we can run tests that depend on it # Set a consistent hostname so we can run tests that depend on it
sudo hostname ghaction-runner-hostname sudo hostname ghaction-runner-hostname
# Set up a tmpfs for ~/.hishtory/ to help tests run faster
mkdir ~/.hishtory/
sudo mount -t tmpfs -o size=500M hishtory-tmpfs ~/.hishtory/
- name: MacOS Setup - name: MacOS Setup
if: ${{ !startsWith(github.event.head_commit.message, 'Release') && matrix.os == 'macos-latest'}} if: ${{ !startsWith(github.event.head_commit.message, 'Release') && matrix.os == 'macos-latest'}}
run: | run: |
# Install our dependencies # Install our dependencies
brew install fish tmux bash brew install fish tmux bash
# Set a consistent hostname so we can run tests that depend on it # Set a consistent hostname so we can run tests that depend on it
sudo scutil --set HostName ghaction-runner-hostname sudo scutil --set HostName ghaction-runner-hostname
# Set up a tmpfs for ~/.hishtory/ to help tests run faster
sudo diskutil apfs create $(sudo hdiutil attach -nomount ram://1024000) tmpfs
ln -s /Volumes/tmpfs ~/.hishtory
- name: Go test - name: Go test
if: ${{ !startsWith(github.event.head_commit.message, 'Release') }} if: ${{ !startsWith(github.event.head_commit.message, 'Release') }}
run: | run: |

View File

@ -1,9 +1,9 @@
forcetest: forcetest:
go clean -testcache go clean -testcache
TZ='America/Los_Angeles' HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 90m ./... TZ='America/Los_Angeles' HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 45m ./...
test: test:
TZ='America/Los_Angeles' HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 90m ./... TZ='America/Los_Angeles' HISHTORY_TEST=1 HISHTORY_SKIP_INIT_IMPORT=1 go test -p 1 -timeout 45m ./...
ftest: ftest:
go clean -testcache go clean -testcache

View File

@ -47,8 +47,11 @@ func getInitialWd() string {
} }
func ResetLocalState(t *testing.T) { func ResetLocalState(t *testing.T) {
homedir, err := os.UserHomeDir()
Check(t, err)
persistLog() persistLog()
_ = BackupAndRestoreWithId(t, "-reset-local-state") _ = BackupAndRestoreWithId(t, "-reset-local-state")
_ = os.RemoveAll(path.Join(homedir, data.GetHishtoryPath()))
} }
func BackupAndRestore(t testing.TB) func() { func BackupAndRestore(t testing.TB) func() {
@ -85,7 +88,7 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
} }
for _, file := range renameFiles { for _, file := range renameFiles {
touchFile(file) touchFile(file)
Check(t, rename(file, getBackPath(file, id))) Check(t, os.Rename(file, getBackPath(file, id)))
} }
copyFiles := []string{ copyFiles := []string{
path.Join(homedir, ".zshrc"), path.Join(homedir, ".zshrc"),
@ -107,14 +110,10 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err) t.Fatalf("failed to execute killall hishtory, stdout=%#v: %v", string(stdout), err)
} }
persistLog() persistLog()
for _, file := range renameFiles { Check(t, os.RemoveAll(path.Join(homedir, data.GetHishtoryPath())))
if strings.Contains(file, data.GetHishtoryPath()) {
_ = os.Remove(file)
}
}
Check(t, os.MkdirAll(path.Join(homedir, data.GetHishtoryPath()), os.ModePerm)) Check(t, os.MkdirAll(path.Join(homedir, data.GetHishtoryPath()), os.ModePerm))
for _, file := range renameFiles { for _, file := range renameFiles {
checkError(rename(getBackPath(file, id), file)) checkError(os.Rename(getBackPath(file, id), file))
} }
for _, file := range copyFiles { for _, file := range copyFiles {
checkError(copy(getBackPath(file, id), file)) checkError(copy(getBackPath(file, id), file))
@ -155,15 +154,6 @@ setopt SHARE_HISTORY
checkError(err) checkError(err)
} }
// Similar to os.Rename, except it supports renaming cross-mount
func rename(src, dst string) error {
err := copy(src, dst)
if err != nil {
return err
}
return os.Remove(src)
}
func copy(src, dst string) error { func copy(src, dst string) error {
// Copy the contents of the file // Copy the contents of the file
in, err := os.Open(src) in, err := os.Open(src)