@ai-dev-tools/csharp-copilot-core 0.0.19

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 (322) hide show
  1. package/ai-dev-tools-csharp-copilot-core-0.0.19.tgz +0 -0
  2. package/azure-pipelines.yml +52 -0
  3. package/out/analyze/cecil.d.ts +1 -0
  4. package/out/analyze/cecil.js +42 -0
  5. package/out/analyze/cecil.js.map +1 -0
  6. package/out/analyze/checkCodeSyntax.d.ts +7 -0
  7. package/out/analyze/checkCodeSyntax.js +67 -0
  8. package/out/analyze/checkCodeSyntax.js.map +1 -0
  9. package/out/analyze/generateCodeDependency.d.ts +6 -0
  10. package/out/analyze/generateCodeDependency.js +122 -0
  11. package/out/analyze/generateCodeDependency.js.map +1 -0
  12. package/out/analyze/installAnalyzerTool.d.ts +1 -0
  13. package/out/analyze/installAnalyzerTool.js +82 -0
  14. package/out/analyze/installAnalyzerTool.js.map +1 -0
  15. package/out/atmpCache/deps/EplantRequestCategoryCondition_Conditions_Eplant_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +281 -0
  16. package/out/atmpCache/deps/IdentitySelectAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  17. package/out/atmpCache/deps/SqmidHelperTests_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsTests_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
  18. package/out/atmpCache/deps/SqmidHelper_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
  19. package/out/atmpCache/deps/ToListCountAnalyzerTests_ToListinatorTests_test_AIUnitTestExample_code_d.deps +4037 -0
  20. package/out/atmpCache/deps/ToListCountAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  21. package/out/atmpCache/deps/ToListCountCodeFixProvider_ToListinatorCodeFixes_src_AIUnitTestExample_code_d.deps +1 -0
  22. package/out/atmpCache/deps/ToListForEachAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
  23. package/out/atmpCache/dllref/ToListinatorTests_ToListinatorTests_test_AIUnitTestExample_code_d.dllref +202 -0
  24. package/out/batch/generateCodeTests.d.ts +6 -0
  25. package/out/batch/generateCodeTests.js +147 -0
  26. package/out/batch/generateCodeTests.js.map +1 -0
  27. package/out/batch/getFolderCodeFile.d.ts +1 -0
  28. package/out/batch/getFolderCodeFile.js +19 -0
  29. package/out/batch/getFolderCodeFile.js.map +1 -0
  30. package/out/batch/getProjectCodeFile.d.ts +4 -0
  31. package/out/batch/getProjectCodeFile.js +87 -0
  32. package/out/batch/getProjectCodeFile.js.map +1 -0
  33. package/out/batch/getSolutionCodeFile.d.ts +8 -0
  34. package/out/batch/getSolutionCodeFile.js +70 -0
  35. package/out/batch/getSolutionCodeFile.js.map +1 -0
  36. package/out/benchmark/formatToMarkdown.d.ts +2 -0
  37. package/out/benchmark/formatToMarkdown.js +101 -0
  38. package/out/benchmark/formatToMarkdown.js.map +1 -0
  39. package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
  40. package/out/benchmark/generateBenchmarkReport.js +82 -0
  41. package/out/benchmark/generateBenchmarkReport.js.map +1 -0
  42. package/out/codeCoverage/codeCoverage.d.ts +6 -0
  43. package/out/codeCoverage/codeCoverage.js +35 -0
  44. package/out/codeCoverage/codeCoverage.js.map +1 -0
  45. package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
  46. package/out/codeCoverage/codeCoverageReport.js +72 -0
  47. package/out/codeCoverage/codeCoverageReport.js.map +1 -0
  48. package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
  49. package/out/codeCoverage/extractCodeCoverageInfo.js +80 -0
  50. package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
  51. package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
  52. package/out/codeCoverage/generateCodeCoverageReport.js +27 -0
  53. package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
  54. package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
  55. package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
  56. package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
  57. package/out/codeCoverage/reportTool.d.ts +2 -0
  58. package/out/codeCoverage/reportTool.js +22 -0
  59. package/out/codeCoverage/reportTool.js.map +1 -0
  60. package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
  61. package/out/codeCoverage/simplifyCoverageXml.js +116 -0
  62. package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
  63. package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
  64. package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  65. package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
  66. package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
  67. package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
  68. package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
  69. package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
  70. package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
  71. package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  72. package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
  73. package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
  74. package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
  75. package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
  76. package/out/codebk/childProcessManager.d.ts +1 -0
  77. package/out/codebk/childProcessManager.js +50 -0
  78. package/out/codebk/childProcessManager.js.map +1 -0
  79. package/out/codebk/msBuidSpawn.d.ts +1 -0
  80. package/out/codebk/msBuidSpawn.js +58 -0
  81. package/out/codebk/msBuidSpawn.js.map +1 -0
  82. package/out/codebk/msBuild.d.ts +1 -0
  83. package/out/codebk/msBuild.js +123 -0
  84. package/out/codebk/msBuild.js.map +1 -0
  85. package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
  86. package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
  87. package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
  88. package/out/codebk/old/xapGuideline-fm.liquid +149 -0
  89. package/out/codebk/old/xapGuideline.liquid +37 -0
  90. package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
  91. package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
  92. package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
  93. package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
  94. package/out/codebk/oldExec/codeCoverage.js +54 -0
  95. package/out/codebk/oldExec/codeCoverage.js.map +1 -0
  96. package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
  97. package/out/codebk/oldExec/codeCoverageReport.js +64 -0
  98. package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
  99. package/out/codebk/oldExec/containsMethods.d.ts +1 -0
  100. package/out/codebk/oldExec/containsMethods.js +74 -0
  101. package/out/codebk/oldExec/containsMethods.js.map +1 -0
  102. package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
  103. package/out/codebk/oldExec/generateCodeDependency.js +95 -0
  104. package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
  105. package/out/codebk/oldExec/msBuild.d.ts +1 -0
  106. package/out/codebk/oldExec/msBuild.js +53 -0
  107. package/out/codebk/oldExec/msBuild.js.map +1 -0
  108. package/out/codebk/oldExec/vsTest.d.ts +1 -0
  109. package/out/codebk/oldExec/vsTest.js +71 -0
  110. package/out/codebk/oldExec/vsTest.js.map +1 -0
  111. package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
  112. package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
  113. package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
  114. package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
  115. package/out/codebk/testbuildkill.d.ts +1 -0
  116. package/out/codebk/testbuildkill.js +37 -0
  117. package/out/codebk/testbuildkill.js.map +1 -0
  118. package/out/command/index.d.ts +2 -0
  119. package/out/command/index.js +85 -0
  120. package/out/command/index.js.map +1 -0
  121. package/out/command/utGenWrapper.d.ts +3 -0
  122. package/out/command/utGenWrapper.js +40 -0
  123. package/out/command/utGenWrapper.js.map +1 -0
  124. package/out/exit/childProcessManager.d.ts +2 -0
  125. package/out/exit/childProcessManager.js +43 -0
  126. package/out/exit/childProcessManager.js.map +1 -0
  127. package/out/exit/setupProcessSignalHandler.d.ts +1 -0
  128. package/out/exit/setupProcessSignalHandler.js +18 -0
  129. package/out/exit/setupProcessSignalHandler.js.map +1 -0
  130. package/out/gen/autoFix.d.ts +4 -0
  131. package/out/gen/autoFix.js +125 -0
  132. package/out/gen/autoFix.js.map +1 -0
  133. package/out/gen/csharpUtGen.d.ts +2 -0
  134. package/out/gen/csharpUtGen.js +151 -0
  135. package/out/gen/csharpUtGen.js.map +1 -0
  136. package/out/gen/ensureValidLLMResponse.d.ts +1 -0
  137. package/out/gen/ensureValidLLMResponse.js +19 -0
  138. package/out/gen/ensureValidLLMResponse.js.map +1 -0
  139. package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
  140. package/out/gen/postGen/extractCodeFromResponse.js +37 -0
  141. package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
  142. package/out/gen/postGen/postGenProcess.d.ts +1 -0
  143. package/out/gen/postGen/postGenProcess.js +36 -0
  144. package/out/gen/postGen/postGenProcess.js.map +1 -0
  145. package/out/gen/postGen/removeComments.d.ts +1 -0
  146. package/out/gen/postGen/removeComments.js +92 -0
  147. package/out/gen/postGen/removeComments.js.map +1 -0
  148. package/out/gen/postGen/removeSingleLines.d.ts +1 -0
  149. package/out/gen/postGen/removeSingleLines.js +28 -0
  150. package/out/gen/postGen/removeSingleLines.js.map +1 -0
  151. package/out/gen/postGen/repairRequiredNameSpaces.d.ts +1 -0
  152. package/out/gen/postGen/repairRequiredNameSpaces.js +116 -0
  153. package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
  154. package/out/gen/postGen/validateTestCode.d.ts +1 -0
  155. package/out/gen/postGen/validateTestCode.js +14 -0
  156. package/out/gen/postGen/validateTestCode.js.map +1 -0
  157. package/out/gen/preGen/excludeFileName.d.ts +1 -0
  158. package/out/gen/preGen/excludeFileName.js +49 -0
  159. package/out/gen/preGen/excludeFileName.js.map +1 -0
  160. package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
  161. package/out/gen/preGen/excludeSpecificTag.js +18 -0
  162. package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
  163. package/out/gen/preGen/preGenProcess.d.ts +1 -0
  164. package/out/gen/preGen/preGenProcess.js +22 -0
  165. package/out/gen/preGen/preGenProcess.js.map +1 -0
  166. package/out/gen/preGen/validateCode.d.ts +3 -0
  167. package/out/gen/preGen/validateCode.js +62 -0
  168. package/out/gen/preGen/validateCode.js.map +1 -0
  169. package/out/index.d.ts +2 -0
  170. package/out/index.js +8 -0
  171. package/out/index.js.map +1 -0
  172. package/out/llm/model/Gpt4o.d.ts +1 -0
  173. package/out/llm/model/Gpt4o.js +91 -0
  174. package/out/llm/model/Gpt4o.js.map +1 -0
  175. package/out/llm/model/claude4.d.ts +1 -0
  176. package/out/llm/model/claude4.js +3 -0
  177. package/out/llm/model/claude4.js.map +1 -0
  178. package/out/llm/preparePrompt.d.ts +2 -0
  179. package/out/llm/preparePrompt.js +110 -0
  180. package/out/llm/preparePrompt.js.map +1 -0
  181. package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
  182. package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  183. package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
  184. package/out/llm/prompt/generateUtAutoFix.liquid +19 -0
  185. package/out/llm/prompt/generateUtDependency.liquid +3 -0
  186. package/out/llm/prompt/generateUtGuidelines.liquid +29 -0
  187. package/out/llm/prompt/generateUtSystem.liquid +5 -0
  188. package/out/llm/prompt/generateUtTemplate.liquid +30 -0
  189. package/out/llm/prompt/generateUtUserInput.liquid +4 -0
  190. package/out/llm/prompt/testAfGuidelines.liquid +6 -0
  191. package/out/llm/prompt/userCustomPrompt.liquid +0 -0
  192. package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  193. package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
  194. package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
  195. package/out/llm/prompt/xap/xapUtGuideline-240804.liquid +36 -0
  196. package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
  197. package/out/llm/sendRequestToLLM.d.ts +4 -0
  198. package/out/llm/sendRequestToLLM.js +12 -0
  199. package/out/llm/sendRequestToLLM.js.map +1 -0
  200. package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
  201. package/out/llm/sendRequestToSelfHostLLM.js +41 -0
  202. package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
  203. package/out/metrics/appInsightTelemetry.d.ts +6 -0
  204. package/out/metrics/appInsightTelemetry.js +77 -0
  205. package/out/metrics/appInsightTelemetry.js.map +1 -0
  206. package/out/metrics/machineId.d.ts +11 -0
  207. package/out/metrics/machineId.js +85 -0
  208. package/out/metrics/machineId.js.map +1 -0
  209. package/out/setup/setup.d.ts +1 -0
  210. package/out/setup/setup.js +10 -0
  211. package/out/setup/setup.js.map +1 -0
  212. package/out/setup/setupConsole.d.ts +1 -0
  213. package/out/setup/setupConsole.js +23 -0
  214. package/out/setup/setupConsole.js.map +1 -0
  215. package/out/setup/setupLLMRequest.d.ts +2 -0
  216. package/out/setup/setupLLMRequest.js +10 -0
  217. package/out/setup/setupLLMRequest.js.map +1 -0
  218. package/out/tools/devenvcom.cmd +13 -0
  219. package/out/tools/devenvexe.cmd +13 -0
  220. package/out/tools/msbuildexe.cmd +13 -0
  221. package/out/tools/vstestexe.cmd +13 -0
  222. package/out/types/benchmark.d.ts +11 -0
  223. package/out/types/benchmark.js +3 -0
  224. package/out/types/benchmark.js.map +1 -0
  225. package/out/types/buildResult.d.ts +8 -0
  226. package/out/types/buildResult.js +3 -0
  227. package/out/types/buildResult.js.map +1 -0
  228. package/out/types/constants.d.ts +3 -0
  229. package/out/types/constants.js +7 -0
  230. package/out/types/constants.js.map +1 -0
  231. package/out/types/genResult.d.ts +10 -0
  232. package/out/types/genResult.js +3 -0
  233. package/out/types/genResult.js.map +1 -0
  234. package/out/types/testResult.d.ts +12 -0
  235. package/out/types/testResult.js +3 -0
  236. package/out/types/testResult.js.map +1 -0
  237. package/out/types/verifyResult.d.ts +8 -0
  238. package/out/types/verifyResult.js +3 -0
  239. package/out/types/verifyResult.js.map +1 -0
  240. package/out/utils/checkTestProject.d.ts +2 -0
  241. package/out/utils/checkTestProject.js +79 -0
  242. package/out/utils/checkTestProject.js.map +1 -0
  243. package/out/utils/checkXapCode.d.ts +2 -0
  244. package/out/utils/checkXapCode.js +59 -0
  245. package/out/utils/checkXapCode.js.map +1 -0
  246. package/out/utils/delay.d.ts +1 -0
  247. package/out/utils/delay.js +7 -0
  248. package/out/utils/delay.js.map +1 -0
  249. package/out/utils/detectTestFramework.d.ts +1 -0
  250. package/out/utils/detectTestFramework.js +32 -0
  251. package/out/utils/detectTestFramework.js.map +1 -0
  252. package/out/utils/fileUtils.d.ts +2 -0
  253. package/out/utils/fileUtils.js +42 -0
  254. package/out/utils/fileUtils.js.map +1 -0
  255. package/out/utils/generateCodeSha256.d.ts +1 -0
  256. package/out/utils/generateCodeSha256.js +46 -0
  257. package/out/utils/generateCodeSha256.js.map +1 -0
  258. package/out/utils/getCodeStructurePath.d.ts +5 -0
  259. package/out/utils/getCodeStructurePath.js +155 -0
  260. package/out/utils/getCodeStructurePath.js.map +1 -0
  261. package/out/utils/getOrCreateDir.d.ts +2 -0
  262. package/out/utils/getOrCreateDir.js +63 -0
  263. package/out/utils/getOrCreateDir.js.map +1 -0
  264. package/out/utils/getTestCodeInfo.d.ts +2 -0
  265. package/out/utils/getTestCodeInfo.js +121 -0
  266. package/out/utils/getTestCodeInfo.js.map +1 -0
  267. package/out/utils/getTestFile.d.ts +13 -0
  268. package/out/utils/getTestFile.js +295 -0
  269. package/out/utils/getTestFile.js.map +1 -0
  270. package/out/utils/parseBuildResult.d.ts +3 -0
  271. package/out/utils/parseBuildResult.js +44 -0
  272. package/out/utils/parseBuildResult.js.map +1 -0
  273. package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
  274. package/out/utils/parseSyntaxCheckResult.js +38 -0
  275. package/out/utils/parseSyntaxCheckResult.js.map +1 -0
  276. package/out/utils/parseVstestResult.d.ts +3 -0
  277. package/out/utils/parseVstestResult.js +61 -0
  278. package/out/utils/parseVstestResult.js.map +1 -0
  279. package/out/utils/removeFailedTestMethods.d.ts +3 -0
  280. package/out/utils/removeFailedTestMethods.js +207 -0
  281. package/out/utils/removeFailedTestMethods.js.map +1 -0
  282. package/out/utils/runCommand.d.ts +1 -0
  283. package/out/utils/runCommand.js +14 -0
  284. package/out/utils/runCommand.js.map +1 -0
  285. package/out/utils/spawnExec.d.ts +1 -0
  286. package/out/utils/spawnExec.js +80 -0
  287. package/out/utils/spawnExec.js.map +1 -0
  288. package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
  289. package/out/utils/verifyBuildErrorCausedFile.js +60 -0
  290. package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
  291. package/out/utils/verifyTestCode.d.ts +2 -0
  292. package/out/utils/verifyTestCode.js +25 -0
  293. package/out/utils/verifyTestCode.js.map +1 -0
  294. package/out/utils/writeGenCode.d.ts +1 -0
  295. package/out/utils/writeGenCode.js +50 -0
  296. package/out/utils/writeGenCode.js.map +1 -0
  297. package/out/vs/msBuild.d.ts +13 -0
  298. package/out/vs/msBuild.js +81 -0
  299. package/out/vs/msBuild.js.map +1 -0
  300. package/out/vs/vsTest.d.ts +15 -0
  301. package/out/vs/vsTest.js +107 -0
  302. package/out/vs/vsTest.js.map +1 -0
  303. package/out/vs/vsTools.d.ts +7 -0
  304. package/out/vs/vsTools.js +177 -0
  305. package/out/vs/vsTools.js.map +1 -0
  306. package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
  307. package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
  308. package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
  309. package/out/vsPlugin/interactionConstants.d.ts +2 -0
  310. package/out/vsPlugin/interactionConstants.js +10 -0
  311. package/out/vsPlugin/interactionConstants.js.map +1 -0
  312. package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
  313. package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
  314. package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
  315. package/out/vsPlugin/stdListener.d.ts +3 -0
  316. package/out/vsPlugin/stdListener.js +57 -0
  317. package/out/vsPlugin/stdListener.js.map +1 -0
  318. package/package.json +33 -0
  319. package/tools/devenvcom.cmd +13 -0
  320. package/tools/devenvexe.cmd +13 -0
  321. package/tools/msbuildexe.cmd +13 -0
  322. package/tools/vstestexe.cmd +13 -0
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMsbuildErrors = parseMsbuildErrors;
4
+ exports.formatMsbuildResultToMarkdown = formatMsbuildResultToMarkdown;
5
+ function parseMsbuildErrors(buildOutput) {
6
+ const errors = [];
7
+ const lines = buildOutput.split(/\r?\n/);
8
+ const regex = /^(.+\.cs)\((\d+),(\d+)(?:,\d+,\d+)?\): error (\w+): (.+?) \[(.+)\]$/;
9
+ for (const line of lines) {
10
+ const trimmed = line.trim();
11
+ if (!trimmed.includes(': error '))
12
+ continue;
13
+ console.error("build error line:", trimmed);
14
+ const match = regex.exec(trimmed);
15
+ if (match) {
16
+ const [, file, lineStr, columnStr, errorCode, message, project] = match;
17
+ errors.push({
18
+ file,
19
+ line: parseInt(lineStr, 10),
20
+ column: parseInt(columnStr, 10),
21
+ errorCode,
22
+ message,
23
+ project,
24
+ });
25
+ }
26
+ }
27
+ return errors;
28
+ }
29
+ function formatMsbuildResultToMarkdown(errors) {
30
+ if (errors.length === 0) {
31
+ return `#### No MSBuild Errors`;
32
+ }
33
+ return errors
34
+ .map(err => {
35
+ const code = `[${err.errorCode}]`;
36
+ const line = `Line ${err.line}`;
37
+ const message = err.message.replace(/\s+/g, ' ').trim();
38
+ return `${code} ${line} - ${message}`;
39
+ })
40
+ .join('\n');
41
+ }
42
+ // const buildError = parseMsbuildErrors("D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\Workflows\Overview\HttpRequestParser\Utils\SqmidHelperTests.cs(37,58): error CS1503: Argument 1: cannot convert from 'int' to 'System.Collections.Generic.IDictionary<string, string>'");
43
+ // console.log(formatMsbuildResultToMarkdown(buildError));
44
+ //# sourceMappingURL=parseBuildResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBuildResult.js","sourceRoot":"","sources":["../../src/utils/parseBuildResult.ts"],"names":[],"mappings":";;AAEA,gDA0BC;AAED,sEAaC;AAzCD,SAAgB,kBAAkB,CAAC,WAAmB;IAClD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,KAAK,GAAG,qEAAqE,CAAC;IAEpF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,SAAS;QAE5C,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC;gBACR,IAAI;gBACJ,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC3B,MAAM,EAAE,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;gBAC/B,SAAS;gBACT,OAAO;gBACP,OAAO;aACV,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAgB,6BAA6B,CAAC,MAAqB;IAC/D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,wBAAwB,CAAC;IACpC,CAAC;IAED,OAAO,MAAM;SACR,GAAG,CAAC,GAAG,CAAC,EAAE;QACP,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC;QAClC,MAAM,IAAI,GAAG,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACxD,OAAO,GAAG,IAAI,IAAI,IAAI,MAAM,OAAO,EAAE,CAAC;IAC1C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,qTAAqT;AACrT,0DAA0D","sourcesContent":["import { BuildResult } from \"../types/buildResult\";\r\n\r\nexport function parseMsbuildErrors(buildOutput: string): BuildResult[] {\r\n const errors: BuildResult[] = [];\r\n const lines = buildOutput.split(/\\r?\\n/);\r\n\r\n const regex = /^(.+\\.cs)\\((\\d+),(\\d+)(?:,\\d+,\\d+)?\\): error (\\w+): (.+?) \\[(.+)\\]$/;\r\n\r\n for (const line of lines) {\r\n const trimmed = line.trim();\r\n if (!trimmed.includes(': error ')) continue;\r\n\r\n console.error(\"build error line:\", trimmed);\r\n const match = regex.exec(trimmed);\r\n if (match) {\r\n const [, file, lineStr, columnStr, errorCode, message, project] = match;\r\n errors.push({\r\n file,\r\n line: parseInt(lineStr, 10),\r\n column: parseInt(columnStr, 10),\r\n errorCode,\r\n message,\r\n project,\r\n });\r\n }\r\n }\r\n\r\n return errors;\r\n}\r\n\r\nexport function formatMsbuildResultToMarkdown(errors: BuildResult[]): string {\r\n if (errors.length === 0) {\r\n return `#### No MSBuild Errors`;\r\n }\r\n\r\n return errors\r\n .map(err => {\r\n const code = `[${err.errorCode}]`;\r\n const line = `Line ${err.line}`;\r\n const message = err.message.replace(/\\s+/g, ' ').trim();\r\n return `${code} ${line} - ${message}`;\r\n })\r\n .join('\\n');\r\n}\r\n\r\n// const buildError = parseMsbuildErrors(\"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelperTests.cs(37,58): error CS1503: Argument 1: cannot convert from 'int' to 'System.Collections.Generic.IDictionary<string, string>'\");\r\n// console.log(formatMsbuildResultToMarkdown(buildError));"]}
@@ -0,0 +1,2 @@
1
+ import { BuildResult } from "../types/buildResult";
2
+ export declare function parseSyntaxCheckErrors(testFilePath: string, errorText: string): BuildResult[];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSyntaxCheckErrors = parseSyntaxCheckErrors;
4
+ function parseSyntaxCheckErrors(testFilePath, errorText) {
5
+ const result = [];
6
+ const lines = errorText.split(/\r?\n/).map(line => line.trim()).filter(line => line.length > 0);
7
+ const regex = /^\((\d+),(\d+)\):\s+error\s+(CS\d+):\s+(.+)$/;
8
+ for (const line of lines) {
9
+ const match = line.match(regex);
10
+ if (match) {
11
+ const [, lineStr, columnStr, errorCode, message] = match;
12
+ result.push({
13
+ file: testFilePath,
14
+ line: Number(lineStr),
15
+ column: Number(columnStr),
16
+ errorCode,
17
+ message,
18
+ project: ""
19
+ });
20
+ }
21
+ }
22
+ return result;
23
+ }
24
+ // const buildErrorStr = `
25
+ // (74,62): error CS1513: } expected
26
+ // (74,62): error CS1513: } expected
27
+ // (74,62): error CS1513: } expected
28
+ // (23,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)
29
+ // (36,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)
30
+ // (38,44): error CS0103: The name 'WeatherParameters' does not exist in the current context
31
+ // (48,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)
32
+ // (63,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)
33
+ // `;
34
+ // const buildErrors = parseSyntaxCheckErrors("", buildErrorStr);
35
+ // buildErrors.forEach(err => {
36
+ // console.log(`File: ${err.file}, Line: ${err.line}, Column: ${err.column}, Code: ${err.errorCode}, Message: ${err.message}, Project: ${err.project}`);
37
+ // });
38
+ //# sourceMappingURL=parseSyntaxCheckResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSyntaxCheckResult.js","sourceRoot":"","sources":["../../src/utils/parseSyntaxCheckResult.ts"],"names":[],"mappings":";;AAEA,wDAuBC;AAvBD,SAAgB,sBAAsB,CAAC,YAAoB,EAAE,SAAiB;IAC1E,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEhG,MAAM,KAAK,GAAG,8CAA8C,CAAC;IAE7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;YACzD,MAAM,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC;gBACrB,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC;gBACzB,SAAS;gBACT,OAAO;gBACP,OAAO,EAAE,EAAE;aACd,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,0BAA0B;AAC1B,oCAAoC;AACpC,oCAAoC;AACpC,oCAAoC;AACpC,yJAAyJ;AACzJ,yJAAyJ;AACzJ,4FAA4F;AAC5F,yJAAyJ;AACzJ,yJAAyJ;AACzJ,KAAK;AAEL,iEAAiE;AACjE,+BAA+B;AAC/B,4JAA4J;AAC5J,MAAM","sourcesContent":["import { BuildResult } from \"../types/buildResult\";\r\n\r\nexport function parseSyntaxCheckErrors(testFilePath: string, errorText: string): BuildResult[] {\r\n const result: BuildResult[] = [];\r\n\r\n const lines = errorText.split(/\\r?\\n/).map(line => line.trim()).filter(line => line.length > 0);\r\n\r\n const regex = /^\\((\\d+),(\\d+)\\):\\s+error\\s+(CS\\d+):\\s+(.+)$/;\r\n\r\n for (const line of lines) {\r\n const match = line.match(regex);\r\n if (match) {\r\n const [, lineStr, columnStr, errorCode, message] = match;\r\n result.push({\r\n file: testFilePath,\r\n line: Number(lineStr),\r\n column: Number(columnStr),\r\n errorCode,\r\n message,\r\n project: \"\"\r\n });\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\n// const buildErrorStr = `\r\n// (74,62): error CS1513: } expected\r\n// (74,62): error CS1513: } expected\r\n// (74,62): error CS1513: } expected\r\n// (23,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)\r\n// (36,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)\r\n// (38,44): error CS0103: The name 'WeatherParameters' does not exist in the current context\r\n// (48,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)\r\n// (63,60): error CS0246: The type or namespace name 'OneServiceRequest' could not be found (are you missing a using directive or an assembly reference?)\r\n// `;\r\n\r\n// const buildErrors = parseSyntaxCheckErrors(\"\", buildErrorStr);\r\n// buildErrors.forEach(err => {\r\n// console.log(`File: ${err.file}, Line: ${err.line}, Column: ${err.column}, Code: ${err.errorCode}, Message: ${err.message}, Project: ${err.project}`);\r\n// });"]}
@@ -0,0 +1,3 @@
1
+ import { TestResult } from "../types/testResult";
2
+ export declare function parseVSTestOutput(output: string): TestResult;
3
+ export declare function formatVSTestResultToMarkdown(result: TestResult): string;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseVSTestOutput = parseVSTestOutput;
4
+ exports.formatVSTestResultToMarkdown = formatVSTestResultToMarkdown;
5
+ function parseVSTestOutput(output) {
6
+ const passedTests = [];
7
+ const failedTests = [];
8
+ const lines = output.split(/\r?\n/);
9
+ let currentFailedTest = null;
10
+ for (let i = 0; i < lines.length; i++) {
11
+ const line = lines[i].trim();
12
+ // Match Passed tests
13
+ const passMatch = line.match(/^Passed (.+) \[/);
14
+ if (passMatch) {
15
+ passedTests.push(passMatch[1]);
16
+ continue;
17
+ }
18
+ // Match Failed tests
19
+ const failMatch = line.match(/^Failed (.+) \[/);
20
+ if (failMatch) {
21
+ currentFailedTest = {
22
+ name: failMatch[1],
23
+ errorMessage: '',
24
+ stackTrace: ''
25
+ };
26
+ // Read error message
27
+ i += 2; // skip "Error Message:"
28
+ const errorMessageLines = [];
29
+ while (i < lines.length && !lines[i].trim().startsWith('Stack Trace:')) {
30
+ errorMessageLines.push(lines[i].trim());
31
+ i++;
32
+ }
33
+ currentFailedTest.errorMessage = errorMessageLines.join('\n');
34
+ // Read stack trace
35
+ i++; // skip "Stack Trace:"
36
+ const stackTraceLines = [];
37
+ while (i < lines.length && lines[i].trim() !== '') {
38
+ stackTraceLines.push(lines[i].trim());
39
+ i++;
40
+ }
41
+ currentFailedTest.stackTrace = stackTraceLines.join('\n');
42
+ failedTests.push(currentFailedTest);
43
+ currentFailedTest = null;
44
+ }
45
+ }
46
+ return { passedTests, failedTests, totalTests: passedTests.length + failedTests.length, passed: passedTests.length, failed: failedTests.length };
47
+ }
48
+ function formatVSTestResultToMarkdown(result) {
49
+ const lines = [];
50
+ result.failedTests.forEach(test => {
51
+ const lineNumbers = Array.from(test.stackTrace.matchAll(/:line (\d+)/g)).map(m => m[1]);
52
+ lines.push(`#### ${test.name}`);
53
+ if (lineNumbers.length > 0) {
54
+ lines.push(`**line**: ${lineNumbers.join(', ')}`);
55
+ }
56
+ lines.push(`**Error Message**: ${test.errorMessage}`);
57
+ lines.push('');
58
+ });
59
+ return lines.join('\n');
60
+ }
61
+ //# sourceMappingURL=parseVstestResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseVstestResult.js","sourceRoot":"","sources":["../../src/utils/parseVstestResult.ts"],"names":[],"mappings":";;AAEA,8CAkDC;AAGD,oEAiBC;AAtED,SAAgB,iBAAiB,CAAC,MAAc;IAC5C,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,WAAW,GAAiB,EAAE,CAAC;IAErC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,iBAAiB,GAAsB,IAAI,CAAC;IAEhD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAE7B,qBAAqB;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,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AW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACpC,iBAAiB,GAAG,IAAI,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;AACrJ,CAAC;AAGD,SAAgB,4BAA4B,CAAC,MAAkB;IAC3D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAC1B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAC3C,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjB,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAChC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,aAAa,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACtD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { FailedTest, TestResult } from \"../types/testResult\";\r\n\r\nexport function parseVSTestOutput(output: string): TestResult {\r\n const passedTests: string[] = [];\r\n const failedTests: FailedTest[] = [];\r\n\r\n const lines = output.split(/\\r?\\n/);\r\n let currentFailedTest: FailedTest | null = null;\r\n\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n\r\n // Match Passed tests\r\n const passMatch = line.match(/^Passed (.+) \\[/);\r\n if (passMatch) {\r\n passedTests.push(passMatch[1]);\r\n continue;\r\n }\r\n\r\n // Match Failed tests\r\n const failMatch = line.match(/^Failed (.+) \\[/);\r\n if (failMatch) {\r\n currentFailedTest = {\r\n name: failMatch[1],\r\n errorMessage: '',\r\n stackTrace: ''\r\n };\r\n\r\n // Read error message\r\n i+=2; // skip \"Error Message:\"\r\n const errorMessageLines: string[] = [];\r\n while (i < lines.length && !lines[i].trim().startsWith('Stack Trace:')) {\r\n errorMessageLines.push(lines[i].trim());\r\n i++;\r\n }\r\n currentFailedTest.errorMessage = errorMessageLines.join('\\n');\r\n\r\n // Read stack trace\r\n i++; // skip \"Stack Trace:\"\r\n const stackTraceLines: string[] = [];\r\n while (i < lines.length && lines[i].trim() !== '') {\r\n stackTraceLines.push(lines[i].trim());\r\n i++;\r\n }\r\n currentFailedTest.stackTrace = stackTraceLines.join('\\n');\r\n\r\n failedTests.push(currentFailedTest);\r\n currentFailedTest = null;\r\n }\r\n }\r\n\r\n return { passedTests, failedTests, totalTests: passedTests.length + failedTests.length, passed: passedTests.length, failed: failedTests.length };\r\n}\r\n\r\n\r\nexport function formatVSTestResultToMarkdown(result: TestResult): string {\r\n const lines: string[] = [];\r\n result.failedTests.forEach(test => {\r\n const lineNumbers = Array.from(\r\n test.stackTrace.matchAll(/:line (\\d+)/g)\r\n ).map(m => m[1]);\r\n\r\n lines.push(`#### ${test.name}`);\r\n if (lineNumbers.length > 0) {\r\n lines.push(`**line**: ${lineNumbers.join(', ')}`);\r\n }\r\n \r\n lines.push(`**Error Message**: ${test.errorMessage}`);\r\n lines.push('');\r\n });\r\n\r\n return lines.join('\\n');\r\n}"]}
@@ -0,0 +1,3 @@
1
+ import { TestResult } from '../types/testResult';
2
+ export declare function removeFailedTests(filePath: string, failedTestNames: string[]): string;
3
+ export declare function removeFailedTestCasesInTestFile(vsTestRes: TestResult, testFilePath: string): void;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.removeFailedTests = removeFailedTests;
37
+ exports.removeFailedTestCasesInTestFile = removeFailedTestCasesInTestFile;
38
+ const fs = __importStar(require("fs"));
39
+ function removeFailedTests(filePath, failedTestNames) {
40
+ try {
41
+ if (!fs.existsSync(filePath)) {
42
+ throw new Error(`File not exist ${filePath}`);
43
+ }
44
+ const content = fs.readFileSync(filePath, 'utf-8');
45
+ const lines = content.split(/\r?\n/);
46
+ // get all test methods in the file
47
+ const testMethods = findTestMethods(lines);
48
+ // filter out methods that match the failed test names
49
+ const methodsToRemove = testMethods.filter(method => failedTestNames.includes(method.methodName));
50
+ if (methodsToRemove.length === 0) {
51
+ console.log('Can not find any failed test methods to remove.');
52
+ return;
53
+ }
54
+ // sort methods by start line in descending order
55
+ // to avoid index issues when removing lines
56
+ methodsToRemove.sort((a, b) => b.startLine - a.startLine);
57
+ // delete the test methods from the lines
58
+ let modifiedLines = [...lines];
59
+ for (const method of methodsToRemove) {
60
+ modifiedLines = removeTestMethod(modifiedLines, method);
61
+ }
62
+ // cleanup empty lines
63
+ modifiedLines = cleanupEmptyLines(modifiedLines);
64
+ const modifiedContent = modifiedLines.join('\n');
65
+ return modifiedContent;
66
+ }
67
+ catch (error) {
68
+ console.error('Error removing failed tests:', error);
69
+ throw error;
70
+ }
71
+ }
72
+ /**
73
+ * find all test methods in the file
74
+ */
75
+ function findTestMethods(lines) {
76
+ const testMethods = [];
77
+ for (let i = 0; i < lines.length; i++) {
78
+ const line = lines[i].trim();
79
+ // find [TestMethod] attribute
80
+ if (line === '[TestMethod]' || line.startsWith('[TestMethod(')) {
81
+ // find the method definition starting from this line
82
+ const methodInfo = findMethodDefinition(lines, i);
83
+ if (methodInfo) {
84
+ testMethods.push(methodInfo);
85
+ }
86
+ }
87
+ }
88
+ return testMethods;
89
+ }
90
+ /**
91
+ * find the method definition based on the line number of [TestMethod]
92
+ */
93
+ function findMethodDefinition(lines, testMethodLine) {
94
+ let methodStartLine = testMethodLine;
95
+ let methodName = '';
96
+ let braceCount = 0;
97
+ let methodFound = false;
98
+ let methodEndLine = -1;
99
+ // find the start of the method definition
100
+ while (methodStartLine > 0 &&
101
+ (lines[methodStartLine - 1].trim() === '' ||
102
+ lines[methodStartLine - 1].trim().startsWith('['))) {
103
+ methodStartLine--;
104
+ }
105
+ // find the method definition starting from the line after [TestMethod]
106
+ for (let i = testMethodLine; i < lines.length; i++) {
107
+ const line = lines[i].trim();
108
+ // skip empty lines and section headers
109
+ if (line === '' || line.startsWith('[')) {
110
+ continue;
111
+ }
112
+ // find the method definition
113
+ if (!methodFound && isMethodDefinition(line)) {
114
+ methodName = extractMethodName(line);
115
+ methodFound = true;
116
+ // if the method is defined in a single line, we can directly set the end line
117
+ const openBraces = (line.match(/{/g) || []).length;
118
+ const closeBraces = (line.match(/}/g) || []).length;
119
+ braceCount += openBraces - closeBraces;
120
+ if (braceCount === 0 && openBraces > 0) {
121
+ // single line method definition
122
+ methodEndLine = i;
123
+ break;
124
+ }
125
+ continue;
126
+ }
127
+ // if we have found the method definition, count braces
128
+ if (methodFound) {
129
+ const openBraces = (line.match(/{/g) || []).length;
130
+ const closeBraces = (line.match(/}/g) || []).length;
131
+ braceCount += openBraces - closeBraces;
132
+ if (braceCount === 0) {
133
+ methodEndLine = i;
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ if (methodFound && methodEndLine !== -1) {
139
+ return {
140
+ startLine: methodStartLine,
141
+ endLine: methodEndLine,
142
+ methodName: methodName
143
+ };
144
+ }
145
+ return null;
146
+ }
147
+ /**
148
+ * check if a line is a method definition
149
+ */
150
+ function isMethodDefinition(line) {
151
+ // simple regex to match method definitions
152
+ // supports public, protected, internal, static, async, and method name with parameters
153
+ const methodPattern = /^\s*(public|function|protected|internal)?\s*(static\s+)?(async\s+)?\w+\s+\w+\s*\(/;
154
+ return methodPattern.test(line);
155
+ }
156
+ /**
157
+ * extract method name from a method definition line
158
+ */
159
+ function extractMethodName(line) {
160
+ const match = line.match(/\b(\w+)\s*\(/);
161
+ return match ? match[1] : '';
162
+ }
163
+ /**
164
+ * delete specific testt method block from lines
165
+ */
166
+ function removeTestMethod(lines, method) {
167
+ const newLines = [...lines];
168
+ // delete methodn block(include [TestMethod] tag)
169
+ newLines.splice(method.startLine, method.endLine - method.startLine + 1);
170
+ return newLines;
171
+ }
172
+ /**
173
+ * clean extra empty line, ensure only one empty line between methods
174
+ */
175
+ function cleanupEmptyLines(lines) {
176
+ const result = [];
177
+ let emptyLineCount = 0;
178
+ for (let i = 0; i < lines.length; i++) {
179
+ const line = lines[i];
180
+ const isEmptyLine = line.trim() === '';
181
+ if (isEmptyLine) {
182
+ emptyLineCount++;
183
+ // keep one empty line between methods
184
+ if (emptyLineCount === 1) {
185
+ result.push(line);
186
+ }
187
+ }
188
+ else {
189
+ emptyLineCount = 0;
190
+ result.push(line);
191
+ }
192
+ }
193
+ // remove trailing empty lines
194
+ while (result.length > 0 && result[result.length - 1].trim() === '') {
195
+ result.pop();
196
+ }
197
+ return result;
198
+ }
199
+ function removeFailedTestCasesInTestFile(vsTestRes, testFilePath) {
200
+ const failedTestMethods = vsTestRes?.failedTests?.map(test => test.name) || [];
201
+ const succeedTestCode = removeFailedTests(testFilePath, failedTestMethods);
202
+ fs.writeFileSync(testFilePath, succeedTestCode, 'utf-8');
203
+ console.log(`Removed failed test cases from file: ${testFilePath}`);
204
+ }
205
+ // const testCode = removeFailedTests("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelperTests.cs", ["GetSqmidFromCookie_InvalidBlisIdFormat_ReturnsEmptyString", "GetSqmidFromCookie_MissingUsrLocCookie_ReturnsEmptyString"]);
206
+ // console.log(testCode);
207
+ //# sourceMappingURL=removeFailedTestMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFailedTestMethods.js","sourceRoot":"","sources":["../../src/utils/removeFailedTestMethods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,8CA2CC;AA0JD,0EAKC;AApND,uCAAyB;AAUzB,SAAgB,iBAAiB,CAAC,QAAgB,EAAE,eAAyB;IACzE,IAAI,CAAC;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,OAAO,GAAG,EAAE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AAC;aAAM,CAAC;YACJ,cAAc,GAAG,CAAC,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACL,CAAC;IAED,8BAA8B;IAC9B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAClE,MAAM,CAAC,GAAG,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,SAAgB,+BAA+B,CAAC,SAAqB,EAAE,YAAoB;IACvF,MAAM,iBAAiB,GAAG,SAAS,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/E,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAC3E,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,wCAAwC,YAAY,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,gUAAgU;AAChU,yBAAyB","sourcesContent":["import * as fs from 'fs';\r\n\r\nimport { TestResult } from '../types/testResult';\r\n\r\ninterface TestMethodInfo {\r\n startLine: number;\r\n endLine: number;\r\n methodName: string;\r\n}\r\n\r\nexport function removeFailedTests(filePath: string, failedTestNames: string[]) {\r\n try {\r\n if (!fs.existsSync(filePath)) {\r\n throw new Error(`File not exist ${filePath}`);\r\n }\r\n\r\n const content = fs.readFileSync(filePath, 'utf-8');\r\n const lines = content.split(/\\r?\\n/);\r\n\r\n // get all test methods in the file\r\n const testMethods = findTestMethods(lines);\r\n\r\n // filter out methods that match the failed test names\r\n const methodsToRemove = testMethods.filter(method =>\r\n failedTestNames.includes(method.methodName)\r\n );\r\n\r\n if (methodsToRemove.length === 0) {\r\n console.log('Can not find any failed test methods to remove.');\r\n return;\r\n }\r\n\r\n // sort methods by start line in descending order\r\n // to avoid index issues when removing lines\r\n methodsToRemove.sort((a, b) => b.startLine - a.startLine);\r\n\r\n // delete the test methods from the lines\r\n let modifiedLines = [...lines];\r\n for (const method of methodsToRemove) {\r\n modifiedLines = removeTestMethod(modifiedLines, method);\r\n }\r\n\r\n // cleanup empty lines\r\n modifiedLines = cleanupEmptyLines(modifiedLines);\r\n\r\n\r\n const modifiedContent = modifiedLines.join('\\n');\r\n return modifiedContent;\r\n\r\n } catch (error) {\r\n console.error('Error removing failed tests:', error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * find all test methods in the file\r\n */\r\nfunction findTestMethods(lines: string[]): TestMethodInfo[] {\r\n const testMethods: TestMethodInfo[] = [];\r\n\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n\r\n // find [TestMethod] attribute\r\n if (line === '[TestMethod]' || line.startsWith('[TestMethod(')) {\r\n // find the method definition starting from this line\r\n const methodInfo = findMethodDefinition(lines, i);\r\n if (methodInfo) {\r\n testMethods.push(methodInfo);\r\n }\r\n }\r\n }\r\n\r\n return testMethods;\r\n}\r\n\r\n/**\r\n * find the method definition based on the line number of [TestMethod]\r\n */\r\nfunction findMethodDefinition(lines: string[], testMethodLine: number): TestMethodInfo | null {\r\n let methodStartLine = testMethodLine;\r\n let methodName = '';\r\n let braceCount = 0;\r\n let methodFound = false;\r\n let methodEndLine = -1;\r\n\r\n // find the start of the method definition\r\n while (methodStartLine > 0 &&\r\n (lines[methodStartLine - 1].trim() === '' ||\r\n lines[methodStartLine - 1].trim().startsWith('['))) {\r\n methodStartLine--;\r\n }\r\n\r\n // find the method definition starting from the line after [TestMethod]\r\n for (let i = testMethodLine; i < lines.length; i++) {\r\n const line = lines[i].trim();\r\n\r\n // skip empty lines and section headers\r\n if (line === '' || line.startsWith('[')) {\r\n continue;\r\n }\r\n\r\n // find the method definition\r\n if (!methodFound && isMethodDefinition(line)) {\r\n methodName = extractMethodName(line);\r\n methodFound = true;\r\n\r\n // if the method is defined in a single line, we can directly set the end line\r\n const openBraces = (line.match(/{/g) || []).length;\r\n const closeBraces = (line.match(/}/g) || []).length;\r\n braceCount += openBraces - closeBraces;\r\n\r\n if (braceCount === 0 && openBraces > 0) {\r\n // single line method definition\r\n methodEndLine = i;\r\n break;\r\n }\r\n continue;\r\n }\r\n\r\n // if we have found the method definition, count braces\r\n if (methodFound) {\r\n const openBraces = (line.match(/{/g) || []).length;\r\n const closeBraces = (line.match(/}/g) || []).length;\r\n braceCount += openBraces - closeBraces;\r\n\r\n if (braceCount === 0) {\r\n methodEndLine = i;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (methodFound && methodEndLine !== -1) {\r\n return {\r\n startLine: methodStartLine,\r\n endLine: methodEndLine,\r\n methodName: methodName\r\n };\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * check if a line is a method definition\r\n */\r\nfunction isMethodDefinition(line: string): boolean {\r\n // simple regex to match method definitions\r\n // supports public, protected, internal, static, async, and method name with parameters\r\n const methodPattern = /^\\s*(public|function|protected|internal)?\\s*(static\\s+)?(async\\s+)?\\w+\\s+\\w+\\s*\\(/;\r\n return methodPattern.test(line);\r\n}\r\n\r\n/**\r\n * extract method name from a method definition line\r\n */\r\nfunction extractMethodName(line: string): string {\r\n const match = line.match(/\\b(\\w+)\\s*\\(/);\r\n return match ? match[1] : '';\r\n}\r\n\r\n/**\r\n * delete specific testt method block from lines\r\n */\r\nfunction removeTestMethod(lines: string[], method: TestMethodInfo): string[] {\r\n const newLines = [...lines];\r\n\r\n // delete methodn block(include [TestMethod] tag)\r\n newLines.splice(method.startLine, method.endLine - method.startLine + 1);\r\n\r\n return newLines;\r\n}\r\n\r\n/**\r\n * clean extra empty line, ensure only one empty line between methods\r\n */\r\nfunction cleanupEmptyLines(lines: string[]): string[] {\r\n const result: string[] = [];\r\n let emptyLineCount = 0;\r\n\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i];\r\n const isEmptyLine = line.trim() === '';\r\n\r\n if (isEmptyLine) {\r\n emptyLineCount++;\r\n // keep one empty line between methods\r\n if (emptyLineCount === 1) {\r\n result.push(line);\r\n }\r\n } else {\r\n emptyLineCount = 0;\r\n result.push(line);\r\n }\r\n }\r\n\r\n // remove trailing empty lines\r\n while (result.length > 0 && result[result.length - 1].trim() === '') {\r\n result.pop();\r\n }\r\n\r\n return result;\r\n}\r\n\r\n\r\nexport function removeFailedTestCasesInTestFile(vsTestRes: TestResult, testFilePath: string): void {\r\n const failedTestMethods = vsTestRes?.failedTests?.map(test => test.name) || [];\r\n const succeedTestCode = removeFailedTests(testFilePath, failedTestMethods);\r\n fs.writeFileSync(testFilePath, succeedTestCode, 'utf-8');\r\n console.log(`Removed failed test cases from file: ${testFilePath}`);\r\n}\r\n\r\n// const testCode = removeFailedTests(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelperTests.cs\", [\"GetSqmidFromCookie_InvalidBlisIdFormat_ReturnsEmptyString\", \"GetSqmidFromCookie_MissingUsrLocCookie_ReturnsEmptyString\"]);\r\n// console.log(testCode);"]}
@@ -0,0 +1 @@
1
+ export declare function runCommand(command: string): string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCommand = runCommand;
4
+ const child_process_1 = require("child_process");
5
+ function runCommand(command) {
6
+ try {
7
+ return (0, child_process_1.execSync)(command, { encoding: 'utf8' });
8
+ }
9
+ catch (error) {
10
+ console.error(`Command failed: ${command}`);
11
+ return '';
12
+ }
13
+ }
14
+ //# sourceMappingURL=runCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../src/utils/runCommand.ts"],"names":[],"mappings":";;AAEA,gCAOC;AATD,iDAAyC;AAEzC,SAAgB,UAAU,CAAC,OAAe;IACtC,IAAI,CAAC;QACD,OAAO,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;QAC5C,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC","sourcesContent":["import { execSync } from \"child_process\";\r\n\r\nexport function runCommand(command: string): string {\r\n try {\r\n return execSync(command, { encoding: 'utf8' });\r\n } catch (error) {\r\n console.error(`Command failed: ${command}`);\r\n return '';\r\n }\r\n}\r\n"]}
@@ -0,0 +1 @@
1
+ export declare function runSpawn(execCmd: string, args: string[], workDir: string, errorHandler: any, closeHandler: any): Promise<any>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.runSpawn = runSpawn;
37
+ const path = __importStar(require("path"));
38
+ const childProcessManager_1 = require("../exit/childProcessManager");
39
+ const child_process_1 = require("child_process");
40
+ function runSpawn(execCmd, args, workDir, errorHandler, closeHandler) {
41
+ return new Promise((resolve) => {
42
+ const normalizedCommand = path.normalize(execCmd);
43
+ console.log(`Running ${path.basename(normalizedCommand)}:\n ${normalizedCommand} ${args.join(' ')} ...`);
44
+ const startTime = Date.now();
45
+ // Split command into executable and arguments for spawn
46
+ // const childProcess = spawn(`"${normalizedCommand}"`, args, {
47
+ const childProcess = (0, child_process_1.spawn)(normalizedCommand, args, {
48
+ cwd: workDir,
49
+ detached: true,
50
+ windowsHide: true, // Hide the console window on Windows
51
+ stdio: ['inherit', 'pipe', 'pipe'], // Pipe stdout and stderr for streaming
52
+ // shell: true // Required to handle quoted paths and command-line arguments
53
+ });
54
+ let stdout = '';
55
+ let stderr = '';
56
+ // Collect stdout data
57
+ childProcess.stdout.on('data', (data) => {
58
+ stdout += data.toString();
59
+ });
60
+ // Collect stderr data
61
+ childProcess.stderr.on('data', (data) => {
62
+ stderr += data.toString();
63
+ });
64
+ // Handle process errors, case: the cmd can't be executed, like path not found...
65
+ childProcess.on('error', (error) => {
66
+ console.log(`exec error cost time: ${(Date.now() - startTime) / 1000} seconds`);
67
+ const result = errorHandler(error);
68
+ resolve(result);
69
+ });
70
+ // Handle process exit, case: the cmd executed but failed with error, or succeeded
71
+ childProcess.on('close', (code) => {
72
+ console.log(`exec complete cost time: ${(Date.now() - startTime) / 1000} seconds`);
73
+ const result = closeHandler(code, stdout, stderr);
74
+ resolve(result);
75
+ });
76
+ childProcessManager_1.childProcessSet.add(childProcess.pid);
77
+ console.log(`Running spawnExec with PID: ${childProcess.pid}`);
78
+ });
79
+ }
80
+ //# sourceMappingURL=spawnExec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawnExec.js","sourceRoot":"","sources":["../../src/utils/spawnExec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,4BA+CC;AApDD,2CAA6B;AAE7B,qEAA8D;AAC9D,iDAAsC;AAEtC,SAAgB,QAAQ,CAAC,OAAe,EAAE,IAAc,EAAE,OAAe,EAAE,YAAY,EAAE,YAAY;IACjG,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAElD,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,OAAO,iBAAiB,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzG,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,wDAAwD;QACxD,+DAA+D;QAC/D,MAAM,YAAY,GAAG,IAAA,qBAAK,EAAC,iBAAiB,EAAE,IAAI,EAAE;YAChD,GAAG,EAAE,OAAO;YACZ,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,IAAI,EAAE,qCAAqC;YACxD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,uCAAuC;YAC3E,4EAA4E;SAC/E,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,sBAAsB;QACtB,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACpC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,sBAAsB;QACtB,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACpC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,iFAAiF;QACjF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;YAChF,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;YACnC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,kFAAkF;QAClF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAC9B,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;YACnF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YAClD,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,qCAAe,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,+BAA+B,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import * as path from 'path';\r\n\r\nimport { childProcessSet } from '../exit/childProcessManager';\r\nimport { spawn } from 'child_process';\r\n\r\nexport function runSpawn(execCmd: string, args: string[], workDir: string, errorHandler, closeHandler): Promise<any> {\r\n return new Promise((resolve) => {\r\n const normalizedCommand = path.normalize(execCmd);\r\n\r\n console.log(`Running ${path.basename(normalizedCommand)}:\\n ${normalizedCommand} ${args.join(' ')} ...`);\r\n\r\n const startTime = Date.now();\r\n // Split command into executable and arguments for spawn\r\n // const childProcess = spawn(`\"${normalizedCommand}\"`, args, {\r\n const childProcess = spawn(normalizedCommand, args, {\r\n cwd: workDir,\r\n detached: true,\r\n windowsHide: true, // Hide the console window on Windows\r\n stdio: ['inherit', 'pipe', 'pipe'], // Pipe stdout and stderr for streaming\r\n // shell: true // Required to handle quoted paths and command-line arguments\r\n });\r\n\r\n let stdout = '';\r\n let stderr = '';\r\n\r\n // Collect stdout data\r\n childProcess.stdout.on('data', (data) => {\r\n stdout += data.toString();\r\n });\r\n\r\n // Collect stderr data\r\n childProcess.stderr.on('data', (data) => {\r\n stderr += data.toString();\r\n });\r\n\r\n // Handle process errors, case: the cmd can't be executed, like path not found...\r\n childProcess.on('error', (error) => {\r\n console.log(`exec error cost time: ${(Date.now() - startTime) / 1000} seconds`);\r\n const result = errorHandler(error);\r\n resolve(result);\r\n });\r\n\r\n // Handle process exit, case: the cmd executed but failed with error, or succeeded\r\n childProcess.on('close', (code) => {\r\n console.log(`exec complete cost time: ${(Date.now() - startTime) / 1000} seconds`);\r\n const result = closeHandler(code, stdout, stderr);\r\n resolve(result);\r\n });\r\n\r\n childProcessSet.add(childProcess.pid);\r\n console.log(`Running spawnExec with PID: ${childProcess.pid}`);\r\n });\r\n}"]}
@@ -0,0 +1 @@
1
+ export declare function verifyBuildErrorCausedFile(testCodePath: string, buildErrors: any[]): boolean;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.verifyBuildErrorCausedFile = verifyBuildErrorCausedFile;
37
+ const path = __importStar(require("path"));
38
+ function verifyBuildErrorCausedFile(testCodePath, buildErrors) {
39
+ if (!buildErrors || buildErrors.length === 0) {
40
+ return true;
41
+ }
42
+ let abortSignal = false;
43
+ // Check if the test code path is mentioned in any of the build errors
44
+ for (const buildError of buildErrors) {
45
+ if (!buildError.file) {
46
+ continue;
47
+ }
48
+ const normalizedFilePath = path.normalize(buildError.file);
49
+ const normalizedTestCodePath = path.normalize(testCodePath);
50
+ if (normalizedFilePath !== normalizedTestCodePath) {
51
+ console.error(`Build error was caused by other code file: ${buildError.file}, plesase fix it first.`);
52
+ abortSignal = true;
53
+ }
54
+ }
55
+ if (abortSignal) {
56
+ return false;
57
+ }
58
+ return true; // No errors related to the test code path
59
+ }
60
+ //# sourceMappingURL=verifyBuildErrorCausedFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifyBuildErrorCausedFile.js","sourceRoot":"","sources":["../../src/utils/verifyBuildErrorCausedFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gEAwBC;AA1BD,2CAA6B;AAE7B,SAAgB,0BAA0B,CAAC,YAAoB,EAAE,WAAkB;IAC/E,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,sEAAsE;IACtE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACnB,SAAS;QACb,CAAC;QACD,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC3D,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,kBAAkB,KAAK,sBAAsB,EAAE,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,8CAA8C,UAAU,CAAC,IAAI,yBAAyB,CAAC,CAAC;YACtG,WAAW,GAAG,IAAI,CAAC;QACvB,CAAC;IACL,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,0CAA0C;AAC3D,CAAC","sourcesContent":["import * as path from 'path';\r\n\r\nexport function verifyBuildErrorCausedFile(testCodePath: string, buildErrors: any[]) {\r\n if (!buildErrors || buildErrors.length === 0) {\r\n return true;\r\n }\r\n\r\n let abortSignal = false;\r\n // Check if the test code path is mentioned in any of the build errors\r\n for (const buildError of buildErrors) {\r\n if (!buildError.file) {\r\n continue;\r\n }\r\n const normalizedFilePath = path.normalize(buildError.file);\r\n const normalizedTestCodePath = path.normalize(testCodePath);\r\n if (normalizedFilePath !== normalizedTestCodePath) {\r\n console.error(`Build error was caused by other code file: ${buildError.file}, plesase fix it first.`);\r\n abortSignal = true;\r\n }\r\n }\r\n\r\n if (abortSignal) {\r\n return false;\r\n }\r\n\r\n return true; // No errors related to the test code path\r\n}"]}
@@ -0,0 +1,2 @@
1
+ import { VerifyResult } from "../types/verifyResult";
2
+ export declare function verifyTestCode(testCode: string, testProjectPath: string): Promise<VerifyResult>;