Skip to content

Commit 7b6c114

Browse files
authored
lint: Enable paralleltest, fix issues (#1367)
Enable the paralleltest linter. This linter checks that all tests and subtests call t.Parallel. Fix all fixable issues reported by the linter. For cases where a test cannot be run in parallel, add a `//nolint:paralleltest` comment with an appropriate explanation. For example: //nolint:paralleltest // modifies global state Best reviewed by ignoring all whitespace changes. <details> <summary>Full list fixed issues</summary> ``` array_test.go:55:1: Function TestArrayWrappers missing the call to method parallel (paralleltest) buffer/buffer_test.go:32:1: Function TestBufferWrites missing the call to method parallel (paralleltest) buffer/buffer_test.go:55:2: Range statement for test TestBufferWrites missing the call to method parallel in test Run (paralleltest) buffer/pool_test.go:30:1: Function TestBuffers missing the call to method parallel (paralleltest) clock_test.go:39:1: Function TestWithClock missing the call to method parallel (paralleltest) config_test.go:34:1: Function TestConfig missing the call to method parallel (paralleltest) config_test.go:59:2: Range statement for test TestConfig missing the call to method parallel in test Run (paralleltest) config_test.go:88:1: Function TestConfigWithInvalidPaths missing the call to method parallel (paralleltest) config_test.go:99:2: Range statement for test TestConfigWithInvalidPaths missing the call to method parallel in test Run (paralleltest) config_test.go:110:1: Function TestConfigWithMissingAttributes missing the call to method parallel (paralleltest) config_test.go:137:2: Range statement for test TestConfigWithMissingAttributes missing the call to method parallel in test Run (paralleltest) config_test.go:161:1: Function TestConfigWithSamplingHook missing the call to method parallel (paralleltest) encoder_test.go:31:1: Function TestRegisterDefaultEncoders missing the call to method parallel (paralleltest) encoder_test.go:35:1: Function TestRegisterEncoder missing the call to method parallel (paralleltest) encoder_test.go:42:1: Function TestDuplicateRegisterEncoder missing the call to method parallel (paralleltest) encoder_test.go:49:1: Function TestRegisterEncoderNoName missing the call to method parallel (paralleltest) encoder_test.go:53:1: Function TestNewEncoder missing the call to method parallel (paralleltest) encoder_test.go:62:1: Function TestNewEncoderNotRegistered missing the call to method parallel (paralleltest) encoder_test.go:67:1: Function TestNewEncoderNoName missing the call to method parallel (paralleltest) error_test.go:34:1: Function TestErrorConstructors missing the call to method parallel (paralleltest) error_test.go:58:1: Function TestErrorArrayConstructor missing the call to method parallel (paralleltest) error_test.go:81:1: Function TestErrorsArraysHandleRichErrors missing the call to method parallel (paralleltest) field_test.go:63:1: Function TestFieldConstructors missing the call to method parallel (paralleltest) field_test.go:258:2: Range statement for test TestFieldConstructors missing the call to method parallel in test Run (paralleltest) field_test.go:268:1: Function TestStackField missing the call to method parallel (paralleltest) field_test.go:277:1: Function TestStackSkipField missing the call to method parallel (paralleltest) field_test.go:286:1: Function TestStackSkipFieldWithSkip missing the call to method parallel (paralleltest) field_test.go:294:1: Function TestDict missing the call to method parallel (paralleltest) field_test.go:305:2: Range statement for test TestDict missing the call to method parallel in test Run (paralleltest) flag_test.go:68:1: Function TestLevelFlag missing the call to method parallel (paralleltest) flag_test.go:90:1: Function TestLevelFlagsAreIndependent missing the call to method parallel (paralleltest) global_test.go:40:1: Function TestReplaceGlobals missing the call to method parallel (paralleltest) global_test.go:69:1: Function TestGlobalsConcurrentUse missing the call to method parallel (paralleltest) global_test.go:100:1: Function TestNewStdLog missing the call to method parallel (paralleltest) global_test.go:108:1: Function TestNewStdLogAt missing the call to method parallel (paralleltest) global_test.go:121:1: Function TestNewStdLogAtPanics missing the call to method parallel (paralleltest) global_test.go:134:1: Function TestNewStdLogAtFatal missing the call to method parallel (paralleltest) global_test.go:147:1: Function TestNewStdLogAtInvalid missing the call to method parallel (paralleltest) global_test.go:152:1: Function TestRedirectStdLog missing the call to method parallel (paralleltest) global_test.go:170:1: Function TestRedirectStdLogCaller missing the call to method parallel (paralleltest) global_test.go:180:1: Function TestRedirectStdLogAt missing the call to method parallel (paralleltest) global_test.go:204:1: Function TestRedirectStdLogAtCaller missing the call to method parallel (paralleltest) global_test.go:220:1: Function TestRedirectStdLogAtPanics missing the call to method parallel (paralleltest) global_test.go:240:1: Function TestRedirectStdLogAtFatal missing the call to method parallel (paralleltest) global_test.go:260:1: Function TestRedirectStdLogAtInvalid missing the call to method parallel (paralleltest) http_handler_test.go:38:1: Function TestAtomicLevelServeHTTP missing the call to method parallel (paralleltest) http_handler_test.go:155:2: Range statement for test TestAtomicLevelServeHTTP missing the call to method parallel in test Run (paralleltest) increase_level_test.go:42:1: Function TestIncreaseLevelTryDecrease missing the call to method parallel (paralleltest) increase_level_test.go:68:1: Function TestIncreaseLevel missing the call to method parallel (paralleltest) internal/color/color_test.go:29:1: Function TestColorFormatting missing the call to method parallel (paralleltest) internal/exit/exit_test.go:30:1: Function TestStub missing the call to method parallel (paralleltest) internal/pool/pool_test.go:36:1: Function TestNew missing the call to method parallel (paralleltest) internal/pool/pool_test.go:78:1: Function TestNew_Race missing the call to method parallel (paralleltest) internal/stacktrace/stack_test.go:32:1: Function TestTake missing the call to method parallel (paralleltest) internal/stacktrace/stack_test.go:44:1: Function TestTakeWithSkip missing the call to method parallel (paralleltest) internal/stacktrace/stack_test.go:56:1: Function TestTakeWithSkipInnerFunc missing the call to method parallel (paralleltest) internal/stacktrace/stack_test.go:71:1: Function TestTakeDeepStack missing the call to method parallel (paralleltest) internal/ztest/clock_test.go:31:1: Function TestMockClock_NewTicker missing the call to method parallel (paralleltest) internal/ztest/clock_test.go:59:1: Function TestMockClock_NewTicker_slowConsumer missing the call to method parallel (paralleltest) internal/ztest/clock_test.go:77:1: Function TestMockClock_Add_negative missing the call to method parallel (paralleltest) level_test.go:33:1: Function TestLevelEnablerFunc missing the call to method parallel (paralleltest) level_test.go:52:1: Function TestNewAtomicLevel missing the call to method parallel (paralleltest) level_test.go:61:1: Function TestParseAtomicLevel missing the call to method parallel (paralleltest) level_test.go:83:1: Function TestAtomicLevelMutation missing the call to method parallel (paralleltest) level_test.go:101:1: Function TestAtomicLevelText missing the call to method parallel (paralleltest) logger_test.go:49:1: Function TestLoggerAtomicLevel missing the call to method parallel (paralleltest) logger_test.go:88:1: Function TestLoggerLevel missing the call to method parallel (paralleltest) logger_test.go:115:1: Function TestLoggerInitialFields missing the call to method parallel (paralleltest) logger_test.go:128:1: Function TestLoggerWith missing the call to method parallel (paralleltest) logger_test.go:155:2: Range statement for test TestLoggerWith missing the call to method parallel in test Run (paralleltest) logger_test.go:178:1: Function TestLoggerWithCaptures missing the call to method parallel (paralleltest) logger_test.go:339:2: Range statement for test TestLoggerWithCaptures missing the call to method parallel in test Run (paralleltest) logger_test.go:375:1: Function TestLoggerLogPanic missing the call to method parallel (paralleltest) logger_test.go:405:1: Function TestLoggerLogFatal missing the call to method parallel (paralleltest) logger_test.go:432:1: Function TestLoggerLeveledMethods missing the call to method parallel (paralleltest) logger_test.go:458:1: Function TestLoggerLogLevels missing the call to method parallel (paralleltest) logger_test.go:481:1: Function TestLoggerAlwaysPanics missing the call to method parallel (paralleltest) logger_test.go:497:1: Function TestLoggerAlwaysFatals missing the call to method parallel (paralleltest) logger_test.go:518:1: Function TestLoggerDPanic missing the call to method parallel (paralleltest) logger_test.go:539:1: Function TestLoggerNoOpsDisabledLevels missing the call to method parallel (paralleltest) logger_test.go:551:1: Function TestLoggerNames missing the call to method parallel (paralleltest) logger_test.go:590:1: Function TestLoggerWriteFailure missing the call to method parallel (paralleltest) logger_test.go:607:1: Function TestLoggerSync missing the call to method parallel (paralleltest) logger_test.go:614:1: Function TestLoggerSyncFail missing the call to method parallel (paralleltest) logger_test.go:627:1: Function TestLoggerAddCaller missing the call to method parallel (paralleltest) logger_test.go:659:1: Function TestLoggerAddCallerFunction missing the call to method parallel (paralleltest) logger_test.go:739:1: Function TestLoggerAddCallerFail missing the call to method parallel (paralleltest) logger_test.go:762:1: Function TestLoggerReplaceCore missing the call to method parallel (paralleltest) logger_test.go:774:1: Function TestLoggerIncreaseLevel missing the call to method parallel (paralleltest) logger_test.go:789:1: Function TestLoggerHooks missing the call to method parallel (paralleltest) logger_test.go:798:1: Function TestLoggerConcurrent missing the call to method parallel (paralleltest) logger_test.go:828:1: Function TestLoggerFatalOnNoop missing the call to method parallel (paralleltest) logger_test.go:839:1: Function TestLoggerCustomOnFatal missing the call to method parallel (paralleltest) logger_test.go:857:2: Range statement for test TestLoggerCustomOnFatal missing the call to method parallel in test Run (paralleltest) logger_test.go:891:1: Function TestLoggerWithFatalHook missing the call to method parallel (paralleltest) logger_test.go:900:1: Function TestNopLogger missing the call to method parallel (paralleltest) logger_test.go:903:2: Function TestNopLogger missing the call to method parallel in the test run (paralleltest) logger_test.go:910:2: Function TestNopLogger missing the call to method parallel in the test run (paralleltest) logger_test.go:914:2: Function TestNopLogger missing the call to method parallel in the test run (paralleltest) logger_test.go:921:1: Function TestMust missing the call to method parallel (paralleltest) logger_test.go:922:2: Function TestMust missing the call to method parallel in the test run (paralleltest) logger_test.go:926:2: Function TestMust missing the call to method parallel in the test run (paralleltest) sink_test.go:47:1: Function TestRegisterSink missing the call to method parallel (paralleltest) sink_test.go:86:1: Function TestRegisterSinkErrors missing the call to method parallel (paralleltest) sink_test.go:100:2: Range statement for test TestRegisterSinkErrors missing the call to method parallel in test Run (paralleltest) stacktrace_ext_test.go:49:1: Function TestStacktraceFiltersZapLog missing the call to method parallel (paralleltest) stacktrace_ext_test.go:59:1: Function TestStacktraceFiltersZapMarshal missing the call to method parallel (paralleltest) stacktrace_ext_test.go:86:1: Function TestStacktraceFiltersVendorZap missing the call to method parallel (paralleltest) stacktrace_ext_test.go:122:1: Function TestStacktraceWithoutCallerSkip missing the call to method parallel (paralleltest) stacktrace_ext_test.go:133:1: Function TestStacktraceWithCallerSkip missing the call to method parallel (paralleltest) sugar_test.go:36:1: Function TestSugarWith missing the call to method parallel (paralleltest) sugar_test.go:187:1: Function TestSugarFieldsInvalidPairs missing the call to method parallel (paralleltest) sugar_test.go:207:1: Function TestSugarStructuredLogging missing the call to method parallel (paralleltest) sugar_test.go:244:1: Function TestSugarConcatenatingLogging missing the call to method parallel (paralleltest) sugar_test.go:276:1: Function TestSugarTemplatedLogging missing the call to method parallel (paralleltest) sugar_test.go:312:1: Function TestSugarLnLogging missing the call to method parallel (paralleltest) sugar_test.go:348:1: Function TestSugarLnLoggingIgnored missing the call to method parallel (paralleltest) sugar_test.go:355:1: Function TestSugarPanicLogging missing the call to method parallel (paralleltest) sugar_test.go:390:1: Function TestSugarFatalLogging missing the call to method parallel (paralleltest) sugar_test.go:426:1: Function TestSugarAddCaller missing the call to method parallel (paralleltest) sugar_test.go:451:1: Function TestSugarAddCallerFail missing the call to method parallel (paralleltest) sugar_test.go:469:1: Function TestSugarWithOptionsIncreaseLevel missing the call to method parallel (paralleltest) sugar_test.go:485:1: Function TestSugarLnWithOptionsIncreaseLevel missing the call to method parallel (paralleltest) time_test.go:30:1: Function TestTimeToMillis missing the call to method parallel (paralleltest) writer_test.go:38:1: Function TestOpenNoPaths missing the call to method parallel (paralleltest) writer_test.go:51:1: Function TestOpen missing the call to method parallel (paralleltest) writer_test.go:82:2: Range statement for test TestOpen missing the call to method parallel in test Run (paralleltest) writer_test.go:96:1: Function TestOpenPathsNotFound missing the call to method parallel (paralleltest) writer_test.go:124:2: Range statement for test TestOpenPathsNotFound missing the call to method parallel in test Run (paralleltest) writer_test.go:142:1: Function TestOpenRelativePath missing the call to method parallel (paralleltest) writer_test.go:162:1: Function TestOpenFails missing the call to method parallel (paralleltest) writer_test.go:179:1: Function TestOpenOtherErrors missing the call to method parallel (paralleltest) writer_test.go:214:2: Range statement for test TestOpenOtherErrors missing the call to method parallel in test Run (paralleltest) writer_test.go:241:1: Function TestOpenWithErroringSinkFactory missing the call to method parallel (paralleltest) writer_test.go:254:1: Function TestCombineWriteSyncers missing the call to method parallel (paralleltest) zapcore/buffered_write_syncer_test.go:33:1: Function TestBufferWriter missing the call to method parallel (paralleltest) zapcore/buffered_write_syncer_test.go:36:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:47:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:56:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:64:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:77:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:88:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:99:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:109:2: Function TestBufferWriter missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:130:1: Function TestBufferWriterWithoutStart missing the call to method parallel (paralleltest) zapcore/buffered_write_syncer_test.go:131:2: Function TestBufferWriterWithoutStart missing the call to method parallel in the test run (paralleltest) zapcore/buffered_write_syncer_test.go:136:2: Function TestBufferWriterWithoutStart missing the call to method parallel in the test run (paralleltest) zapcore/clock_test.go:33:1: Function TestSystemClock_NewTicker missing the call to method parallel (paralleltest) zapcore/console_encoder_test.go:38:1: Function TestConsoleSeparator missing the call to method parallel (paralleltest) zapcore/console_encoder_test.go:66:2: Range statement for test TestConsoleSeparator missing the call to method parallel in test Run (paralleltest) zapcore/core_test.go:40:1: Function TestNopCore missing the call to method parallel (paralleltest) zapcore/core_test.go:69:1: Function TestIOCore missing the call to method parallel (paralleltest) zapcore/core_test.go:110:1: Function TestIOCoreSyncFail missing the call to method parallel (paralleltest) zapcore/core_test.go:129:1: Function TestIOCoreSyncsOutput missing the call to method parallel (paralleltest) zapcore/core_test.go:156:1: Function TestIOCoreWriteFailure missing the call to method parallel (paralleltest) zapcore/encoder_test.go:77:1: Function TestEncoderConfiguration missing the call to method parallel (paralleltest) zapcore/encoder_test.go:563:1: Function TestLevelEncoders missing the call to method parallel (paralleltest) zapcore/encoder_test.go:586:1: Function TestTimeEncoders missing the call to method parallel (paralleltest) zapcore/encoder_test.go:618:1: Function TestTimeEncodersWrongYAML missing the call to method parallel (paralleltest) zapcore/encoder_test.go:629:1: Function TestTimeEncodersParseFromJSON missing the call to method parallel (paralleltest) zapcore/encoder_test.go:652:1: Function TestDurationEncoders missing the call to method parallel (paralleltest) zapcore/encoder_test.go:677:1: Function TestCallerEncoders missing the call to method parallel (paralleltest) zapcore/encoder_test.go:701:1: Function TestNameEncoders missing the call to method parallel (paralleltest) zapcore/entry_test.go:48:1: Function TestPutNilEntry missing the call to method parallel (paralleltest) zapcore/entry_test.go:76:1: Function TestEntryCaller missing the call to method parallel (paralleltest) zapcore/entry_test.go:106:1: Function TestCheckedEntryWrite missing the call to method parallel (paralleltest) zapcore/entry_test.go:107:2: Function TestCheckedEntryWrite missing the call to method parallel in the test run (paralleltest) zapcore/entry_test.go:112:2: Function TestCheckedEntryWrite missing the call to method parallel in the test run (paralleltest) zapcore/entry_test.go:118:2: Function TestCheckedEntryWrite missing the call to method parallel in the test run (paralleltest) zapcore/entry_test.go:124:2: Function TestCheckedEntryWrite missing the call to method parallel in the test run (paralleltest) zapcore/entry_test.go:134:2: Function TestCheckedEntryWrite missing the call to method parallel in the test run (paralleltest) zapcore/error_test.go:67:1: Function TestErrorEncoding missing the call to method parallel (paralleltest) zapcore/error_test.go:155:1: Function TestRichErrorSupport missing the call to method parallel (paralleltest) zapcore/field_test.go:96:1: Function TestUnknownFieldType missing the call to method parallel (paralleltest) zapcore/field_test.go:104:1: Function TestFieldAddingError missing the call to method parallel (paralleltest) zapcore/field_test.go:130:1: Function TestFields missing the call to method parallel (paralleltest) zapcore/field_test.go:183:1: Function TestInlineMarshaler missing the call to method parallel (paralleltest) zapcore/field_test.go:204:1: Function TestEquals missing the call to method parallel (paralleltest) zapcore/hook_test.go:33:1: Function TestHooks missing the call to method parallel (paralleltest) zapcore/hook_test.go:44:2: Range statement for test TestHooks missing the call to method parallel in test Run (paralleltest) zapcore/increase_level_test.go:34:1: Function TestIncreaseLevel missing the call to method parallel (paralleltest) zapcore/increase_level_test.go:80:2: Range statement for test TestIncreaseLevel missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_impl_test.go:47:1: Function TestJSONClone missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:60:1: Function TestJSONEscaping missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:95:2: Function TestJSONEscaping missing the call to method parallel in the test run (paralleltest) zapcore/json_encoder_impl_test.go:103:2: Function TestJSONEscaping missing the call to method parallel in the test run (paralleltest) zapcore/json_encoder_impl_test.go:112:1: Function TestJSONEncoderObjectFields missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:284:2: Range statement for test TestJSONEncoderObjectFields missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_impl_test.go:291:1: Function TestJSONEncoderTimeFormats missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:333:2: Range statement for test TestJSONEncoderTimeFormats missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_impl_test.go:340:1: Function TestJSONEncoderArrays missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:442:2: Range statement for test TestJSONEncoderArrays missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_impl_test.go:459:1: Function TestJSONEncoderTimeArrays missing the call to method parallel (paralleltest) zapcore/json_encoder_impl_test.go:493:2: Range statement for test TestJSONEncoderTimeArrays missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_impl_test.go:655:1: Function TestJSONQuick missing the call to method parallel (paralleltest) zapcore/json_encoder_test.go:39:1: Function TestJSONEncodeEntry missing the call to method parallel (paralleltest) zapcore/json_encoder_test.go:128:2: Range statement for test TestJSONEncodeEntry missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_test.go:139:1: Function TestNoEncodeLevelSupplied missing the call to method parallel (paralleltest) zapcore/json_encoder_test.go:168:1: Function TestJSONEmptyConfig missing the call to method parallel (paralleltest) zapcore/json_encoder_test.go:186:2: Range statement for test TestJSONEmptyConfig missing the call to method parallel in test Run (paralleltest) zapcore/json_encoder_test.go:215:1: Function TestJSONCustomReflectedEncoder missing the call to method parallel (paralleltest) zapcore/lazy_with_test.go:60:1: Function TestLazyCore missing the call to method parallel (paralleltest) zapcore/lazy_with_test.go:122:2: Range statement for test TestLazyCore missing the call to method parallel in test Run (paralleltest) zapcore/level_strings_test.go:29:1: Function TestAllLevelsCoveredByLevelString missing the call to method parallel (paralleltest) zapcore/level_test.go:32:1: Function TestLevelString missing the call to method parallel (paralleltest) zapcore/level_test.go:51:1: Function TestLevelText missing the call to method parallel (paralleltest) zapcore/level_test.go:80:1: Function TestParseLevel missing the call to method parallel (paralleltest) zapcore/level_test.go:101:1: Function TestCapitalLevelsParse missing the call to method parallel (paralleltest) zapcore/level_test.go:122:1: Function TestWeirdLevelsParse missing the call to method parallel (paralleltest) zapcore/level_test.go:153:1: Function TestLevelNils missing the call to method parallel (paralleltest) zapcore/level_test.go:169:1: Function TestLevelUnmarshalUnknownText missing the call to method parallel (paralleltest) zapcore/level_test.go:175:1: Function TestLevelAsFlagValue missing the call to method parallel (paralleltest) zapcore/level_test.go:215:1: Function TestLevelOf missing the call to method parallel (paralleltest) zapcore/memory_encoder_test.go:31:1: Function TestMapObjectEncoderAdd missing the call to method parallel (paralleltest) zapcore/memory_encoder_test.go:250:2: Range statement for test TestMapObjectEncoderAdd missing the call to method parallel in test Run (paralleltest) zapcore/memory_encoder_test.go:259:1: Function TestSliceArrayEncoderAppend missing the call to method parallel (paralleltest) zapcore/memory_encoder_test.go:345:2: Range statement for test TestSliceArrayEncoderAppend missing the call to method parallel in test Run (paralleltest) zapcore/memory_encoder_test.go:361:1: Function TestMapObjectEncoderReflectionFailures missing the call to method parallel (paralleltest) zapcore/sampler_test.go:69:1: Function TestSampler missing the call to method parallel (paralleltest) zapcore/sampler_test.go:91:1: Function TestLevelOfSampler missing the call to method parallel (paralleltest) zapcore/sampler_test.go:104:1: Function TestSamplerDisabledLevels missing the call to method parallel (paralleltest) zapcore/sampler_test.go:113:1: Function TestSamplerTicking missing the call to method parallel (paralleltest) zapcore/sampler_test.go:169:1: Function TestSamplerConcurrent missing the call to method parallel (paralleltest) zapcore/sampler_test.go:250:1: Function TestSamplerRaces missing the call to method parallel (paralleltest) zapcore/sampler_test.go:271:1: Function TestSamplerUnknownLevels missing the call to method parallel (paralleltest) zapcore/sampler_test.go:278:2: Range statement for test TestSamplerUnknownLevels missing the call to method parallel in test Run (paralleltest) zapcore/sampler_test.go:291:1: Function TestSamplerWithZeroThereafter missing the call to method parallel (paralleltest) zapcore/tee_test.go:41:1: Function TestTeeUnusualInput missing the call to method parallel (paralleltest) zapcore/tee_test.go:43:2: Function TestTeeUnusualInput missing the call to method parallel in the test run (paralleltest) zapcore/tee_test.go:47:2: Function TestTeeUnusualInput missing the call to method parallel in the test run (paralleltest) zapcore/tee_test.go:52:1: Function TestLevelOfTee missing the call to method parallel (paralleltest) zapcore/tee_test.go:90:1: Function TestTeeCheck missing the call to method parallel (paralleltest) zapcore/tee_test.go:116:1: Function TestTeeWrite missing the call to method parallel (paralleltest) zapcore/tee_test.go:135:1: Function TestTeeWith missing the call to method parallel (paralleltest) zapcore/tee_test.go:152:1: Function TestTeeEnabled missing the call to method parallel (paralleltest) zapcore/tee_test.go:174:1: Function TestTeeSync missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:45:1: Function TestAddSyncWriteSyncer missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:58:1: Function TestAddSyncWriter missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:67:1: Function TestNewMultiWriteSyncerWorksForSingleWriter missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:77:1: Function TestMultiWriteSyncerWritesBoth missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:91:1: Function TestMultiWriteSyncerFailsWrite missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:97:1: Function TestMultiWriteSyncerFailsShortWrite missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:104:1: Function TestWritestoAllSyncs_EvenIfFirstErrors missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:114:1: Function TestMultiWriteSyncerSync_PropagatesErrors missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:122:1: Function TestMultiWriteSyncerSync_NoErrorsOnDiscard missing the call to method parallel (paralleltest) zapcore/write_syncer_test.go:127:1: Function TestMultiWriteSyncerSync_AllCalled missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:34:1: Function TestLoggerInfoExpected missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:68:1: Function TestLoggerDebugExpected missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:88:1: Function TestLoggerDebugSuppressed missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:98:1: Function TestLoggerWarningExpected missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:118:1: Function TestLoggerErrorExpected missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:138:1: Function TestLoggerFatalExpected missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:158:1: Function TestLoggerV missing the call to method parallel (paralleltest) zapgrpc/zapgrpc_test.go:200:2: Range statement for test TestLoggerV missing the call to method parallel in test Run (paralleltest) zapio/writer_test.go:173:2: Function TestWrite_Sync missing the call to method parallel in the test run (paralleltest) zapio/writer_test.go:177:2: Function TestWrite_Sync missing the call to method parallel in the test run (paralleltest) zapio/writer_test.go:187:2: Function TestWrite_Sync missing the call to method parallel in the test run (paralleltest) zaptest/logger_test.go:37:1: Function TestTestLogger missing the call to method parallel (paralleltest) zaptest/logger_test.go:61:1: Function TestTestLoggerSupportsLevels missing the call to method parallel (paralleltest) zaptest/logger_test.go:83:1: Function TestTestLoggerSupportsWrappedZapOptions missing the call to method parallel (paralleltest) zaptest/logger_test.go:107:1: Function TestTestingWriter missing the call to method parallel (paralleltest) zaptest/logger_test.go:116:1: Function TestTestLoggerErrorOutput missing the call to method parallel (paralleltest) zaptest/observer/logged_entry_test.go:32:1: Function TestLoggedEntryContextMap missing the call to method parallel (paralleltest) zaptest/observer/logged_entry_test.go:80:2: Range statement for test TestLoggedEntryContextMap missing the call to method parallel in test Run (paralleltest) zaptest/observer/observer_test.go:40:1: Function TestObserver missing the call to method parallel (paralleltest) zaptest/observer/observer_test.go:74:1: Function TestObserverWith missing the call to method parallel (paralleltest) zaptest/observer/observer_test.go:126:1: Function TestFilters missing the call to method parallel (paralleltest) zaptest/timeout_test.go:31:1: Function TestTimeout missing the call to method parallel (paralleltest) zaptest/timeout_test.go:36:1: Function TestSleep missing the call to method parallel (paralleltest) zaptest/writer_test.go:30:1: Function TestSyncer missing the call to method parallel (paralleltest) zaptest/writer_test.go:38:1: Function TestDiscarder missing the call to method parallel (paralleltest) zaptest/writer_test.go:46:1: Function TestFailWriter missing the call to method parallel (paralleltest) zaptest/writer_test.go:54:1: Function TestShortWriter missing the call to method parallel (paralleltest) zaptest/writer_test.go:62:1: Function TestBuffer missing the call to method parallel (paralleltest) exp/zapfield/zapfield_test.go:38:1: Function TestFieldConstructors missing the call to method parallel (paralleltest) exp/zapslog/handler_test.go:53:1: Function TestAddStack missing the call to method parallel (paralleltest) exp/zapslog/handler_test.go:73:1: Function TestAddStackSkip missing the call to method parallel (paralleltest) exp/zapslog/handler_test.go:93:2: Function TestEmptyAttr missing the call to method parallel in the test run (paralleltest) exp/zapslog/handler_test.go:107:2: Function TestEmptyAttr missing the call to method parallel in the test run (paralleltest) exp/zapslog/handler_test.go:117:2: Function TestEmptyAttr missing the call to method parallel in the test run (paralleltest) exp/zapslog/handler_test.go:133:2: Function TestWithName missing the call to method parallel in the test run (paralleltest) exp/zapslog/handler_test.go:142:2: Function TestWithName missing the call to method parallel in the test run (paralleltest) exp/zapslog/handler_test.go:159:1: Function TestAttrKinds missing the call to method parallel (paralleltest) zapgrpc/internal/test/grpc_test.go:35:1: Function TestLoggerV2 missing the call to method parallel (paralleltest) ``` </details>
1 parent ed7ddb5 commit 7b6c114

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1327
-460
lines changed

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ linters:
1818

1919
# Our own extras:
2020
- gofumpt
21-
- nolintlint # lints nolint directives
21+
- nolintlint # lints nolint directives
22+
- paralleltest # requires t.Parallel on all tests
2223
- revive
2324

2425
linters-settings:

array_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ func BenchmarkBoolsReflect(b *testing.B) {
5353
}
5454

5555
func TestArrayWrappers(t *testing.T) {
56+
t.Parallel()
57+
5658
tests := []struct {
5759
desc string
5860
field Field
@@ -101,11 +103,16 @@ func TestArrayWrappers(t *testing.T) {
101103
}
102104

103105
for _, tt := range tests {
104-
enc := zapcore.NewMapObjectEncoder()
105-
tt.field.Key = "k"
106-
tt.field.AddTo(enc)
107-
assert.Equal(t, tt.expected, enc.Fields["k"], "%s: unexpected map contents.", tt.desc)
108-
assert.Equal(t, 1, len(enc.Fields), "%s: found extra keys in map: %v", tt.desc, enc.Fields)
106+
tt := tt
107+
t.Run(tt.desc, func(t *testing.T) {
108+
t.Parallel()
109+
110+
enc := zapcore.NewMapObjectEncoder()
111+
tt.field.Key = "k"
112+
tt.field.AddTo(enc)
113+
assert.Equal(t, tt.expected, enc.Fields["k"], "unexpected map contents")
114+
assert.Equal(t, 1, len(enc.Fields), "found extra keys in map: %v", enc.Fields)
115+
})
109116
}
110117
}
111118

buffer/buffer_test.go

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,86 @@ import (
3030
)
3131

3232
func TestBufferWrites(t *testing.T) {
33-
buf := NewPool().Get()
33+
t.Parallel()
3434

3535
tests := []struct {
3636
desc string
37-
f func()
37+
f func(*Buffer)
3838
want string
3939
}{
40-
{"AppendByte", func() { buf.AppendByte('v') }, "v"},
41-
{"AppendString", func() { buf.AppendString("foo") }, "foo"},
42-
{"AppendIntPositive", func() { buf.AppendInt(42) }, "42"},
43-
{"AppendIntNegative", func() { buf.AppendInt(-42) }, "-42"},
44-
{"AppendUint", func() { buf.AppendUint(42) }, "42"},
45-
{"AppendBool", func() { buf.AppendBool(true) }, "true"},
46-
{"AppendFloat64", func() { buf.AppendFloat(3.14, 64) }, "3.14"},
40+
{
41+
desc: "AppendByte",
42+
f: func(buf *Buffer) { buf.AppendByte('v') },
43+
want: "v",
44+
},
45+
{
46+
desc: "AppendString",
47+
f: func(buf *Buffer) { buf.AppendString("foo") },
48+
want: "foo",
49+
},
50+
{
51+
desc: "AppendIntPositive",
52+
f: func(buf *Buffer) { buf.AppendInt(42) },
53+
want: "42",
54+
},
55+
{
56+
desc: "AppendIntNegative",
57+
f: func(buf *Buffer) { buf.AppendInt(-42) },
58+
want: "-42",
59+
},
60+
{
61+
desc: "AppendUint",
62+
f: func(buf *Buffer) { buf.AppendUint(42) },
63+
want: "42",
64+
},
65+
{
66+
desc: "AppendBool",
67+
f: func(buf *Buffer) { buf.AppendBool(true) },
68+
want: "true",
69+
},
70+
{
71+
desc: "AppendFloat64",
72+
f: func(buf *Buffer) { buf.AppendFloat(3.14, 64) },
73+
want: "3.14",
74+
},
4775
// Intentionally introduce some floating-point error.
48-
{"AppendFloat32", func() { buf.AppendFloat(float64(float32(3.14)), 32) }, "3.14"},
49-
{"AppendWrite", func() { buf.Write([]byte("foo")) }, "foo"},
50-
{"AppendTime", func() { buf.AppendTime(time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC), time.RFC3339) }, "2000-01-02T03:04:05Z"},
51-
{"WriteByte", func() { buf.WriteByte('v') }, "v"},
52-
{"WriteString", func() { buf.WriteString("foo") }, "foo"},
76+
{
77+
desc: "AppendFloat32",
78+
f: func(buf *Buffer) { buf.AppendFloat(float64(float32(3.14)), 32) },
79+
want: "3.14",
80+
},
81+
{
82+
desc: "AppendWrite",
83+
f: func(buf *Buffer) { buf.Write([]byte("foo")) },
84+
want: "foo",
85+
},
86+
{
87+
desc: "AppendTime",
88+
f: func(buf *Buffer) { buf.AppendTime(time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC), time.RFC3339) },
89+
want: "2000-01-02T03:04:05Z",
90+
},
91+
{
92+
desc: "WriteByte",
93+
f: func(buf *Buffer) { buf.WriteByte('v') },
94+
want: "v",
95+
},
96+
{
97+
desc: "WriteString",
98+
f: func(buf *Buffer) { buf.WriteString("foo") },
99+
want: "foo",
100+
},
53101
}
54102

103+
pool := NewPool()
55104
for _, tt := range tests {
105+
tt := tt
56106
t.Run(tt.desc, func(t *testing.T) {
57-
buf.Reset()
58-
tt.f()
107+
t.Parallel()
108+
109+
buf := pool.Get()
110+
defer buf.Free()
111+
112+
tt.f(buf)
59113
assert.Equal(t, tt.want, buf.String(), "Unexpected buffer.String().")
60114
assert.Equal(t, tt.want, string(buf.Bytes()), "Unexpected string(buffer.Bytes()).")
61115
assert.Equal(t, len(tt.want), buf.Len(), "Unexpected buffer length.")

buffer/pool_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
)
2929

3030
func TestBuffers(t *testing.T) {
31+
t.Parallel()
32+
3133
const dummyData = "dummy data"
3234
p := NewPool()
3335

clock_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func (c constantClock) NewTicker(d time.Duration) *time.Ticker {
3737
}
3838

3939
func TestWithClock(t *testing.T) {
40+
t.Parallel()
41+
4042
date := time.Date(2077, 1, 23, 10, 15, 13, 441, time.UTC)
4143
clock := constantClock(date)
4244
withLogger(t, DebugLevel, []Option{WithClock(clock)}, func(log *Logger, logs *observer.ObservedLogs) {

config_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
)
3333

3434
func TestConfig(t *testing.T) {
35+
t.Parallel()
36+
3537
tests := []struct {
3638
desc string
3739
cfg Config
@@ -57,7 +59,10 @@ func TestConfig(t *testing.T) {
5759
}
5860

5961
for _, tt := range tests {
62+
tt := tt
6063
t.Run(tt.desc, func(t *testing.T) {
64+
t.Parallel()
65+
6166
logOut := filepath.Join(t.TempDir(), "test.log")
6267

6368
tt.cfg.OutputPaths = []string{logOut}
@@ -86,6 +91,8 @@ func TestConfig(t *testing.T) {
8691
}
8792

8893
func TestConfigWithInvalidPaths(t *testing.T) {
94+
t.Parallel()
95+
8996
tests := []struct {
9097
desc string
9198
output string
@@ -97,7 +104,10 @@ func TestConfigWithInvalidPaths(t *testing.T) {
97104
}
98105

99106
for _, tt := range tests {
107+
tt := tt
100108
t.Run(tt.desc, func(t *testing.T) {
109+
t.Parallel()
110+
101111
cfg := NewProductionConfig()
102112
cfg.OutputPaths = []string{tt.output}
103113
cfg.ErrorOutputPaths = []string{tt.errOutput}
@@ -108,6 +118,8 @@ func TestConfigWithInvalidPaths(t *testing.T) {
108118
}
109119

110120
func TestConfigWithMissingAttributes(t *testing.T) {
121+
t.Parallel()
122+
111123
tests := []struct {
112124
desc string
113125
cfg Config
@@ -135,7 +147,10 @@ func TestConfigWithMissingAttributes(t *testing.T) {
135147
}
136148

137149
for _, tt := range tests {
150+
tt := tt
138151
t.Run(tt.desc, func(t *testing.T) {
152+
t.Parallel()
153+
139154
cfg := tt.cfg
140155
_, err := cfg.Build()
141156
assert.EqualError(t, err, tt.expectErr)
@@ -159,6 +174,8 @@ func makeSamplerCountingHook() (h func(zapcore.Entry, zapcore.SamplingDecision),
159174
}
160175

161176
func TestConfigWithSamplingHook(t *testing.T) {
177+
t.Parallel()
178+
162179
shook, dcount, scount := makeSamplerCountingHook()
163180
cfg := Config{
164181
Level: NewAtomicLevelAt(InfoLevel),

encoder_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ import (
2929
)
3030

3131
func TestRegisterDefaultEncoders(t *testing.T) {
32+
t.Parallel()
33+
3234
testEncodersRegistered(t, "console", "json")
3335
}
3436

37+
//nolint:paralleltest // modifies global registry
3538
func TestRegisterEncoder(t *testing.T) {
3639
testEncoders(func() {
3740
assert.NoError(t, RegisterEncoder("foo", newNilEncoder), "expected to be able to register the encoder foo")
3841
testEncodersRegistered(t, "foo")
3942
})
4043
}
4144

45+
//nolint:paralleltest // modifies global registry
4246
func TestDuplicateRegisterEncoder(t *testing.T) {
4347
testEncoders(func() {
4448
assert.NoError(t, RegisterEncoder("foo", newNilEncoder), "expected to be able to register the encoder foo")
@@ -47,9 +51,12 @@ func TestDuplicateRegisterEncoder(t *testing.T) {
4751
}
4852

4953
func TestRegisterEncoderNoName(t *testing.T) {
54+
t.Parallel()
55+
5056
assert.Equal(t, errNoEncoderNameSpecified, RegisterEncoder("", newNilEncoder), "expected an error when registering an encoder with no name")
5157
}
5258

59+
//nolint:paralleltest // modifies global registry
5360
func TestNewEncoder(t *testing.T) {
5461
testEncoders(func() {
5562
assert.NoError(t, RegisterEncoder("foo", newNilEncoder), "expected to be able to register the encoder foo")
@@ -60,11 +67,15 @@ func TestNewEncoder(t *testing.T) {
6067
}
6168

6269
func TestNewEncoderNotRegistered(t *testing.T) {
70+
t.Parallel()
71+
6372
_, err := newEncoder("foo", zapcore.EncoderConfig{})
6473
assert.Error(t, err, "expected an error when trying to create an encoder of an unregistered name")
6574
}
6675

6776
func TestNewEncoderNoName(t *testing.T) {
77+
t.Parallel()
78+
6879
_, err := newEncoder("", zapcore.EncoderConfig{})
6980
assert.Equal(t, errNoEncoderNameSpecified, err, "expected an error when creating an encoder with no name")
7081
}

error_test.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
)
3333

3434
func TestErrorConstructors(t *testing.T) {
35+
t.Parallel()
36+
3537
fail := errors.New("fail")
3638

3739
tests := []struct {
@@ -48,14 +50,21 @@ func TestErrorConstructors(t *testing.T) {
4850
}
4951

5052
for _, tt := range tests {
51-
if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) {
52-
t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface)
53-
}
54-
assertCanBeReused(t, tt.field)
53+
tt := tt
54+
t.Run(tt.name, func(t *testing.T) {
55+
t.Parallel()
56+
57+
if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) {
58+
t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface)
59+
}
60+
assertCanBeReused(t, tt.field)
61+
})
5562
}
5663
}
5764

5865
func TestErrorArrayConstructor(t *testing.T) {
66+
t.Parallel()
67+
5968
tests := []struct {
6069
desc string
6170
field Field
@@ -70,15 +79,22 @@ func TestErrorArrayConstructor(t *testing.T) {
7079
}
7180

7281
for _, tt := range tests {
73-
enc := zapcore.NewMapObjectEncoder()
74-
tt.field.Key = "k"
75-
tt.field.AddTo(enc)
76-
assert.Equal(t, tt.expected, enc.Fields["k"], "%s: unexpected map contents.", tt.desc)
77-
assert.Equal(t, 1, len(enc.Fields), "%s: found extra keys in map: %v", tt.desc, enc.Fields)
82+
tt := tt
83+
t.Run(tt.desc, func(t *testing.T) {
84+
t.Parallel()
85+
86+
enc := zapcore.NewMapObjectEncoder()
87+
tt.field.Key = "k"
88+
tt.field.AddTo(enc)
89+
assert.Equal(t, tt.expected, enc.Fields["k"], "%s: unexpected map contents.", tt.desc)
90+
assert.Equal(t, 1, len(enc.Fields), "%s: found extra keys in map: %v", tt.desc, enc.Fields)
91+
})
7892
}
7993
}
8094

8195
func TestErrorsArraysHandleRichErrors(t *testing.T) {
96+
t.Parallel()
97+
8298
errs := []error{fmt.Errorf("egad")}
8399

84100
enc := zapcore.NewMapObjectEncoder()

exp/zapfield/zapfield_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type (
3636
)
3737

3838
func TestFieldConstructors(t *testing.T) {
39+
t.Parallel()
40+
3941
var (
4042
key = MyKey("test key")
4143
value = MyValue("test value")
@@ -55,10 +57,15 @@ func TestFieldConstructors(t *testing.T) {
5557
}
5658

5759
for _, tt := range tests {
58-
if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) {
59-
t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface)
60-
}
61-
assertCanBeReused(t, tt.field)
60+
tt := tt
61+
t.Run(tt.name, func(t *testing.T) {
62+
t.Parallel()
63+
64+
if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) {
65+
t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface)
66+
}
67+
assertCanBeReused(t, tt.field)
68+
})
6269
}
6370
}
6471

0 commit comments

Comments
 (0)