Skip to content

Commit ab6d95e

Browse files
committed
Merge branch 'former_1' of github.com:Wandalen/wTools into former_1
2 parents a24fa01 + d2bd574 commit ab6d95e

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

module/core/test_tools/spec.md

Whitespace-only changes.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Task Plan: Fix `test_tools` Test Compilation Failures
2+
3+
### Goal
4+
* Resolve the widespread compilation failures in the `test_tools` test suite by correcting the conditional compilation logic that is incorrectly hiding the public API from tests.
5+
6+
### Ubiquitous Language (Vocabulary)
7+
* **Aggregated Test:** A test suite imported from another crate (e.g., `error_tools`) to be run within the context of `test_tools` to ensure re-export consistency.
8+
* **`doctest` feature:** A cargo feature used to conditionally compile code, intended to manage specifics of documentation generation.
9+
* **`cfg` gate:** A `#[cfg(...)]` attribute used for conditional compilation.
10+
11+
### Progress
12+
* **Primary Editable Crate:** `module/core/test_tools`
13+
* **Overall Progress:** 0/2 increments complete
14+
* **Increment Status:**
15+
* ⚫ Increment 1: Remove restrictive `cfg` gates and verify compilation
16+
* ⚫ Increment 2: Finalization
17+
18+
### Permissions & Boundaries
19+
* **Mode:** `code`
20+
* **Run workspace-wise commands:** `false`
21+
* **Add transient comments:** `true`
22+
* **Additional Editable Crates:**
23+
* None
24+
25+
### Relevant Context
26+
* Control Files to Reference (if they exist):
27+
* `./roadmap.md`
28+
* `./spec.md`
29+
* `./spec_addendum.md`
30+
* Files to Include (for AI's reference, if `read_file` is planned):
31+
* `module/core/test_tools/src/lib.rs`
32+
* `module/core/test_tools/.cargo/config.toml`
33+
* **Initial Analysis Summary:** The test suite fails with 147 `E0432` and `E0433` errors due to unresolved imports. The root cause is the `#[cfg(not(feature = "doctest"))]` attribute in `src/lib.rs` hiding the main API from the test runner. The test runner enables the `doctest` feature because of the `rustdocflags` in `.cargo/config.toml`, creating a conflict. The fix is to remove the problematic `cfg` gates to ensure the API is always visible to tests.
34+
35+
### Expected Behavior Rules / Specifications
36+
* The `test_tools` crate must successfully compile its entire test suite, including the aggregated tests from other modules.
37+
* The public API of `test_tools` must be visible to its own integration tests.
38+
39+
### Tests
40+
| Test ID | Status | Notes |
41+
|---|---|---|
42+
| `tests::inc` | Failing (New) | Fails to compile due to unresolved imports. |
43+
44+
### Crate Conformance Check Procedure
45+
1. **Compile Check:** Run `timeout 90 cargo test -p test_tools --all-features --no-run`. Analyze output to ensure there are no compilation errors.
46+
2. **Test Execution:** If compilation succeeds, run `timeout 90 cargo test -p test_tools --all-features`. Analyze output to ensure all tests pass.
47+
48+
### Increments
49+
50+
##### Increment 1: Remove restrictive `cfg` gates and verify compilation
51+
* **Goal:** Surgically remove all instances of the `#[cfg(not(feature = "doctest"))]` attribute in `src/lib.rs` to make the public API unconditionally visible to the test suite, and then verify that all compilation errors are resolved.
52+
* **Specification Reference:** N/A
53+
* **Steps:**
54+
* Step 1: Read the file `module/core/test_tools/src/lib.rs` to ensure we have the latest content before modification.
55+
```rust
56+
// Relevant snippets from module/core/test_tools/src/lib.rs that will be affected:
57+
// ...
58+
/// Namespace with dependencies.
59+
#[ allow( unused_imports ) ]
60+
#[ cfg( feature = "enabled" ) ]
61+
#[cfg(not(feature = "doctest"))] // <- This line will be removed
62+
pub mod dependency {
63+
// ...
64+
#[ cfg( feature = "enabled" ) ]
65+
#[cfg(not(feature = "doctest"))] // <- This line will be removed
66+
pub mod test;
67+
// ...
68+
#[ cfg( feature = "enabled" ) ]
69+
#[cfg(not(feature = "doctest"))] // <- This line will be removed
70+
#[cfg(all(feature = "standalone_build", not(feature = "normal_build")))]
71+
mod standalone;
72+
// ... and so on for all public modules and re-exports.
73+
```
74+
* Step 2: Execute a single `search_and_replace` operation to remove all occurrences of the `#[cfg(not(feature = "doctest"))]` line from `module/core/test_tools/src/lib.rs`. The search pattern will include the trailing newline to ensure the file is cleaned up correctly.
75+
* Step 3: Perform Increment Verification. This is the crucial step to confirm the fix works.
76+
* Step 4: If Increment Verification passes, perform the full Crate Conformance Check, which will run the actual tests.
77+
* **Increment Verification:**
78+
* **Action:** Execute the following command: `timeout 90 cargo test -p test_tools --all-features --no-run`.
79+
* **Success Criteria:**
80+
* The command must exit with code `0`.
81+
* The `stderr` output must **not** contain any lines starting with `error[E...`.
82+
* The output should end with a success message like `Finished test [unoptimized + debuginfo] target(s) in ...s`.
83+
* **Failure Action:** If the command fails or produces new compilation errors, initiate Critical Log Analysis.
84+
* **Commit Message:** `fix(test_tools): Remove doctest cfg gates to resolve test compilation errors`
85+
86+
##### Increment 2: Finalization
87+
* **Goal:** Perform a final, comprehensive verification of the changes to ensure the project is in a clean, correct, and passing state before completing the task.
88+
* **Specification Reference:** N/A
89+
* **Steps:**
90+
* Step 1: Execute the full `Crate Conformance Check Procedure` one last time. This ensures that not only does the code compile, but all tests now pass as expected.
91+
* Step 2: Execute `git status` via `execute_command` to confirm that the working directory is clean and all changes have been staged for the commit.
92+
* **Increment Verification:**
93+
* **Action 1 (Conformance):** Execute `timeout 90 cargo test -p test_tools --all-features --no-run` followed by `timeout 90 cargo test -p test_tools --all-features`.
94+
* **Success Criteria 1:** Both commands must exit with code `0` and produce no warnings or errors.
95+
* **Action 2 (Git Status):** Execute `git status`.
96+
* **Success Criteria 2:** The output must contain the message `nothing to commit, working tree clean`.
97+
* **Commit Message:** `chore(test_tools): Finalize compilation fix`
98+
99+
### Task Requirements
100+
* The fix must resolve all 147 compilation errors.
101+
* The fix should not break the intended behavior of the `doctest` feature if possible, but making the tests compile is the primary priority. Removing the `cfg` gates is the most direct way to achieve this.
102+
103+
### Project Requirements
104+
* All code must strictly adhere to the `codestyle` rulebook.
105+
* All changes must be verified by running the test suite.
106+
107+
### Assumptions
108+
* The `doctest` feature was intended for documentation generation and its removal for regular test builds is the correct approach.
109+
* The aggregated tests are a critical part of the crate's quality assurance and must be made to pass.
110+
111+
### Out of Scope
112+
* Refactoring the module visibility system (`own`, `orphan`, etc.).
113+
* Addressing any other `// qqq` or `// xxx` comments not directly related to the compilation failure.
114+
115+
### External System Dependencies
116+
* None.
117+
118+
### Notes & Insights
119+
* The core issue is a conflict between a documentation-oriented feature (`doctest`) and the integration testing strategy. The solution is to prioritize the correctness of the integration tests by ensuring a consistent API surface.
120+
121+
### Analysis
122+
123+
Here is a breakdown of how the errors are connected and why the plan addresses them all:
124+
125+
The Core Problem: The #[cfg(not(feature = "doctest"))] attribute is removing almost the entire public API of test_tools when tests are run.
126+
127+
Category 1: Unresolved Top-Level Imports:
128+
129+
Errors like: unresolved imports test_tools::tests_impls, test_tools::tests_index, test_tools::a_id
130+
131+
Explanation: These macros and functions are directly exposed in test_tools/src/test/mod.rs and re-exported to the top level. Because the test module itself is gated by #[cfg(not(feature = "doctest"))], these items cease to exist during compilation, causing the initial import failures in the aggregated tests.
132+
133+
Category 2: Unresolved mod_interface Modules:
134+
135+
Errors like: could not find exposed in test_tools
136+
137+
Explanation: The own, orphan, exposed, and prelude modules are the fundamental structure created by the mod_interface pattern. All of these modules in src/lib.rs are gated by #[cfg(not(feature = "doctest"))]. When the doctest feature is on, these modules are compiled out, making any path like the_module::exposed::* invalid.
138+
139+
Category 3: Unresolved Re-exported Crates:
140+
141+
Errors like: could not find impls_index in test_tools or could not find error in the_module
142+
143+
Explanation: test_tools re-exports other crates like error_tools and impls_index. These pub use statements are also gated by #[cfg(not(feature = "doctest"))]. When the gate is active, the re-exports are removed, and the symbols are not found.
144+
145+
Category 4: Consequential Failures (Domino Effect):
146+
147+
Errors like: could not find bmap in the_module or cannot find macro f1 in this scope
148+
149+
Explanation: These are secondary failures.
150+
151+
The compiler can't find bmap because it first couldn't find the_module::collection_tools or the_module::exposed where bmap is re-exported.
152+
153+
The compiler can't find the macro f1 because it's defined inside a tests_impls! block. But the compiler never found tests_impls! in the first place (Category 1), so the macro f1 was never defined.
154+
155+
Conclusion:
156+
157+
All 147 errors are a direct consequence of the API being hidden. The elaborated plan to surgically remove all instances of #[cfg(not(feature = "doctest"))] in src/lib.rs is designed to fix this single point of failure. By making the entire API surface of test_tools visible to the test compilation context, it will resolve all categories of errors, from the initial unresolved imports down to the final consequential failures.
158+
159+
The plan is comprehensive and addresses the entirety of the problem space presented in the error log. I am ready to proceed with the first increment.
160+
161+
### Changelog
162+
* [Log will be populated as increments are completed]

0 commit comments

Comments
 (0)