fix: change save path log to be relative
This commit is contained in:
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
echo a
|
||||
exit
|
||||
@@ -0,0 +1,4 @@
|
||||
[?2004h$ echo a
|
||||
[?2004l
|
||||
a
|
||||
[?2004h$ exit
|
||||
@@ -7,7 +7,7 @@
|
||||
[?2004h$ echo saved
|
||||
[?2004l
|
||||
saved
|
||||
[?2004h$ exit
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[?2004h$ echo rewrite
|
||||
[?2004l
|
||||
rewrite
|
||||
[?2004h$ exit
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
|
||||
+11
-20
@@ -1,35 +1,26 @@
|
||||
[?2004h$ mire init
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Done initialising...
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Done initialising...
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
[?2004h$ mire record --save a
|
||||
[?2004l
|
||||
[?2004l
|
||||
one
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
[?2004h$ echo one
|
||||
[?2004l
|
||||
exit
|
||||
[?2004l
|
||||
one
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m /home/test/e2e/a
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
[?2004l
|
||||
two
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Saved at e2e/a
|
||||
[?2004h$ mire record --save nested/b
|
||||
[?2004l
|
||||
exit
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m /home/test/e2e/nested/b
|
||||
[?2004h$ echo two
|
||||
[?2004l
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m [38;2;215;255;255mRUN[0m a
|
||||
two
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Saved at e2e/nested/b
|
||||
[?2004l
|
||||
exit
|
||||
[?2004h$ mire test
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@
|
||||
[?2004l
|
||||
a
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Save recording? [y/N] y
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
[?2004h$ echo one
|
||||
[?2004l
|
||||
one
|
||||
[?2004h$ exit
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
@@ -15,7 +15,7 @@
|
||||
[?2004h$ mire record --save nested/b
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
[?2004h$ echo two
|
||||
[?2004h$ echo two
|
||||
[?2004l
|
||||
two
|
||||
[?2004h$ exit
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
[?2004l
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Run commands in the recorder shell, then type exit to finish.
|
||||
[?2004h$ echo $FROM_SETUP
|
||||
[?2004l
|
||||
[?2004l
|
||||
from_setup
|
||||
[?2004h$ exit
|
||||
[?2004l
|
||||
[?2004l
|
||||
exit
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Verifying recording...
|
||||
[1m[3m[38;2;112;224;0mmire[0m [1m[3m[38;2;29;211;176m›[0m Saved at e2e/suite/spec
|
||||
|
||||
Reference in New Issue
Block a user