Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fee63ee56b |
@@ -22,12 +22,14 @@ Run `make frontend-viewport-test` in CI as its own step; it is not part of
|
||||
# Completed Steps
|
||||
|
||||
- 2026-10-18: when the backend runs on its own, a `DATA_DIR` that cannot be
|
||||
created or read stops the start with an error naming `DATA_DIR` and its value,
|
||||
as the other settings' errors do
|
||||
([#148](https://git.eeqj.de/sneak/netwatch/issues/148)); it named only the
|
||||
path. A unit test starts the buffer with `DATA_DIR` below a regular file and
|
||||
checks the error. The report file number is an `atomic.Int64`, as the Go style
|
||||
guide asks for int types
|
||||
created or read, or where no file can be created, stops the start with an
|
||||
error naming `DATA_DIR` and its value, as the other settings' errors do
|
||||
([#148](https://git.eeqj.de/sneak/netwatch/issues/148)); the first two named
|
||||
only the path, and the third was found only at the first write of a report
|
||||
file. At start the server creates a file in `DATA_DIR` and removes it. Unit
|
||||
tests start the buffer with `DATA_DIR` below a regular file and with
|
||||
`DATA_DIR` set to `/proc`, and check the error. The report file number is an
|
||||
`atomic.Int64`, as the Go style guide asks for int types
|
||||
([#161](https://git.eeqj.de/sneak/netwatch/issues/161)); file names are
|
||||
unchanged
|
||||
- 2026-10-18: a browser that cannot format the header's clocks still probes
|
||||
|
||||
@@ -134,6 +134,19 @@ func New(
|
||||
return fmt.Errorf("DATA_DIR %q: %w", b.dataDir, err)
|
||||
}
|
||||
|
||||
// Creating and removing a file now stops the start if
|
||||
// report files cannot be written, instead of the first
|
||||
// write failing after reports were answered 200.
|
||||
f, err := os.CreateTemp(b.dataDir, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("DATA_DIR %q: %w", b.dataDir, err)
|
||||
}
|
||||
|
||||
err = errors.Join(f.Close(), os.Remove(f.Name()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("DATA_DIR %q: %w", b.dataDir, err)
|
||||
}
|
||||
|
||||
// Report files left by earlier runs count too, and are
|
||||
// the first to be deleted to make room.
|
||||
files, err := reportFiles(b.dataDir)
|
||||
|
||||
@@ -140,6 +140,36 @@ func TestUncreatableDataDirStopsStart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestUnwritableDataDirStopsStart sets DATA_DIR to /proc, which exists
|
||||
// and can be read, but where no file can be created, even by root, as
|
||||
// the tests run in the backend image: root ignores a directory the test
|
||||
// makes read-only. The start must fail with an error naming DATA_DIR and
|
||||
// its value, rather than the first write of a report file.
|
||||
func TestUnwritableDataDirStopsStart(t *testing.T) {
|
||||
dir := "/proc"
|
||||
t.Setenv("DATA_DIR", dir)
|
||||
|
||||
app := fxtest.New(t,
|
||||
fx.Provide(
|
||||
globals.New,
|
||||
logger.New,
|
||||
config.New,
|
||||
reportbuf.New,
|
||||
),
|
||||
fx.Invoke(func(*reportbuf.Buffer) {}),
|
||||
)
|
||||
|
||||
err := app.Start(t.Context())
|
||||
if err == nil {
|
||||
t.Fatal("start succeeded with DATA_DIR /proc")
|
||||
}
|
||||
|
||||
want := fmt.Sprintf("DATA_DIR %q: ", dir)
|
||||
if !strings.Contains(err.Error(), want) {
|
||||
t.Fatalf("start error = %q, want it to contain %q", err, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestStopWaitsForPeriodicWrite holds open the write the periodic flush
|
||||
// starts, then stops the app. The stop must wait until the write is
|
||||
// released, and the report must then be in its file. The test runs in
|
||||
|
||||
Reference in New Issue
Block a user