mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-25 06:22:24 +02:00
Revert all tmpfs related commits, since running in a tmpfs doesn't seem to meaningfully improve test reliability
This commit is contained in:
parent
9b06e6980a
commit
25eae144d8
12
.github/workflows/go-test.yml
vendored
12
.github/workflows/go-test.yml
vendored
@ -34,23 +34,15 @@ jobs:
|
||||
|
||||
# Set a consistent hostname so we can run tests that depend on it
|
||||
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
|
||||
if: ${{ !startsWith(github.event.head_commit.message, 'Release') && matrix.os == 'macos-latest'}}
|
||||
run: |
|
||||
|
||||
# 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
|
||||
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
|
||||
sudo scutil --set HostName ghaction-runner-hostname
|
||||
- name: Go test
|
||||
if: ${{ !startsWith(github.event.head_commit.message, 'Release') }}
|
||||
run: |
|
||||
|
4
Makefile
4
Makefile
@ -1,9 +1,9 @@
|
||||
forcetest:
|
||||
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:
|
||||
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:
|
||||
go clean -testcache
|
||||
|
@ -47,8 +47,11 @@ func getInitialWd() string {
|
||||
}
|
||||
|
||||
func ResetLocalState(t *testing.T) {
|
||||
homedir, err := os.UserHomeDir()
|
||||
Check(t, err)
|
||||
persistLog()
|
||||
_ = BackupAndRestoreWithId(t, "-reset-local-state")
|
||||
_ = os.RemoveAll(path.Join(homedir, data.GetHishtoryPath()))
|
||||
}
|
||||
|
||||
func BackupAndRestore(t testing.TB) func() {
|
||||
@ -85,7 +88,7 @@ func BackupAndRestoreWithId(t testing.TB, id string) func() {
|
||||
}
|
||||
for _, file := range renameFiles {
|
||||
touchFile(file)
|
||||
Check(t, rename(file, getBackPath(file, id)))
|
||||
Check(t, os.Rename(file, getBackPath(file, id)))
|
||||
}
|
||||
copyFiles := []string{
|
||||
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)
|
||||
}
|
||||
persistLog()
|
||||
for _, file := range renameFiles {
|
||||
if strings.Contains(file, data.GetHishtoryPath()) {
|
||||
_ = os.Remove(file)
|
||||
}
|
||||
}
|
||||
Check(t, os.RemoveAll(path.Join(homedir, data.GetHishtoryPath())))
|
||||
Check(t, os.MkdirAll(path.Join(homedir, data.GetHishtoryPath()), os.ModePerm))
|
||||
for _, file := range renameFiles {
|
||||
checkError(rename(getBackPath(file, id), file))
|
||||
checkError(os.Rename(getBackPath(file, id), file))
|
||||
}
|
||||
for _, file := range copyFiles {
|
||||
checkError(copy(getBackPath(file, id), file))
|
||||
@ -155,15 +154,6 @@ setopt SHARE_HISTORY
|
||||
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 {
|
||||
// Copy the contents of the file
|
||||
in, err := os.Open(src)
|
||||
|
Loading…
x
Reference in New Issue
Block a user