fix: change save path log to be relative

This commit is contained in:
2026-03-25 21:37:08 +00:00
parent 526e31d0b0
commit 6fae05eb6f
11 changed files with 59 additions and 33 deletions
+22 -1
View File
@@ -1 +1,22 @@
a lean cli e2e testing framework written in go
# Mire
E2E tests for CLIs.
# Quickstart
## Install
- clone
- `make build`
- add `build/mire` to path
## Using
- `mire init` to create the the single config file, every entry is explicit in config.
- `mire record test/name/` - now test how you would test manually, try out commands to see if they work as expected
- `mire test` or `mire test specific/test`
- `mire rewrite` - to rewrite all golden outputs in case of a style change
**Using fixtures?**
You can write you script commands in `setup.sh` at any level, anything at that and nested level will have those run before dropping you
into record.
+9 -1
View File
@@ -2,6 +2,7 @@ package cmd
import (
"errors"
"os"
"path/filepath"
"mire/internal/mire"
@@ -28,7 +29,14 @@ func newRecordCommand() *cobra.Command {
return err
}
output.Println(createdPath)
displayPath := createdPath
if cwd, err := os.Getwd(); err == nil {
if relPath, err := filepath.Rel(cwd, createdPath); err == nil {
displayPath = relPath
}
}
output.Printf("Saved at %s\n", displayPath)
return nil
},
}
+4 -4
View File
@@ -114,8 +114,8 @@ func TestRunRecord(t *testing.T) {
})
createdPath := filepath.Join(wantDir, "suite", "spec")
if !strings.Contains(stdout, createdPath) {
t.Fatalf("stdout = %q, want created path", stdout)
if !strings.Contains(stdout, prefixed("Saved at e2e/suite/spec\n")) {
t.Fatalf("stdout = %q, want saved message %q", stdout, prefixed("Saved at e2e/suite/spec\n"))
}
if !strings.Contains(stderr, "Save recording?") {
t.Fatalf("stderr = %q, want save prompt", stderr)
@@ -156,8 +156,8 @@ func TestRunRecordSaveFlagSkipsPrompt(t *testing.T) {
})
createdPath := filepath.Join(wantDir, "suite", "spec")
if !strings.Contains(stdout, createdPath) {
t.Fatalf("stdout = %q, want created path", stdout)
if !strings.Contains(stdout, prefixed("Saved at e2e/suite/spec\n")) {
t.Fatalf("stdout = %q, want saved message %q", stdout, prefixed("Saved at e2e/suite/spec\n"))
}
if strings.Contains(stderr, "Save recording?") {
t.Fatalf("stderr = %q, want save prompt omitted", stderr)
+2
View File
@@ -0,0 +1,2 @@
echo a
exit
+4
View File
@@ -0,0 +1,4 @@
[?2004h$ echo a
[?2004l
a
[?2004h$ exit
+1 -1
View File
@@ -7,7 +7,7 @@
[?2004h$ echo saved
[?2004l
saved
[?2004h$ exit
[?2004h$ exit
[?2004l
exit
mire  Verifying recording...
+1 -1
View File
@@ -7,7 +7,7 @@
[?2004h$ echo rewrite
[?2004l
rewrite
[?2004h$ exit
[?2004h$ exit
[?2004l
exit
mire  Verifying recording...
+11 -20
View File
@@ -1,35 +1,26 @@
[?2004h$ mire init
[?2004l
mire  Done initialising...
[?2004l
mire  Done initialising...
[?2004l
mire  Run commands in the recorder shell, then type exit to finish.
[?2004h$ mire record --save a
[?2004l
[?2004l
one
mire  Run commands in the recorder shell, then type exit to finish.
[?2004h$ echo one
[?2004l
exit
[?2004l
one
mire  /home/test/e2e/a
[?2004h$ exit
[?2004l
[?2004l
mire  Run commands in the recorder shell, then type exit to finish.
exit
mire  Verifying recording...
[?2004l
two
mire  Saved at e2e/a
[?2004h$ mire record --save nested/b
[?2004l
exit
[?2004l
mire  Run commands in the recorder shell, then type exit to finish.
mire  /home/test/e2e/nested/b
[?2004h$ echo two
[?2004l
[?2004l
mire  RUN a
two
[?2004h$ exit
[?2004l
exit
mire  Verifying recording...
mire  Saved at e2e/nested/b
[?2004l
exit
[?2004h$ mire test
+1 -1
View File
@@ -8,6 +8,6 @@
[?2004l
a
[?2004h$ exit
[?2004l
[?2004l
exit
mire  Save recording? [y/N] y
+2 -2
View File
@@ -7,7 +7,7 @@
[?2004h$ echo one
[?2004l
one
[?2004h$ exit
[?2004h$ exit
[?2004l
exit
mire  Verifying recording...
@@ -15,7 +15,7 @@
[?2004h$ mire record --save nested/b
[?2004l
mire  Run commands in the recorder shell, then type exit to finish.
[?2004h$ echo two
[?2004h$ echo two
[?2004l
two
[?2004h$ exit
+2 -2
View File
@@ -9,10 +9,10 @@
[?2004l
mire  Run commands in the recorder shell, then type exit to finish.
[?2004h$ echo $FROM_SETUP
[?2004l
[?2004l
from_setup
[?2004h$ exit
[?2004l
[?2004l
exit
mire  Verifying recording...
mire  Saved at e2e/suite/spec