xtrm-tools 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/README.md +127 -111
  2. package/cli/dist/index.cjs +107 -53
  3. package/cli/dist/index.cjs.map +1 -1
  4. package/cli/package.json +1 -1
  5. package/config/pi/extensions/beads.ts +24 -0
  6. package/hooks/beads-gate-core.mjs +6 -4
  7. package/hooks/beads-memory-gate.mjs +12 -5
  8. package/hooks/hooks.json +126 -0
  9. package/package.json +3 -1
  10. package/skills/test-planning/SKILL.md +208 -0
  11. package/skills/test-planning/evals/evals.json +23 -0
  12. package/skills/using-xtrm/SKILL.md +5 -27
  13. package/project-skills/tdd-guard/.claude/hooks/tdd-guard-pretool-bridge.cjs +0 -103
  14. package/project-skills/tdd-guard/.claude/settings.json +0 -38
  15. package/project-skills/tdd-guard/.claude/skills/using-tdd-guard/SKILL.md +0 -79
  16. package/project-skills/tdd-guard/CLAUDE.md +0 -98
  17. package/project-skills/tdd-guard/CONTRIBUTING.md +0 -38
  18. package/project-skills/tdd-guard/DEVELOPMENT.md +0 -127
  19. package/project-skills/tdd-guard/LICENSE +0 -21
  20. package/project-skills/tdd-guard/README.md +0 -398
  21. package/project-skills/tdd-guard/docs/adr/001-claude-session-subdirectory.md +0 -52
  22. package/project-skills/tdd-guard/docs/adr/002-secure-claude-binary-path.md +0 -56
  23. package/project-skills/tdd-guard/docs/adr/003-remove-configurable-data-directory.md +0 -56
  24. package/project-skills/tdd-guard/docs/adr/004-monorepo-architecture.md +0 -64
  25. package/project-skills/tdd-guard/docs/adr/005-claude-project-dir-support.md +0 -55
  26. package/project-skills/tdd-guard/docs/adr/006-phpunit-separate-repository.md +0 -93
  27. package/project-skills/tdd-guard/docs/adr/007-golangci-lint-path-support.md +0 -83
  28. package/project-skills/tdd-guard/docs/adr/008-storybook-reporter-design.md +0 -182
  29. package/project-skills/tdd-guard/docs/assets/tdd-guard-demo-screenshot.gif +0 -0
  30. package/project-skills/tdd-guard/docs/config-migration.md +0 -143
  31. package/project-skills/tdd-guard/docs/configuration.md +0 -137
  32. package/project-skills/tdd-guard/docs/custom-instructions.md +0 -43
  33. package/project-skills/tdd-guard/docs/enforcement.md +0 -46
  34. package/project-skills/tdd-guard/docs/ignore-patterns.md +0 -81
  35. package/project-skills/tdd-guard/docs/linting.md +0 -109
  36. package/project-skills/tdd-guard/docs/quick-commands.md +0 -52
  37. package/project-skills/tdd-guard/docs/session-management.md +0 -75
  38. package/project-skills/tdd-guard/docs/storybook-vitest-addon.md +0 -120
  39. package/project-skills/tdd-guard/docs/validation-model.md +0 -63
  40. package/project-skills/tdd-guard/eslint.config.mjs +0 -140
  41. package/project-skills/tdd-guard/package-lock.json +0 -16937
  42. package/project-skills/tdd-guard/package.json +0 -102
  43. package/project-skills/tdd-guard/reporters/go/README.md +0 -67
  44. package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main.go +0 -127
  45. package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main_test.go +0 -280
  46. package/project-skills/tdd-guard/reporters/go/go.mod +0 -3
  47. package/project-skills/tdd-guard/reporters/go/go.sum +0 -0
  48. package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter.go +0 -126
  49. package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter_test.go +0 -264
  50. package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader.go +0 -26
  51. package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader_test.go +0 -37
  52. package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader.go +0 -94
  53. package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader_test.go +0 -198
  54. package/project-skills/tdd-guard/reporters/go/internal/parser/parser.go +0 -245
  55. package/project-skills/tdd-guard/reporters/go/internal/parser/parser_test.go +0 -547
  56. package/project-skills/tdd-guard/reporters/go/internal/storage/storage.go +0 -35
  57. package/project-skills/tdd-guard/reporters/go/internal/storage/storage_test.go +0 -113
  58. package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer.go +0 -103
  59. package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer_test.go +0 -303
  60. package/project-skills/tdd-guard/reporters/jest/README.md +0 -102
  61. package/project-skills/tdd-guard/reporters/jest/package.json +0 -38
  62. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test-data.ts +0 -199
  63. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.test.ts +0 -302
  64. package/project-skills/tdd-guard/reporters/jest/src/JestReporter.ts +0 -201
  65. package/project-skills/tdd-guard/reporters/jest/src/index.ts +0 -4
  66. package/project-skills/tdd-guard/reporters/jest/src/types.ts +0 -42
  67. package/project-skills/tdd-guard/reporters/jest/tsconfig.json +0 -11
  68. package/project-skills/tdd-guard/reporters/phpunit/.php-cs-fixer.php +0 -28
  69. package/project-skills/tdd-guard/reporters/phpunit/README.md +0 -97
  70. package/project-skills/tdd-guard/reporters/phpunit/SYNC_README.md +0 -29
  71. package/project-skills/tdd-guard/reporters/phpunit/composer.json +0 -55
  72. package/project-skills/tdd-guard/reporters/phpunit/phpunit.xml.dist +0 -19
  73. package/project-skills/tdd-guard/reporters/phpunit/psalm.xml +0 -44
  74. package/project-skills/tdd-guard/reporters/phpunit/src/Event/ErroredTestSubscriber.php +0 -28
  75. package/project-skills/tdd-guard/reporters/phpunit/src/Event/FailedTestSubscriber.php +0 -28
  76. package/project-skills/tdd-guard/reporters/phpunit/src/Event/IncompleteTestSubscriber.php +0 -28
  77. package/project-skills/tdd-guard/reporters/phpunit/src/Event/PassedTestSubscriber.php +0 -27
  78. package/project-skills/tdd-guard/reporters/phpunit/src/Event/SkippedTestSubscriber.php +0 -28
  79. package/project-skills/tdd-guard/reporters/phpunit/src/Event/TestRunnerFinishedSubscriber.php +0 -24
  80. package/project-skills/tdd-guard/reporters/phpunit/src/PathValidator.php +0 -88
  81. package/project-skills/tdd-guard/reporters/phpunit/src/Storage.php +0 -26
  82. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardExtension.php +0 -33
  83. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardListener.php +0 -158
  84. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardSubscriber.php +0 -35
  85. package/project-skills/tdd-guard/reporters/phpunit/src/TestResultCollector.php +0 -105
  86. package/project-skills/tdd-guard/reporters/phpunit/tests/PathValidatorTest.php +0 -74
  87. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionFailedTest.php +0 -241
  88. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionTest.php +0 -84
  89. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardStorageLocationTest.php +0 -71
  90. package/project-skills/tdd-guard/reporters/pytest/README.md +0 -77
  91. package/project-skills/tdd-guard/reporters/pytest/pyproject.toml +0 -43
  92. package/project-skills/tdd-guard/reporters/pytest/pytest.ini.example +0 -7
  93. package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/__init__.py +0 -1
  94. package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/pytest_reporter.py +0 -134
  95. package/project-skills/tdd-guard/reporters/pytest/tests/__init__.py +0 -1
  96. package/project-skills/tdd-guard/reporters/pytest/tests/conftest.py +0 -3
  97. package/project-skills/tdd-guard/reporters/pytest/tests/helpers.py +0 -293
  98. package/project-skills/tdd-guard/reporters/pytest/tests/test_config_option.py +0 -38
  99. package/project-skills/tdd-guard/reporters/pytest/tests/test_path_validation.py +0 -59
  100. package/project-skills/tdd-guard/reporters/pytest/tests/test_plugin_config.py +0 -32
  101. package/project-skills/tdd-guard/reporters/pytest/tests/test_project_root.py +0 -296
  102. package/project-skills/tdd-guard/reporters/pytest/tests/test_pytest_reporter.py +0 -137
  103. package/project-skills/tdd-guard/reporters/rspec/Gemfile +0 -3
  104. package/project-skills/tdd-guard/reporters/rust/Cargo.lock +0 -458
  105. package/project-skills/tdd-guard/reporters/rust/Cargo.toml +0 -33
  106. package/project-skills/tdd-guard/reporters/rust/Makefile.example +0 -95
  107. package/project-skills/tdd-guard/reporters/rust/README.md +0 -88
  108. package/project-skills/tdd-guard/reporters/rust/src/error_parser.rs +0 -309
  109. package/project-skills/tdd-guard/reporters/rust/src/main.rs +0 -464
  110. package/project-skills/tdd-guard/reporters/rust/src/parser.rs +0 -225
  111. package/project-skills/tdd-guard/reporters/rust/src/transformer.rs +0 -409
  112. package/project-skills/tdd-guard/reporters/storybook/README.md +0 -108
  113. package/project-skills/tdd-guard/reporters/storybook/package-lock.json +0 -9482
  114. package/project-skills/tdd-guard/reporters/storybook/package.json +0 -43
  115. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test-data.ts +0 -22
  116. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test.ts +0 -190
  117. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.ts +0 -88
  118. package/project-skills/tdd-guard/reporters/storybook/src/index.ts +0 -12
  119. package/project-skills/tdd-guard/reporters/storybook/src/types.ts +0 -37
  120. package/project-skills/tdd-guard/reporters/storybook/tsconfig.json +0 -11
  121. package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/go.mod +0 -3
  122. package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/single_failing_test.go +0 -13
  123. package/project-skills/tdd-guard/reporters/test/artifacts/go/import/go.mod +0 -3
  124. package/project-skills/tdd-guard/reporters/test/artifacts/go/import/single_import_error_test.go +0 -17
  125. package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/go.mod +0 -3
  126. package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/single_passing_test.go +0 -13
  127. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-failing.test.js +0 -5
  128. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-import-error.test.js +0 -8
  129. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-passing.test.js +0 -5
  130. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleFailingTest.php +0 -11
  131. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleImportErrorTest.php +0 -14
  132. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SinglePassingTest.php +0 -11
  133. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_failing.py +0 -3
  134. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_import_error.py +0 -6
  135. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_passing.py +0 -3
  136. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.lock +0 -7
  137. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.toml +0 -4
  138. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/src/lib.rs +0 -14
  139. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.lock +0 -7
  140. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.toml +0 -4
  141. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/src/lib.rs +0 -13
  142. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.lock +0 -7
  143. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.toml +0 -4
  144. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/src/lib.rs +0 -14
  145. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/Calculator.js +0 -4
  146. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-failing.stories.js +0 -15
  147. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-import-error.stories.js +0 -14
  148. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-passing.stories.js +0 -15
  149. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-failing.test.js +0 -7
  150. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-import-error.test.js +0 -9
  151. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-passing.test.js +0 -7
  152. package/project-skills/tdd-guard/reporters/test/factories/go.ts +0 -59
  153. package/project-skills/tdd-guard/reporters/test/factories/helpers.ts +0 -48
  154. package/project-skills/tdd-guard/reporters/test/factories/index.ts +0 -7
  155. package/project-skills/tdd-guard/reporters/test/factories/jest.ts +0 -51
  156. package/project-skills/tdd-guard/reporters/test/factories/phpunit.ts +0 -63
  157. package/project-skills/tdd-guard/reporters/test/factories/pytest.ts +0 -41
  158. package/project-skills/tdd-guard/reporters/test/factories/rust.ts +0 -158
  159. package/project-skills/tdd-guard/reporters/test/factories/storybook.ts +0 -198
  160. package/project-skills/tdd-guard/reporters/test/factories/vitest.ts +0 -51
  161. package/project-skills/tdd-guard/reporters/test/reporters.integration.test.ts +0 -735
  162. package/project-skills/tdd-guard/reporters/test/types.ts +0 -28
  163. package/project-skills/tdd-guard/reporters/vitest/README.md +0 -64
  164. package/project-skills/tdd-guard/reporters/vitest/package.json +0 -35
  165. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test-data.ts +0 -85
  166. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.test.ts +0 -446
  167. package/project-skills/tdd-guard/reporters/vitest/src/VitestReporter.ts +0 -110
  168. package/project-skills/tdd-guard/reporters/vitest/src/index.ts +0 -4
  169. package/project-skills/tdd-guard/reporters/vitest/src/types.ts +0 -39
  170. package/project-skills/tdd-guard/reporters/vitest/tsconfig.json +0 -11
  171. package/project-skills/tdd-guard/src/cli/buildContext.test.ts +0 -200
  172. package/project-skills/tdd-guard/src/cli/buildContext.ts +0 -48
  173. package/project-skills/tdd-guard/src/cli/tdd-guard.test.ts +0 -159
  174. package/project-skills/tdd-guard/src/cli/tdd-guard.ts +0 -48
  175. package/project-skills/tdd-guard/src/config/Config.test.ts +0 -538
  176. package/project-skills/tdd-guard/src/config/Config.ts +0 -172
  177. package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.test.ts +0 -58
  178. package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.ts +0 -8
  179. package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.test.ts +0 -347
  180. package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.ts +0 -61
  181. package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.test.ts +0 -24
  182. package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.ts +0 -7
  183. package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.test.ts +0 -377
  184. package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.ts +0 -75
  185. package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.test.ts +0 -563
  186. package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.ts +0 -140
  187. package/project-skills/tdd-guard/src/contracts/types/ClientType.ts +0 -1
  188. package/project-skills/tdd-guard/src/contracts/types/ConfigOptions.ts +0 -12
  189. package/project-skills/tdd-guard/src/contracts/types/Context.ts +0 -16
  190. package/project-skills/tdd-guard/src/contracts/types/ModelClient.ts +0 -3
  191. package/project-skills/tdd-guard/src/contracts/types/ValidationResult.ts +0 -6
  192. package/project-skills/tdd-guard/src/guard/GuardManager.test.ts +0 -336
  193. package/project-skills/tdd-guard/src/guard/GuardManager.ts +0 -83
  194. package/project-skills/tdd-guard/src/hooks/HookEvents.test.ts +0 -107
  195. package/project-skills/tdd-guard/src/hooks/HookEvents.ts +0 -39
  196. package/project-skills/tdd-guard/src/hooks/fileTypeDetection.ts +0 -16
  197. package/project-skills/tdd-guard/src/hooks/postToolLint.test.ts +0 -327
  198. package/project-skills/tdd-guard/src/hooks/postToolLint.ts +0 -165
  199. package/project-skills/tdd-guard/src/hooks/processHookData.test.ts +0 -465
  200. package/project-skills/tdd-guard/src/hooks/processHookData.ts +0 -203
  201. package/project-skills/tdd-guard/src/hooks/sessionHandler.test.ts +0 -136
  202. package/project-skills/tdd-guard/src/hooks/sessionHandler.ts +0 -31
  203. package/project-skills/tdd-guard/src/hooks/userPromptHandler.test.ts +0 -131
  204. package/project-skills/tdd-guard/src/hooks/userPromptHandler.ts +0 -55
  205. package/project-skills/tdd-guard/src/index.ts +0 -19
  206. package/project-skills/tdd-guard/src/linters/Linter.ts +0 -5
  207. package/project-skills/tdd-guard/src/linters/eslint/ESLint.test.ts +0 -183
  208. package/project-skills/tdd-guard/src/linters/eslint/ESLint.ts +0 -82
  209. package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.test.ts +0 -170
  210. package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.ts +0 -148
  211. package/project-skills/tdd-guard/src/processors/index.ts +0 -1
  212. package/project-skills/tdd-guard/src/processors/lintProcessor.ts +0 -77
  213. package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.test.ts +0 -303
  214. package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.ts +0 -255
  215. package/project-skills/tdd-guard/src/providers/LinterProvider.test.ts +0 -43
  216. package/project-skills/tdd-guard/src/providers/LinterProvider.ts +0 -20
  217. package/project-skills/tdd-guard/src/providers/ModelClientProvider.test.ts +0 -68
  218. package/project-skills/tdd-guard/src/providers/ModelClientProvider.ts +0 -22
  219. package/project-skills/tdd-guard/src/storage/FileStorage.test.ts +0 -76
  220. package/project-skills/tdd-guard/src/storage/FileStorage.ts +0 -108
  221. package/project-skills/tdd-guard/src/storage/MemoryStorage.ts +0 -57
  222. package/project-skills/tdd-guard/src/storage/Storage.test.ts +0 -227
  223. package/project-skills/tdd-guard/src/storage/Storage.ts +0 -17
  224. package/project-skills/tdd-guard/src/validation/context/context.test.ts +0 -364
  225. package/project-skills/tdd-guard/src/validation/context/context.ts +0 -155
  226. package/project-skills/tdd-guard/src/validation/models/AnthropicApi.test.ts +0 -171
  227. package/project-skills/tdd-guard/src/validation/models/AnthropicApi.ts +0 -49
  228. package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.test.ts +0 -167
  229. package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.ts +0 -54
  230. package/project-skills/tdd-guard/src/validation/models/ClaudeCli.test.ts +0 -239
  231. package/project-skills/tdd-guard/src/validation/models/ClaudeCli.ts +0 -57
  232. package/project-skills/tdd-guard/src/validation/prompts/file-types.ts +0 -52
  233. package/project-skills/tdd-guard/src/validation/prompts/operations/edit.ts +0 -58
  234. package/project-skills/tdd-guard/src/validation/prompts/operations/multi-edit.ts +0 -54
  235. package/project-skills/tdd-guard/src/validation/prompts/operations/write.ts +0 -54
  236. package/project-skills/tdd-guard/src/validation/prompts/response.ts +0 -40
  237. package/project-skills/tdd-guard/src/validation/prompts/rules.ts +0 -51
  238. package/project-skills/tdd-guard/src/validation/prompts/system-prompt.ts +0 -10
  239. package/project-skills/tdd-guard/src/validation/prompts/tools/lint-results.ts +0 -15
  240. package/project-skills/tdd-guard/src/validation/prompts/tools/test-output.ts +0 -14
  241. package/project-skills/tdd-guard/src/validation/prompts/tools/todos.ts +0 -9
  242. package/project-skills/tdd-guard/src/validation/validator.test.ts +0 -268
  243. package/project-skills/tdd-guard/src/validation/validator.ts +0 -159
  244. package/project-skills/tdd-guard/test/artifacts/go/.golangci.yml +0 -6
  245. package/project-skills/tdd-guard/test/artifacts/go/with-issues/file-with-issues.go +0 -12
  246. package/project-skills/tdd-guard/test/artifacts/go/with-issues/go.mod +0 -3
  247. package/project-skills/tdd-guard/test/artifacts/go/without-issues/file-without-issues.go +0 -7
  248. package/project-skills/tdd-guard/test/artifacts/go/without-issues/go.mod +0 -3
  249. package/project-skills/tdd-guard/test/artifacts/javascript/eslint.config.js +0 -20
  250. package/project-skills/tdd-guard/test/artifacts/javascript/file-with-issues.js +0 -12
  251. package/project-skills/tdd-guard/test/artifacts/javascript/file-without-issues.js +0 -10
  252. package/project-skills/tdd-guard/test/hooks/fileTypeDetection.test.ts +0 -26
  253. package/project-skills/tdd-guard/test/hooks/processHookData.fileType.test.ts +0 -46
  254. package/project-skills/tdd-guard/test/hooks/processHookData.python.test.ts +0 -68
  255. package/project-skills/tdd-guard/test/integration/test-context.test.ts +0 -66
  256. package/project-skills/tdd-guard/test/integration/validator.core.test.ts +0 -96
  257. package/project-skills/tdd-guard/test/integration/validator.scenarios.test.ts +0 -497
  258. package/project-skills/tdd-guard/test/utils/assertions.ts +0 -29
  259. package/project-skills/tdd-guard/test/utils/factories/contextFactory.ts +0 -30
  260. package/project-skills/tdd-guard/test/utils/factories/editFactory.ts +0 -82
  261. package/project-skills/tdd-guard/test/utils/factories/helpers.test.ts +0 -46
  262. package/project-skills/tdd-guard/test/utils/factories/helpers.ts +0 -46
  263. package/project-skills/tdd-guard/test/utils/factories/lintFactory.ts +0 -352
  264. package/project-skills/tdd-guard/test/utils/factories/modelClientProviderFactory.ts +0 -21
  265. package/project-skills/tdd-guard/test/utils/factories/multiEditFactory.ts +0 -79
  266. package/project-skills/tdd-guard/test/utils/factories/operations.ts +0 -57
  267. package/project-skills/tdd-guard/test/utils/factories/reporterFactory.ts +0 -55
  268. package/project-skills/tdd-guard/test/utils/factories/scenarios/index.ts +0 -22
  269. package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/python.ts +0 -745
  270. package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/typescript.ts +0 -767
  271. package/project-skills/tdd-guard/test/utils/factories/scenarios/types.ts +0 -77
  272. package/project-skills/tdd-guard/test/utils/factories/scenarios/utils.ts +0 -15
  273. package/project-skills/tdd-guard/test/utils/factories/sessionStartFactory.ts +0 -36
  274. package/project-skills/tdd-guard/test/utils/factories/testDefaults.ts +0 -90
  275. package/project-skills/tdd-guard/test/utils/factories/testResultsFactory.ts +0 -234
  276. package/project-skills/tdd-guard/test/utils/factories/todoFactory.ts +0 -99
  277. package/project-skills/tdd-guard/test/utils/factories/userPromptSubmitFactory.ts +0 -39
  278. package/project-skills/tdd-guard/test/utils/factories/writeFactory.ts +0 -70
  279. package/project-skills/tdd-guard/test/utils/index.ts +0 -131
  280. package/project-skills/tdd-guard/tsconfig.build.json +0 -16
  281. package/project-skills/tdd-guard/tsconfig.eslint.json +0 -17
  282. package/project-skills/tdd-guard/tsconfig.json +0 -32
  283. package/project-skills/tdd-guard/tsconfig.node.json +0 -10
  284. package/project-skills/tdd-guard/vitest.config.ts +0 -85
@@ -1,547 +0,0 @@
1
- package parser
2
-
3
- import (
4
- "bufio"
5
- "encoding/json"
6
- "strings"
7
- "testing"
8
- )
9
-
10
- // Test fixtures - common JSON events
11
- const (
12
- passEvent = `{"Action":"pass","Package":"example.com/pkg","Test":"TestAdd"}`
13
- failEvent = `{"Action":"fail","Package":"example.com/pkg","Test":"TestFail"}`
14
- runEvent = `{"Action":"run","Package":"example.com/pkg","Test":"TestAdd"}`
15
- )
16
-
17
- func TestParser(t *testing.T) {
18
- t.Run("Creation", func(t *testing.T) {
19
- t.Run("creates new parser", func(t *testing.T) {
20
- parser := NewParser()
21
- if parser == nil {
22
- t.Fatal("Expected parser to be created")
23
- }
24
- })
25
-
26
- t.Run("returns empty results initially", func(t *testing.T) {
27
- parser := NewParser()
28
- results := parser.GetResults()
29
- if results == nil {
30
- t.Fatal("Expected results to be non-nil")
31
- }
32
- if len(results) != 0 {
33
- t.Fatalf("Expected empty results, got %d items", len(results))
34
- }
35
- })
36
- })
37
-
38
- t.Run("Parsing", func(t *testing.T) {
39
- t.Run("accepts io.Reader", func(t *testing.T) {
40
- parser := NewParser()
41
- err := parser.Parse(strings.NewReader(""))
42
- if err != nil {
43
- t.Fatalf("Parse returned error: %v", err)
44
- }
45
- })
46
-
47
- t.Run("handles invalid JSON", func(t *testing.T) {
48
- results := parseJSON(t, "not json")
49
- if len(results) != 0 {
50
- t.Fatal("Expected no results for invalid JSON")
51
- }
52
- })
53
- })
54
-
55
- t.Run("Recording tests", func(t *testing.T) {
56
- t.Run("records passing test", func(t *testing.T) {
57
- results := parseJSON(t, passEvent)
58
-
59
- if len(results) != 1 {
60
- t.Fatalf("Expected 1 package, got %d", len(results))
61
- }
62
-
63
- tests := getPackageTests(t, results, "example.com/pkg")
64
- if _, exists := tests["TestAdd"]; !exists {
65
- t.Fatal("Expected test 'TestAdd' to be recorded")
66
- }
67
- })
68
-
69
- t.Run("records failing test", func(t *testing.T) {
70
- results := parseJSON(t, failEvent)
71
- tests := getPackageTests(t, results, "example.com/pkg")
72
-
73
- if _, exists := tests["TestFail"]; !exists {
74
- t.Fatal("Expected test 'TestFail' to be recorded")
75
- }
76
- })
77
-
78
- t.Run("ignores non-terminal actions", func(t *testing.T) {
79
- results := parseJSON(t, runEvent)
80
-
81
- // Package should exist but with no tests
82
- if tests, exists := results["example.com/pkg"]; exists {
83
- if _, hasTest := tests["TestAdd"]; hasTest {
84
- t.Fatal("Should not record test with 'run' action")
85
- }
86
- }
87
- })
88
- })
89
-
90
- t.Run("Test states", func(t *testing.T) {
91
- testCases := []struct {
92
- name string
93
- input string
94
- testName string
95
- expected TestState
96
- }{
97
- {"passing test", passEvent, "TestAdd", StatePassed},
98
- {"failing test", failEvent, "TestFail", StateFailed},
99
- }
100
-
101
- for _, tc := range testCases {
102
- t.Run(tc.name, func(t *testing.T) {
103
- results := parseJSON(t, tc.input)
104
- tests := getPackageTests(t, results, "example.com/pkg")
105
-
106
- state, exists := tests[tc.testName]
107
- if !exists {
108
- t.Fatalf("Test %s not found", tc.testName)
109
- }
110
- if state != tc.expected {
111
- t.Errorf("Expected state %s, got %v", tc.expected, state)
112
- }
113
- })
114
- }
115
- })
116
-
117
- t.Run("Multiple tests", func(t *testing.T) {
118
- input := strings.Join([]string{
119
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestOne"}`,
120
- `{"Action":"fail","Package":"example.com/pkg","Test":"TestTwo"}`,
121
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestThree"}`,
122
- }, "\n")
123
-
124
- results := parseJSON(t, input)
125
- tests := getPackageTests(t, results, "example.com/pkg")
126
-
127
- if len(tests) != 3 {
128
- t.Fatalf("Expected 3 tests, got %d", len(tests))
129
- }
130
-
131
- // Verify individual test states
132
- expectedStates := map[string]TestState{
133
- "TestOne": StatePassed,
134
- "TestTwo": StateFailed,
135
- "TestThree": StatePassed,
136
- }
137
-
138
- for name, expectedState := range expectedStates {
139
- if state, exists := tests[name]; !exists {
140
- t.Errorf("Test %s not found", name)
141
- } else if state != expectedState {
142
- t.Errorf("Test %s: expected state %s, got %v", name, expectedState, state)
143
- }
144
- }
145
- })
146
-
147
- t.Run("Multiple packages", func(t *testing.T) {
148
- input := strings.Join([]string{
149
- `{"Action":"pass","Package":"example.com/pkg1","Test":"TestA"}`,
150
- `{"Action":"pass","Package":"example.com/pkg2","Test":"TestB"}`,
151
- }, "\n")
152
-
153
- results := parseJSON(t, input)
154
-
155
- if len(results) != 2 {
156
- t.Fatalf("Expected 2 packages, got %d", len(results))
157
- }
158
-
159
- // Verify both packages exist
160
- for _, pkg := range []string{"example.com/pkg1", "example.com/pkg2"} {
161
- if _, exists := results[pkg]; !exists {
162
- t.Errorf("Package %s not found", pkg)
163
- }
164
- }
165
- })
166
-
167
- t.Run("Subtest filtering", func(t *testing.T) {
168
- t.Run("filters out parent test when one subtest exists", func(t *testing.T) {
169
- // Simplest case: parent with one child
170
- input := strings.Join([]string{
171
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent"}`,
172
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent/Child"}`,
173
- }, "\n")
174
-
175
- results := parseJSON(t, input)
176
- tests := getPackageTests(t, results, "example.com/pkg")
177
-
178
- // Should only have the child test, not the parent
179
- if _, exists := tests["TestParent"]; exists {
180
- t.Error("Expected TestParent to be filtered out when child exists")
181
- }
182
- })
183
-
184
- t.Run("keeps test without children", func(t *testing.T) {
185
- input := strings.Join([]string{
186
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestSimple"}`,
187
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent"}`,
188
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent/Child"}`,
189
- }, "\n")
190
-
191
- results := parseJSON(t, input)
192
- tests := getPackageTests(t, results, "example.com/pkg")
193
-
194
- // TestSimple has no children, should be kept
195
- if _, exists := tests["TestSimple"]; !exists {
196
- t.Error("Expected TestSimple to exist (has no children)")
197
- }
198
- })
199
-
200
- t.Run("filters parent with multiple children", func(t *testing.T) {
201
- input := strings.Join([]string{
202
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent"}`,
203
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent/Child1"}`,
204
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestParent/Child2"}`,
205
- }, "\n")
206
-
207
- results := parseJSON(t, input)
208
- tests := getPackageTests(t, results, "example.com/pkg")
209
-
210
- // Parent should be filtered out
211
- if _, exists := tests["TestParent"]; exists {
212
- t.Error("Expected TestParent to be filtered out when multiple children exist")
213
- }
214
- })
215
-
216
- t.Run("filters intermediate level in nested tests", func(t *testing.T) {
217
- input := strings.Join([]string{
218
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestAPI"}`,
219
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestAPI/Users"}`,
220
- `{"Action":"pass","Package":"example.com/pkg","Test":"TestAPI/Users/Create"}`,
221
- }, "\n")
222
-
223
- results := parseJSON(t, input)
224
- tests := getPackageTests(t, results, "example.com/pkg")
225
-
226
- // TestAPI/Users should be filtered out (has child)
227
- if _, exists := tests["TestAPI/Users"]; exists {
228
- t.Error("Expected TestAPI/Users to be filtered out when it has children")
229
- }
230
- })
231
- })
232
-
233
- t.Run("Test output capture", func(t *testing.T) {
234
- t.Run("captures output for specific test", func(t *testing.T) {
235
- input := strings.Join([]string{
236
- `{"Action":"run","Package":"example.com/pkg","Test":"ExampleTest"}`,
237
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"=== RUN ExampleTest\n"}`,
238
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":" main_test.go:10: Expected 6 but got 5\n"}`,
239
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"--- FAIL: ExampleTest (0.00s)\n"}`,
240
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest","Elapsed":0}`,
241
- }, "\n")
242
-
243
- output := parseAndGetOutput(t, input)
244
- if output == "" {
245
- t.Fatal("Expected test output to be captured")
246
- }
247
- })
248
-
249
- t.Run("returns empty string for non-existent test", func(t *testing.T) {
250
- parser := NewParser()
251
-
252
- testOutput := parser.GetTestOutput("example.com/pkg", "NonExistentTest")
253
- if testOutput != "" {
254
- t.Fatalf("Expected empty string for non-existent test, got %q", testOutput)
255
- }
256
- })
257
-
258
- t.Run("returns empty string when test exists but has no output", func(t *testing.T) {
259
- input := `{"Action":"pass","Package":"example.com/pkg","Test":"ExampleTest"}`
260
-
261
- output := parseAndGetOutput(t, input)
262
- if output != "" {
263
- t.Fatalf("Expected empty string for test without output, got %q", output)
264
- }
265
- })
266
-
267
- t.Run("returns actual output content", func(t *testing.T) {
268
- input := strings.Join([]string{
269
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"Expected 6 but got 5\n"}`,
270
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
271
- }, "\n")
272
-
273
- output := parseAndGetOutput(t, input)
274
- expected := "Expected 6 but got 5"
275
- if output != expected {
276
- t.Fatalf("Expected %q, got %q", expected, output)
277
- }
278
- })
279
-
280
- t.Run("concatenates multiple output lines", func(t *testing.T) {
281
- input := strings.Join([]string{
282
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"Line 1\n"}`,
283
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"Line 2\n"}`,
284
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
285
- }, "\n")
286
-
287
- output := parseAndGetOutput(t, input)
288
- expected := "Line 1\nLine 2"
289
- if output != expected {
290
- t.Fatalf("Expected %q, got %q", expected, output)
291
- }
292
- })
293
-
294
- t.Run("excludes RUN lines from output", func(t *testing.T) {
295
- input := strings.Join([]string{
296
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"=== RUN ExampleTest\n"}`,
297
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"Error message\n"}`,
298
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
299
- }, "\n")
300
-
301
- output := parseAndGetOutput(t, input)
302
- if strings.Contains(output, "=== RUN") {
303
- t.Fatalf("Output should not contain RUN line, got %q", output)
304
- }
305
- })
306
-
307
- t.Run("excludes FAIL lines from output", func(t *testing.T) {
308
- input := strings.Join([]string{
309
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"Error message\n"}`,
310
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"--- FAIL: ExampleTest (0.00s)\n"}`,
311
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
312
- }, "\n")
313
-
314
- output := parseAndGetOutput(t, input)
315
- if strings.Contains(output, "--- FAIL") {
316
- t.Fatalf("Output should not contain FAIL line, got %q", output)
317
- }
318
- })
319
-
320
- t.Run("trims leading whitespace from error lines", func(t *testing.T) {
321
- input := strings.Join([]string{
322
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":" test.go:10: Expected 6 but got 5\n"}`,
323
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
324
- }, "\n")
325
-
326
- output := parseAndGetOutput(t, input)
327
- expected := "test.go:10: Expected 6 but got 5"
328
- if output != expected {
329
- t.Fatalf("Expected %q, got %q", expected, output)
330
- }
331
- })
332
-
333
- t.Run("trims trailing newline from output", func(t *testing.T) {
334
- input := strings.Join([]string{
335
- `{"Action":"output","Package":"example.com/pkg","Test":"ExampleTest","Output":"test.go:10: Error message\n"}`,
336
- `{"Action":"fail","Package":"example.com/pkg","Test":"ExampleTest"}`,
337
- }, "\n")
338
-
339
- output := parseAndGetOutput(t, input)
340
- expected := "test.go:10: Error message"
341
- if output != expected {
342
- t.Fatalf("Expected %q, got %q", expected, output)
343
- }
344
- })
345
- })
346
-
347
- t.Run("Build events", func(t *testing.T) {
348
- t.Run("TestEvent includes ImportPath field", func(t *testing.T) {
349
- input := `{"Action":"build-output","ImportPath":"example.com/pkg","Output":"# example.com/pkg\n"}`
350
-
351
- reader := strings.NewReader(input)
352
- scanner := bufio.NewScanner(reader)
353
-
354
- if scanner.Scan() {
355
- var event TestEvent
356
- err := json.Unmarshal(scanner.Bytes(), &event)
357
- if err != nil {
358
- t.Fatalf("Failed to unmarshal: %v", err)
359
- }
360
-
361
- if event.ImportPath != "example.com/pkg" {
362
- t.Errorf("Expected ImportPath to be 'example.com/pkg', got '%s'", event.ImportPath)
363
- }
364
- }
365
- })
366
-
367
- t.Run("TestEvent includes FailedBuild field", func(t *testing.T) {
368
- input := `{"Action":"fail","Package":"example.com/pkg","FailedBuild":"example.com/pkg"}`
369
-
370
- reader := strings.NewReader(input)
371
- scanner := bufio.NewScanner(reader)
372
-
373
- if scanner.Scan() {
374
- var event TestEvent
375
- err := json.Unmarshal(scanner.Bytes(), &event)
376
- if err != nil {
377
- t.Fatalf("Failed to unmarshal: %v", err)
378
- }
379
-
380
- if event.FailedBuild != "example.com/pkg" {
381
- t.Errorf("Expected FailedBuild to be 'example.com/pkg', got '%s'", event.FailedBuild)
382
- }
383
- }
384
- })
385
-
386
- t.Run("captures build-output events", func(t *testing.T) {
387
- parser := NewParser()
388
-
389
- input := `{"Action":"build-output","ImportPath":"example.com/pkg","Output":"compilation error\n"}`
390
- err := parser.Parse(strings.NewReader(input))
391
- if err != nil {
392
- t.Fatalf("Parse failed: %v", err)
393
- }
394
-
395
- // We need a way to verify the build output was captured
396
- // For now, let's add a GetBuildFailure method
397
- buildOutput := parser.GetBuildFailure("example.com/pkg")
398
- if buildOutput != "compilation error\n" {
399
- t.Errorf("Expected build output 'compilation error\\n', got %q", buildOutput)
400
- }
401
- })
402
-
403
- t.Run("creates CompilationError test for build failure", func(t *testing.T) {
404
- parser := NewParser()
405
-
406
- input := `{"Action":"fail","Package":"example.com/pkg","FailedBuild":"example.com/pkg"}`
407
- err := parser.Parse(strings.NewReader(input))
408
- if err != nil {
409
- t.Fatalf("Parse failed: %v", err)
410
- }
411
-
412
- results := parser.GetResults()
413
- tests := results["example.com/pkg"]
414
-
415
- state, exists := tests["CompilationError"]
416
- if !exists {
417
- t.Fatal("Expected CompilationError test to be created")
418
- }
419
-
420
- if state != StateFailed {
421
- t.Errorf("Expected CompilationError to have state 'failed', got %v", state)
422
- }
423
- })
424
-
425
- t.Run("GetTestOutput returns build failure for CompilationError", func(t *testing.T) {
426
- parser := NewParser()
427
-
428
- // First capture build output
429
- buildOutput := `{"Action":"build-output","ImportPath":"example.com/pkg","Output":"undefined: someFunc\n"}`
430
- err := parser.Parse(strings.NewReader(buildOutput))
431
- if err != nil {
432
- t.Fatalf("Parse failed: %v", err)
433
- }
434
-
435
- // Then process the build failure
436
- failEvent := `{"Action":"fail","Package":"example.com/pkg","FailedBuild":"example.com/pkg"}`
437
- err = parser.Parse(strings.NewReader(failEvent))
438
- if err != nil {
439
- t.Fatalf("Parse failed: %v", err)
440
- }
441
-
442
- // GetTestOutput should return the build failure message for CompilationError
443
- output := parser.GetTestOutput("example.com/pkg", "CompilationError")
444
- if output != "undefined: someFunc" {
445
- t.Errorf("Expected 'undefined: someFunc', got %q", output)
446
- }
447
- })
448
- })
449
-
450
- t.Run("Package-level output", func(t *testing.T) {
451
- t.Run("captures error output messages", func(t *testing.T) {
452
- // When compilation fails, Go emits output events before the fail event
453
- input := strings.Join([]string{
454
- `{"Action":"output","Package":"example.com/pkg","Output":"# example.com/pkg\n"}`,
455
- `{"Action":"output","Package":"example.com/pkg","Output":"./main.go:3:8: package foo is not in std\n"}`,
456
- `{"Action":"fail","Package":"example.com/pkg","Elapsed":0.001}`,
457
- }, "\n")
458
-
459
- parser := NewParser()
460
- err := parser.Parse(strings.NewReader(input))
461
- if err != nil {
462
- t.Fatalf("Parse failed: %v", err)
463
- }
464
-
465
- // Check if we have error output stored
466
- errorOutput := parser.GetErrorOutput("example.com/pkg")
467
- if errorOutput == "" {
468
- t.Fatal("Expected error output to be captured")
469
- }
470
- })
471
-
472
- t.Run("marks package as failed when package-level fail with no tests", func(t *testing.T) {
473
- // This simulates a build failure that produces JSON output
474
- // The package fails but has no test entries
475
- input := `{"Action":"fail","Package":"example.com/pkg","Elapsed":0}`
476
-
477
- parser := NewParser()
478
- err := parser.Parse(strings.NewReader(input))
479
- if err != nil {
480
- t.Fatalf("Parse failed: %v", err)
481
- }
482
-
483
- results := parser.GetResults()
484
- if pkg, exists := results["example.com/pkg"]; exists {
485
- if pkg["CompilationError"] != StateFailed {
486
- t.Fatal("Expected CompilationError to be failed for package-level failure")
487
- }
488
- } else {
489
- t.Fatal("Expected package to exist in results")
490
- }
491
- })
492
-
493
- t.Run("combines multiple output lines", func(t *testing.T) {
494
- input := strings.Join([]string{
495
- `{"Action":"output","Package":"example.com/pkg","Output":"# example.com/pkg\n"}`,
496
- `{"Action":"output","Package":"example.com/pkg","Output":"./main.go:3:8: package foo is not in std\n"}`,
497
- `{"Action":"output","Package":"example.com/pkg","Output":"./main.go:4:8: package bar is not in std\n"}`,
498
- `{"Action":"fail","Package":"example.com/pkg","Elapsed":0.001}`,
499
- }, "\n")
500
-
501
- parser := NewParser()
502
- err := parser.Parse(strings.NewReader(input))
503
- if err != nil {
504
- t.Fatalf("Parse failed: %v", err)
505
- }
506
-
507
- errorOutput := parser.GetErrorOutput("example.com/pkg")
508
- expected := "# example.com/pkg\n./main.go:3:8: package foo is not in std\n./main.go:4:8: package bar is not in std\n"
509
- if errorOutput != expected {
510
- t.Errorf("Expected output:\n%q\nGot:\n%q", expected, errorOutput)
511
- }
512
- })
513
- })
514
- }
515
-
516
- // Helper functions
517
-
518
- func parseJSON(t *testing.T, input string) Results {
519
- t.Helper()
520
- parser := NewParser()
521
- err := parser.Parse(strings.NewReader(input))
522
- if err != nil {
523
- t.Fatalf("Parse failed: %v", err)
524
- }
525
- return parser.GetResults()
526
- }
527
-
528
- func getPackageTests(t *testing.T, results Results, pkg string) PackageResults {
529
- t.Helper()
530
- tests, exists := results[pkg]
531
- if !exists {
532
- t.Fatalf("Package %s not found", pkg)
533
- }
534
- return tests
535
- }
536
-
537
- // parseAndGetOutput is a helper for test output capture tests
538
- // It uses the default package "example.com/pkg" and test name ExampleTest"
539
- func parseAndGetOutput(t *testing.T, input string) string {
540
- t.Helper()
541
- parser := NewParser()
542
- err := parser.Parse(strings.NewReader(input))
543
- if err != nil {
544
- t.Fatalf("Parse failed: %v", err)
545
- }
546
- return parser.GetTestOutput("example.com/pkg", "ExampleTest")
547
- }
@@ -1,35 +0,0 @@
1
- package storage
2
-
3
- import (
4
- "encoding/json"
5
- "os"
6
- "path/filepath"
7
-
8
- "github.com/nizos/tdd-guard/reporters/go/internal/transformer"
9
- )
10
-
11
- var (
12
- // Path components for cross-platform compatibility
13
- TestResultsPath = []string{".claude", "tdd-guard", "data", "test.json"}
14
- )
15
-
16
- type Storage struct {
17
- basePath string
18
- }
19
-
20
- func NewStorage(projectRoot string) *Storage {
21
- return &Storage{basePath: projectRoot}
22
- }
23
-
24
- func (s *Storage) Save(results *transformer.TestResult) error {
25
- parts := append([]string{s.basePath}, TestResultsPath...)
26
- filePath := filepath.Join(parts...)
27
-
28
- // Ensure directory exists
29
- dir := filepath.Dir(filePath)
30
- os.MkdirAll(dir, 0755)
31
-
32
- // Marshal to JSON
33
- data, _ := json.Marshal(results)
34
- return os.WriteFile(filePath, data, 0644)
35
- }
@@ -1,113 +0,0 @@
1
- package storage
2
-
3
- import (
4
- "os"
5
- "path/filepath"
6
- "testing"
7
- )
8
-
9
- func TestStorage(t *testing.T) {
10
- t.Run("NewStorage", func(t *testing.T) {
11
- t.Run("creates storage with empty path", func(t *testing.T) {
12
- storage := NewStorage("")
13
- if storage == nil {
14
- t.Fatal("Expected storage to be created")
15
- }
16
- })
17
-
18
- t.Run("creates storage with project root", func(t *testing.T) {
19
- storage := NewStorage("/some/path")
20
- if storage == nil {
21
- t.Fatal("Expected storage to be created with root")
22
- }
23
- })
24
- })
25
-
26
- t.Run("Save", func(t *testing.T) {
27
- // Setup: Create temp directory and change to it for all tests
28
- oldWd, _ := os.Getwd()
29
- tempDir := t.TempDir()
30
- os.Chdir(tempDir)
31
- t.Cleanup(func() {
32
- os.Chdir(oldWd)
33
- })
34
-
35
- t.Run("returns no error", func(t *testing.T) {
36
- storage := NewStorage("")
37
- err := storage.Save(nil)
38
- if err != nil {
39
- t.Fatalf("Save failed: %v", err)
40
- }
41
- })
42
-
43
- t.Run("without project root", func(t *testing.T) {
44
- storage := NewStorage("")
45
-
46
- t.Run("creates directory in current directory", func(t *testing.T) {
47
- storage.Save(nil)
48
-
49
- // Extract directory path from TestResultsPath
50
- dirParts := TestResultsPath[:len(TestResultsPath)-1]
51
- expectedDir := filepath.Join(append([]string{tempDir}, dirParts...)...)
52
-
53
- if _, err := os.Stat(expectedDir); os.IsNotExist(err) {
54
- t.Fatal("Expected directory to be created")
55
- }
56
- })
57
-
58
- t.Run("creates file in current directory", func(t *testing.T) {
59
- storage.Save(nil)
60
-
61
- // Build expected file path
62
- parts := append([]string{tempDir}, TestResultsPath...)
63
- expectedPath := filepath.Join(parts...)
64
-
65
- if _, err := os.Stat(expectedPath); os.IsNotExist(err) {
66
- t.Fatal("Expected file to be created")
67
- }
68
- })
69
- })
70
-
71
- t.Run("with project root", func(t *testing.T) {
72
- projectDir := filepath.Join(tempDir, "project")
73
- storage := NewStorage(projectDir)
74
-
75
- t.Run("creates directory in project root", func(t *testing.T) {
76
- storage.Save(nil)
77
-
78
- // Extract directory path from TestResultsPath
79
- dirParts := TestResultsPath[:len(TestResultsPath)-1]
80
- expectedDir := filepath.Join(append([]string{projectDir}, dirParts...)...)
81
-
82
- if _, err := os.Stat(expectedDir); os.IsNotExist(err) {
83
- t.Fatal("Expected directory to be created in project root")
84
- }
85
- })
86
-
87
- t.Run("creates file in project root", func(t *testing.T) {
88
- storage.Save(nil)
89
-
90
- // Build expected file path
91
- parts := append([]string{projectDir}, TestResultsPath...)
92
- expectedPath := filepath.Join(parts...)
93
-
94
- if _, err := os.Stat(expectedPath); os.IsNotExist(err) {
95
- t.Fatal("Expected file to be created in project root")
96
- }
97
- })
98
- })
99
-
100
- t.Run("writes data to file", func(t *testing.T) {
101
- storage := NewStorage("")
102
- storage.Save(nil)
103
-
104
- parts := append([]string{tempDir}, TestResultsPath...)
105
- filePath := filepath.Join(parts...)
106
- content, _ := os.ReadFile(filePath)
107
-
108
- if len(content) == 0 {
109
- t.Fatal("Expected file to contain data")
110
- }
111
- })
112
- })
113
- }