Hold runMu in internal/cli tests that log outside a CLI run (closes #210)
check / check (push) Waiting to run
check / check (push) Waiting to run
A CLI run under runMu points the process-global logger at its own buffers, so a line another test logged outside runMu could land in that run's output. TestCheckQuietShowsFailedFiles caught one: a "loaded manifest" line in the stderr of a passing check -q run. The test helpers that scan or load a manifest now hold runMu themselves, and so do the remaining direct loads and scans, the recordEntry call and the retrying download. Two dotfile tests use manifestPaths instead of loading the manifest themselves. Judgement call: a downloadFile call that gets its answer on the first request does not log, so those calls are left as they are. Model: opus-5-5
This commit is contained in:
@@ -70,6 +70,11 @@ func runFreshen(t *testing.T, fs afero.Fs, root, manifestPath string) {
|
||||
func manifestFiles(t *testing.T, fs afero.Fs, path string) []*mfer.MFFilePath {
|
||||
t.Helper()
|
||||
|
||||
// Loading a manifest logs to the process-global logger, so serialize
|
||||
// with the CLI runs.
|
||||
runMu.Lock()
|
||||
defer runMu.Unlock()
|
||||
|
||||
manifest, err := mfer.NewManifestFromFile(&mfer.ManifestFromFileOptions{
|
||||
Path: path,
|
||||
Fs: fs,
|
||||
@@ -436,7 +441,11 @@ func TestFreshenRecordEntryMtimePresence(t *testing.T) {
|
||||
s := &freshenScanner{
|
||||
existingByPath: map[string]*mfer.MFFilePath{relPath: tc.entry},
|
||||
}
|
||||
|
||||
// recordEntry logs to the process-global logger.
|
||||
runMu.Lock()
|
||||
s.recordEntry(relPath, info)
|
||||
runMu.Unlock()
|
||||
|
||||
require.Len(t, s.entries, 1)
|
||||
assert.Equal(t, tc.needsHash, s.entries[0].needsHash)
|
||||
|
||||
Reference in New Issue
Block a user