feat: add timing stats for each test
This commit is contained in:
+11
-8
@@ -220,9 +220,10 @@ func TestRunTest(t *testing.T) {
|
|||||||
|
|
||||||
for _, want := range []string{
|
for _, want := range []string{
|
||||||
"RUN a",
|
"RUN a",
|
||||||
"PASS a",
|
"PASS a in ",
|
||||||
|
" seconds",
|
||||||
"RUN nested/b",
|
"RUN nested/b",
|
||||||
"PASS nested/b",
|
"PASS nested/b in ",
|
||||||
"Summary: total=2 passed=2 failed=0",
|
"Summary: total=2 passed=2 failed=0",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(stdout, want) {
|
if !strings.Contains(stdout, want) {
|
||||||
@@ -265,9 +266,9 @@ func TestRunTestScopedDirectory(t *testing.T) {
|
|||||||
|
|
||||||
for _, want := range []string{
|
for _, want := range []string{
|
||||||
"RUN nested/b",
|
"RUN nested/b",
|
||||||
"PASS nested/b",
|
"PASS nested/b in ",
|
||||||
"RUN nested/c",
|
"RUN nested/c",
|
||||||
"PASS nested/c",
|
"PASS nested/c in ",
|
||||||
"Summary: total=2 passed=2 failed=0",
|
"Summary: total=2 passed=2 failed=0",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(stdout, want) {
|
if !strings.Contains(stdout, want) {
|
||||||
@@ -312,7 +313,7 @@ func TestRunTestScopedLeafDirectory(t *testing.T) {
|
|||||||
|
|
||||||
for _, want := range []string{
|
for _, want := range []string{
|
||||||
"RUN nested/b",
|
"RUN nested/b",
|
||||||
"PASS nested/b",
|
"PASS nested/b in ",
|
||||||
"Summary: total=1 passed=1 failed=0",
|
"Summary: total=1 passed=1 failed=0",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(stdout, want) {
|
if !strings.Contains(stdout, want) {
|
||||||
@@ -357,9 +358,10 @@ func TestRunTestReturnsZeroWhenScenarioMismatches(t *testing.T) {
|
|||||||
|
|
||||||
for _, want := range []string{
|
for _, want := range []string{
|
||||||
"RUN a",
|
"RUN a",
|
||||||
"PASS a",
|
"PASS a in ",
|
||||||
"RUN b",
|
"RUN b",
|
||||||
"FAIL b: output differed",
|
"FAIL b in ",
|
||||||
|
"output differed",
|
||||||
"Summary: total=2 passed=1 failed=1",
|
"Summary: total=2 passed=1 failed=1",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(stdout, want) {
|
if !strings.Contains(stdout, want) {
|
||||||
@@ -457,7 +459,8 @@ func TestRunTestReturnsZeroWhenCompareMarkerMissing(t *testing.T) {
|
|||||||
|
|
||||||
for _, want := range []string{
|
for _, want := range []string{
|
||||||
"RUN some",
|
"RUN some",
|
||||||
"FAIL some: missing compare marker",
|
"FAIL some in ",
|
||||||
|
"missing compare marker",
|
||||||
"Summary: total=1 passed=0 failed=1",
|
"Summary: total=1 passed=0 failed=1",
|
||||||
} {
|
} {
|
||||||
if !strings.Contains(stdout, want) {
|
if !strings.Contains(stdout, want) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"miro/internal/output"
|
"miro/internal/output"
|
||||||
)
|
)
|
||||||
@@ -82,14 +83,17 @@ func runTests(path string, tio testIO) error {
|
|||||||
for _, scenario := range scenarios {
|
for _, scenario := range scenarios {
|
||||||
output.Fprintf(tio.out, "%s %s\n", output.Label("RUN", output.Info), scenario.relPath)
|
output.Fprintf(tio.out, "%s %s\n", output.Label("RUN", output.Info), scenario.relPath)
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
if err := replayScenario(scenario, shellPath, tio, cfg.Sandbox); err != nil {
|
if err := replayScenario(scenario, shellPath, tio, cfg.Sandbox); err != nil {
|
||||||
|
elapsed := time.Since(start).Seconds()
|
||||||
summary.failed++
|
summary.failed++
|
||||||
output.Fprintf(tio.out, "%s %s: %v\n", output.Label("FAIL", output.Fail), scenario.relPath, err)
|
output.Fprintf(tio.out, "%s %s in %.3f seconds: %v\n", output.Label("FAIL", output.Fail), scenario.relPath, elapsed, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elapsed := time.Since(start).Seconds()
|
||||||
summary.passed++
|
summary.passed++
|
||||||
output.Fprintf(tio.out, "%s %s\n", output.Label("PASS", output.Pass), scenario.relPath)
|
output.Fprintf(tio.out, "%s %s in %.3f seconds\n", output.Label("PASS", output.Pass), scenario.relPath, elapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
summaryColor := output.Pass
|
summaryColor := output.Pass
|
||||||
|
|||||||
Reference in New Issue
Block a user