Create the e2e trace directory before writing a trace (#2194)
`newPageOn` writes a trace into `traces/` when a test fails, and never created that directory. It is gitignored, so a fresh checkout does not have it. Traces were not in fact being dropped: the driver creates the parent of the trace path itself, checked against the version this module pins rather than assumed. The directory is created here anyway because nothing in the suite states or tests that dependency, and the missing directory has been raised in review on #2180 and again on #2193, each time needing the driver checked before it could be answered. One visible difference on a fresh checkout: the directory now arrives at 0750 rather than the 0755 the driver's own mkdir leaves, both measured. It runs only on a test that has already failed, and logs its error rather than swallowing it, matching the Stop call below it.
This commit is contained in:
@@ -274,6 +274,11 @@ func newPageOn(t *testing.T, b playwright.Browser) playwright.Page {
|
|||||||
// overwriting each other: the counter restarts with every process
|
// overwriting each other: the counter restarts with every process
|
||||||
name := strings.ReplaceAll(t.Name(), "/", "-")
|
name := strings.ReplaceAll(t.Name(), "/", "-")
|
||||||
path := filepath.Join(traceDir, fmt.Sprintf("%s-%d-%d.zip", name, os.Getpid(), seq))
|
path := filepath.Join(traceDir, fmt.Sprintf("%s-%d-%d.zip", name, os.Getpid(), seq))
|
||||||
|
// the driver creates the parent of the trace path too, but nothing here states or
|
||||||
|
// tests that, so the suite makes the directory itself
|
||||||
|
if derr := os.MkdirAll(traceDir, 0o750); derr != nil {
|
||||||
|
t.Logf("could not create %s: %v", traceDir, derr)
|
||||||
|
}
|
||||||
if serr := ctx.Tracing().Stop(path); serr != nil {
|
if serr := ctx.Tracing().Stop(path); serr != nil {
|
||||||
t.Logf("could not write the trace to %s: %v", path, serr)
|
t.Logf("could not write the trace to %s: %v", path, serr)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user