testing: add tests - #1
Draft
mohammed90 wants to merge 4 commits into
Draft
Conversation
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>
Member
Author
|
The commit 3034714 fixes all 9 bugs that the edge-case suite flagged red. The full suite, Source changesThread safety
Panics and crashes
Behavior corrections
Test changes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclosure: LLM generated (copilot/Claude Fable 5)
ℹ️ Draft until I review every single line
Adds a correctness-asserting test suite (7 new test files, 7 new testdata fixture packages) covering edge cases across all source files, plus a CI workflow. Every bug found is listed below with the test that covers it.
Unlike the existing baseline tests (which pass on current behavior), these tests assert correct behavior and intentionally fail red until the underlying bug is fixed. Toolchain-dependent tests are skipped under
go test -short; crash-prone cases (stack overflows, fatal map races) run isolated in child processes so they cannot take down the rest of the suite.New tests
-racejson:"-", unexported fields, non-string map keys, interface{}, RawMessage→Module, ModuleMap, embedded promotion, inline structs, recursive types, func/chan fieldsBugs found (B1–B12)
Confirmed, with red tests:
Driver.muis declared but never used;discoveredTypesis accessed unlocked — data race confirmed by-race(TestConcurrentDiscoveredTypesAccess)TraverseTypeindexesvals[0]without a length check — panics on unknown module IDs (TestTraverseTypeUnknownModuleID)TestBuildRepresentationUnsupportedFieldTypes)caddy.RegisterModule(otherpkg.Type{})panics with an interface-conversion error (TestFindModuleIdentsUnusualAST)TestModuleIDFromConstant,TestModuleIDFromConcatenation)deepDereferencehas no cycle detection — stack overflow (TestDeepDereferenceCycle)jsonNameFromTagcomma handling diverges from encoding/json (TestJSONNameFromTagEdgeCases)dereferencemutates Storage-owned values in place — doc duplication, namespace clobbering across contexts, and a second data race under concurrentLoadTypesByModuleID(TestDereferenceDoesNotMutateStoredType,TestConcurrentModuleTypeLoading)buildRepresentationhas no recursion guard — a self-referential struct (type Node struct { Next *Node }) stack-overflows (TestBuildRepresentationRecursiveType)Documented as possibly intended (green tests lock in the current contract):
TestUnregisteredModuleFailsPackage,TestRegistrationWithoutLocalImplementation)Investigated and disproven:
go mod initfailure does not existdereferencedoes not existOther changes
go vet+go test -short -race). Note: CI stays red until the bugs above are fixed — intentional per the red-test policyTest results
go test -short ./— passes except 5 intentional redsgo test ./— 10 intentional redsgo test -race ./— 12 intentional reds (adds the two concurrency tests)go vetcleanNotes for reviewers