check / check (push) Waiting to run
A backup under --skip-errors printed its skip errors, then "Finished successfully.", and exited 0, so a cron wrapper could not tell it from a complete backup. Each skipped entry, including a directory the walk could not list, is now counted as examined and failed. If --skip-errors skipped anything it could not read or list, the run still keeps its snapshots and prunes as before, then fails with "Backup completed, but N file(s) could not be read". A file removed during the run, even before the walk reaches it, counts once as failed and leaves the exit status alone; without the flag it no longer stops the backup. Excluded entries are never counted. Model: opus-5-5
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package cli //nolint:testpackage // shares runEntry and the hermetic config helpers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestEntrySnapshotCreateSkipErrorsExitsNonZeroWhenItSkips backs up,
|
|
// under --skip-errors, a source directory that does not exist, which the
|
|
// walk skips. The command exits non-zero and reports the backup as
|
|
// completed, not as a failed snapshot creation. See
|
|
// https://git.eeqj.de/sneak/vaultik/issues/310.
|
|
//
|
|
//nolint:paralleltest // replaces os.Args, os.Stdout, os.Stderr and the xdg globals
|
|
func TestEntrySnapshotCreateSkipErrorsExitsNonZeroWhenItSkips(t *testing.T) {
|
|
// writeBackupConfig would create the source directory.
|
|
configPath := writeHermeticPruneConfig(t, false)
|
|
|
|
code, stdout, stderr := runEntry(t,
|
|
flagConfig, configPath, "--skip-errors", cmdSnapshot, cmdCreate)
|
|
|
|
assert.Equal(t, 1, code)
|
|
assert.Contains(t, stdout,
|
|
"Files: 1 examined, 0 backed up, 0 unchanged, 1 failed.")
|
|
assert.NotContains(t, stdout, "Finished successfully.")
|
|
assert.Contains(t, stderr,
|
|
"Backup completed, but 1 file(s) could not be read")
|
|
assert.NotContains(t, stderr, "Snapshot creation failed")
|
|
}
|