@ai-dev-tools/csharp-copilot-core 0.0.31 → 0.0.32

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 (309) hide show
  1. package/out/analyze/cecil.d.ts +1 -0
  2. package/out/analyze/cecil.js +42 -0
  3. package/out/analyze/cecil.js.map +1 -0
  4. package/out/analyze/checkCodeSyntax.d.ts +7 -0
  5. package/out/analyze/checkCodeSyntax.js +67 -0
  6. package/out/analyze/checkCodeSyntax.js.map +1 -0
  7. package/out/analyze/generateCodeDependency.d.ts +6 -0
  8. package/out/analyze/generateCodeDependency.js +127 -0
  9. package/out/analyze/generateCodeDependency.js.map +1 -0
  10. package/out/analyze/installAnalyzerTool.d.ts +1 -0
  11. package/out/analyze/installAnalyzerTool.js +83 -0
  12. package/out/analyze/installAnalyzerTool.js.map +1 -0
  13. package/out/batch/generateCodeTests.d.ts +6 -0
  14. package/out/batch/generateCodeTests.js +163 -0
  15. package/out/batch/generateCodeTests.js.map +1 -0
  16. package/out/batch/getFolderCodeFile.d.ts +1 -0
  17. package/out/batch/getFolderCodeFile.js +19 -0
  18. package/out/batch/getFolderCodeFile.js.map +1 -0
  19. package/out/batch/getProjectCodeFile.d.ts +4 -0
  20. package/out/batch/getProjectCodeFile.js +86 -0
  21. package/out/batch/getProjectCodeFile.js.map +1 -0
  22. package/out/batch/getSolutionCodeFile.d.ts +8 -0
  23. package/out/batch/getSolutionCodeFile.js +70 -0
  24. package/out/batch/getSolutionCodeFile.js.map +1 -0
  25. package/out/benchmark/formatToMarkdown.d.ts +2 -0
  26. package/out/benchmark/formatToMarkdown.js +101 -0
  27. package/out/benchmark/formatToMarkdown.js.map +1 -0
  28. package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
  29. package/out/benchmark/generateBenchmarkReport.js +82 -0
  30. package/out/benchmark/generateBenchmarkReport.js.map +1 -0
  31. package/out/codeCoverage/codeCoverage.d.ts +6 -0
  32. package/out/codeCoverage/codeCoverage.js +39 -0
  33. package/out/codeCoverage/codeCoverage.js.map +1 -0
  34. package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
  35. package/out/codeCoverage/codeCoverageReport.js +76 -0
  36. package/out/codeCoverage/codeCoverageReport.js.map +1 -0
  37. package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
  38. package/out/codeCoverage/extractCodeCoverageInfo.js +81 -0
  39. package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
  40. package/out/codeCoverage/extractCoverageReportPath.d.ts +1 -0
  41. package/out/codeCoverage/extractCoverageReportPath.js +25 -0
  42. package/out/codeCoverage/extractCoverageReportPath.js.map +1 -0
  43. package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
  44. package/out/codeCoverage/generateCodeCoverageReport.js +30 -0
  45. package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
  46. package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
  47. package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
  48. package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
  49. package/out/codeCoverage/reportTool.d.ts +2 -0
  50. package/out/codeCoverage/reportTool.js +23 -0
  51. package/out/codeCoverage/reportTool.js.map +1 -0
  52. package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
  53. package/out/codeCoverage/simplifyCoverageXml.js +117 -0
  54. package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
  55. package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
  56. package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  57. package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
  58. package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
  59. package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
  60. package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
  61. package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
  62. package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
  63. package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  64. package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
  65. package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
  66. package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
  67. package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
  68. package/out/codebk/childProcessManager.d.ts +1 -0
  69. package/out/codebk/childProcessManager.js +50 -0
  70. package/out/codebk/childProcessManager.js.map +1 -0
  71. package/out/codebk/msBuidSpawn.d.ts +1 -0
  72. package/out/codebk/msBuidSpawn.js +58 -0
  73. package/out/codebk/msBuidSpawn.js.map +1 -0
  74. package/out/codebk/msBuild.d.ts +1 -0
  75. package/out/codebk/msBuild.js +123 -0
  76. package/out/codebk/msBuild.js.map +1 -0
  77. package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
  78. package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
  79. package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
  80. package/out/codebk/old/xapGuideline-fm.liquid +149 -0
  81. package/out/codebk/old/xapGuideline.liquid +37 -0
  82. package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
  83. package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
  84. package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
  85. package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
  86. package/out/codebk/oldExec/codeCoverage.js +54 -0
  87. package/out/codebk/oldExec/codeCoverage.js.map +1 -0
  88. package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
  89. package/out/codebk/oldExec/codeCoverageReport.js +64 -0
  90. package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
  91. package/out/codebk/oldExec/containsMethods.d.ts +1 -0
  92. package/out/codebk/oldExec/containsMethods.js +74 -0
  93. package/out/codebk/oldExec/containsMethods.js.map +1 -0
  94. package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
  95. package/out/codebk/oldExec/generateCodeDependency.js +95 -0
  96. package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
  97. package/out/codebk/oldExec/msBuild.d.ts +1 -0
  98. package/out/codebk/oldExec/msBuild.js +53 -0
  99. package/out/codebk/oldExec/msBuild.js.map +1 -0
  100. package/out/codebk/oldExec/vsTest.d.ts +1 -0
  101. package/out/codebk/oldExec/vsTest.js +71 -0
  102. package/out/codebk/oldExec/vsTest.js.map +1 -0
  103. package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
  104. package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
  105. package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
  106. package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
  107. package/out/codebk/testbuildkill.d.ts +1 -0
  108. package/out/codebk/testbuildkill.js +37 -0
  109. package/out/codebk/testbuildkill.js.map +1 -0
  110. package/out/command/index.d.ts +2 -0
  111. package/out/command/index.js +90 -0
  112. package/out/command/index.js.map +1 -0
  113. package/out/command/utGenWrapper.d.ts +3 -0
  114. package/out/command/utGenWrapper.js +53 -0
  115. package/out/command/utGenWrapper.js.map +1 -0
  116. package/out/exit/childProcessManager.d.ts +2 -0
  117. package/out/exit/childProcessManager.js +43 -0
  118. package/out/exit/childProcessManager.js.map +1 -0
  119. package/out/exit/setupProcessSignalHandler.d.ts +1 -0
  120. package/out/exit/setupProcessSignalHandler.js +18 -0
  121. package/out/exit/setupProcessSignalHandler.js.map +1 -0
  122. package/out/gen/autoFix.d.ts +4 -0
  123. package/out/gen/autoFix.js +129 -0
  124. package/out/gen/autoFix.js.map +1 -0
  125. package/out/gen/csharpUtGen.d.ts +2 -0
  126. package/out/gen/csharpUtGen.js +125 -0
  127. package/out/gen/csharpUtGen.js.map +1 -0
  128. package/out/gen/ensureValidLLMResponse.d.ts +1 -0
  129. package/out/gen/ensureValidLLMResponse.js +19 -0
  130. package/out/gen/ensureValidLLMResponse.js.map +1 -0
  131. package/out/gen/postGen/addAiAnnotation.d.ts +1 -0
  132. package/out/gen/postGen/addAiAnnotation.js +57 -0
  133. package/out/gen/postGen/addAiAnnotation.js.map +1 -0
  134. package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
  135. package/out/gen/postGen/extractCodeFromResponse.js +38 -0
  136. package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
  137. package/out/gen/postGen/postGenProcess.d.ts +1 -0
  138. package/out/gen/postGen/postGenProcess.js +39 -0
  139. package/out/gen/postGen/postGenProcess.js.map +1 -0
  140. package/out/gen/postGen/removeComments.d.ts +1 -0
  141. package/out/gen/postGen/removeComments.js +92 -0
  142. package/out/gen/postGen/removeComments.js.map +1 -0
  143. package/out/gen/postGen/removeSingleLines.d.ts +1 -0
  144. package/out/gen/postGen/removeSingleLines.js +29 -0
  145. package/out/gen/postGen/removeSingleLines.js.map +1 -0
  146. package/out/gen/postGen/repairRequiredNameSpaces.d.ts +2 -0
  147. package/out/gen/postGen/repairRequiredNameSpaces.js +142 -0
  148. package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
  149. package/out/gen/postGen/validateTestCode.d.ts +1 -0
  150. package/out/gen/postGen/validateTestCode.js +14 -0
  151. package/out/gen/postGen/validateTestCode.js.map +1 -0
  152. package/out/gen/preGen/excludeFileName.d.ts +1 -0
  153. package/out/gen/preGen/excludeFileName.js +49 -0
  154. package/out/gen/preGen/excludeFileName.js.map +1 -0
  155. package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
  156. package/out/gen/preGen/excludeSpecificTag.js +19 -0
  157. package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
  158. package/out/gen/preGen/preGenProcess.d.ts +1 -0
  159. package/out/gen/preGen/preGenProcess.js +22 -0
  160. package/out/gen/preGen/preGenProcess.js.map +1 -0
  161. package/out/gen/preGen/validateCode.d.ts +3 -0
  162. package/out/gen/preGen/validateCode.js +63 -0
  163. package/out/gen/preGen/validateCode.js.map +1 -0
  164. package/out/index.d.ts +3 -0
  165. package/out/index.js +10 -0
  166. package/out/index.js.map +1 -0
  167. package/out/llm/model/Gpt.d.ts +1 -0
  168. package/out/llm/model/Gpt.js +93 -0
  169. package/out/llm/model/Gpt.js.map +1 -0
  170. package/out/llm/preparePrompt.d.ts +2 -0
  171. package/out/llm/preparePrompt.js +135 -0
  172. package/out/llm/preparePrompt.js.map +1 -0
  173. package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
  174. package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
  175. package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
  176. package/out/llm/prompt/generateUtAutoFix.liquid +23 -0
  177. package/out/llm/prompt/generateUtDependency.liquid +3 -0
  178. package/out/llm/prompt/generateUtSystem.liquid +5 -0
  179. package/out/llm/prompt/generateUtTemplate.liquid +32 -0
  180. package/out/llm/prompt/generateUtUserInput.liquid +4 -0
  181. package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
  182. package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
  183. package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
  184. package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
  185. package/out/llm/sendRequestToLLM.d.ts +4 -0
  186. package/out/llm/sendRequestToLLM.js +9 -0
  187. package/out/llm/sendRequestToLLM.js.map +1 -0
  188. package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
  189. package/out/llm/sendRequestToSelfHostLLM.js +41 -0
  190. package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
  191. package/out/metrics/appInsightTelemetry.d.ts +6 -0
  192. package/out/metrics/appInsightTelemetry.js +77 -0
  193. package/out/metrics/appInsightTelemetry.js.map +1 -0
  194. package/out/metrics/machineId.d.ts +11 -0
  195. package/out/metrics/machineId.js +85 -0
  196. package/out/metrics/machineId.js.map +1 -0
  197. package/out/setup/setup.d.ts +1 -0
  198. package/out/setup/setup.js +10 -0
  199. package/out/setup/setup.js.map +1 -0
  200. package/out/setup/setupConsole.d.ts +1 -0
  201. package/out/setup/setupConsole.js +23 -0
  202. package/out/setup/setupConsole.js.map +1 -0
  203. package/out/setup/setupLLMRequest.d.ts +2 -0
  204. package/out/setup/setupLLMRequest.js +10 -0
  205. package/out/setup/setupLLMRequest.js.map +1 -0
  206. package/out/tools/devenvcom.cmd +13 -0
  207. package/out/tools/devenvexe.cmd +13 -0
  208. package/out/tools/msbuildexe.cmd +13 -0
  209. package/out/tools/vstestexe.cmd +13 -0
  210. package/out/types/benchmark.d.ts +11 -0
  211. package/out/types/benchmark.js +3 -0
  212. package/out/types/benchmark.js.map +1 -0
  213. package/out/types/buildResult.d.ts +8 -0
  214. package/out/types/buildResult.js +3 -0
  215. package/out/types/buildResult.js.map +1 -0
  216. package/out/types/constants.d.ts +10 -0
  217. package/out/types/constants.js +14 -0
  218. package/out/types/constants.js.map +1 -0
  219. package/out/types/genResult.d.ts +10 -0
  220. package/out/types/genResult.js +3 -0
  221. package/out/types/genResult.js.map +1 -0
  222. package/out/types/testResult.d.ts +12 -0
  223. package/out/types/testResult.js +3 -0
  224. package/out/types/testResult.js.map +1 -0
  225. package/out/types/verifyResult.d.ts +8 -0
  226. package/out/types/verifyResult.js +3 -0
  227. package/out/types/verifyResult.js.map +1 -0
  228. package/out/utils/checkTestProject.d.ts +2 -0
  229. package/out/utils/checkTestProject.js +79 -0
  230. package/out/utils/checkTestProject.js.map +1 -0
  231. package/out/utils/checkXapCode.d.ts +2 -0
  232. package/out/utils/checkXapCode.js +59 -0
  233. package/out/utils/checkXapCode.js.map +1 -0
  234. package/out/utils/delay.d.ts +1 -0
  235. package/out/utils/delay.js +7 -0
  236. package/out/utils/delay.js.map +1 -0
  237. package/out/utils/detectTestFramework.d.ts +1 -0
  238. package/out/utils/detectTestFramework.js +33 -0
  239. package/out/utils/detectTestFramework.js.map +1 -0
  240. package/out/utils/fileUtils.d.ts +2 -0
  241. package/out/utils/fileUtils.js +42 -0
  242. package/out/utils/fileUtils.js.map +1 -0
  243. package/out/utils/generateCodeSha256.d.ts +1 -0
  244. package/out/utils/generateCodeSha256.js +46 -0
  245. package/out/utils/generateCodeSha256.js.map +1 -0
  246. package/out/utils/getCodeStructurePath.d.ts +5 -0
  247. package/out/utils/getCodeStructurePath.js +155 -0
  248. package/out/utils/getCodeStructurePath.js.map +1 -0
  249. package/out/utils/getOrCreateDir.d.ts +2 -0
  250. package/out/utils/getOrCreateDir.js +63 -0
  251. package/out/utils/getOrCreateDir.js.map +1 -0
  252. package/out/utils/getTestCodeInfo.d.ts +2 -0
  253. package/out/utils/getTestCodeInfo.js +121 -0
  254. package/out/utils/getTestCodeInfo.js.map +1 -0
  255. package/out/utils/getTestFile.d.ts +13 -0
  256. package/out/utils/getTestFile.js +297 -0
  257. package/out/utils/getTestFile.js.map +1 -0
  258. package/out/utils/parseBuildResult.d.ts +3 -0
  259. package/out/utils/parseBuildResult.js +45 -0
  260. package/out/utils/parseBuildResult.js.map +1 -0
  261. package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
  262. package/out/utils/parseSyntaxCheckResult.js +39 -0
  263. package/out/utils/parseSyntaxCheckResult.js.map +1 -0
  264. package/out/utils/parseVstestResult.d.ts +3 -0
  265. package/out/utils/parseVstestResult.js +62 -0
  266. package/out/utils/parseVstestResult.js.map +1 -0
  267. package/out/utils/removeFailedTestMethods.d.ts +3 -0
  268. package/out/utils/removeFailedTestMethods.js +208 -0
  269. package/out/utils/removeFailedTestMethods.js.map +1 -0
  270. package/out/utils/runCommand.d.ts +1 -0
  271. package/out/utils/runCommand.js +14 -0
  272. package/out/utils/runCommand.js.map +1 -0
  273. package/out/utils/spawnExec.d.ts +1 -0
  274. package/out/utils/spawnExec.js +80 -0
  275. package/out/utils/spawnExec.js.map +1 -0
  276. package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
  277. package/out/utils/verifyBuildErrorCausedFile.js +60 -0
  278. package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
  279. package/out/utils/verifyTestCode.d.ts +2 -0
  280. package/out/utils/verifyTestCode.js +25 -0
  281. package/out/utils/verifyTestCode.js.map +1 -0
  282. package/out/utils/writeFailedVerifyResult.d.ts +1 -0
  283. package/out/utils/writeFailedVerifyResult.js +67 -0
  284. package/out/utils/writeFailedVerifyResult.js.map +1 -0
  285. package/out/utils/writeGenCode.d.ts +1 -0
  286. package/out/utils/writeGenCode.js +63 -0
  287. package/out/utils/writeGenCode.js.map +1 -0
  288. package/out/vs/msBuild.d.ts +13 -0
  289. package/out/vs/msBuild.js +49 -0
  290. package/out/vs/msBuild.js.map +1 -0
  291. package/out/vs/vsTest.d.ts +15 -0
  292. package/out/vs/vsTest.js +75 -0
  293. package/out/vs/vsTest.js.map +1 -0
  294. package/out/vs/vsTools.d.ts +7 -0
  295. package/out/vs/vsTools.js +177 -0
  296. package/out/vs/vsTools.js.map +1 -0
  297. package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
  298. package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
  299. package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
  300. package/out/vsPlugin/interactionConstants.d.ts +2 -0
  301. package/out/vsPlugin/interactionConstants.js +10 -0
  302. package/out/vsPlugin/interactionConstants.js.map +1 -0
  303. package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
  304. package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
  305. package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
  306. package/out/vsPlugin/stdListener.d.ts +3 -0
  307. package/out/vsPlugin/stdListener.js +57 -0
  308. package/out/vsPlugin/stdListener.js.map +1 -0
  309. package/package.json +1 -1
@@ -0,0 +1,208 @@
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
+ const constants_1 = require("../types/constants");
40
+ function removeFailedTests(filePath, failedTestNames) {
41
+ try {
42
+ if (!fs.existsSync(filePath)) {
43
+ throw new Error(`File not exist ${filePath}`);
44
+ }
45
+ const content = fs.readFileSync(filePath, 'utf-8');
46
+ const lines = content.split(constants_1.LINESEPARATOR);
47
+ // get all test methods in the file
48
+ const testMethods = findTestMethods(lines);
49
+ // filter out methods that match the failed test names
50
+ const methodsToRemove = testMethods.filter(method => failedTestNames.includes(method.methodName));
51
+ if (methodsToRemove.length === 0) {
52
+ console.log('Can not find any failed test methods to remove.');
53
+ return;
54
+ }
55
+ // sort methods by start line in descending order
56
+ // to avoid index issues when removing lines
57
+ methodsToRemove.sort((a, b) => b.startLine - a.startLine);
58
+ // delete the test methods from the lines
59
+ let modifiedLines = [...lines];
60
+ for (const method of methodsToRemove) {
61
+ modifiedLines = removeTestMethod(modifiedLines, method);
62
+ }
63
+ // cleanup empty lines
64
+ modifiedLines = cleanupEmptyLines(modifiedLines);
65
+ const modifiedContent = modifiedLines.join('\n');
66
+ return modifiedContent;
67
+ }
68
+ catch (error) {
69
+ console.error('Error removing failed tests:', error);
70
+ throw error;
71
+ }
72
+ }
73
+ /**
74
+ * find all test methods in the file
75
+ */
76
+ function findTestMethods(lines) {
77
+ const testMethods = [];
78
+ for (let i = 0; i < lines.length; i++) {
79
+ const line = lines[i].trim();
80
+ // find [TestMethod] attribute
81
+ if (line === '[TestMethod]' || line.startsWith('[TestMethod(')) {
82
+ // find the method definition starting from this line
83
+ const methodInfo = findMethodDefinition(lines, i);
84
+ if (methodInfo) {
85
+ testMethods.push(methodInfo);
86
+ }
87
+ }
88
+ }
89
+ return testMethods;
90
+ }
91
+ /**
92
+ * find the method definition based on the line number of [TestMethod]
93
+ */
94
+ function findMethodDefinition(lines, testMethodLine) {
95
+ let methodStartLine = testMethodLine;
96
+ let methodName = '';
97
+ let braceCount = 0;
98
+ let methodFound = false;
99
+ let methodEndLine = -1;
100
+ // find the start of the method definition
101
+ while (methodStartLine > 0 &&
102
+ (lines[methodStartLine - 1].trim() === '' ||
103
+ lines[methodStartLine - 1].trim().startsWith('['))) {
104
+ methodStartLine--;
105
+ }
106
+ // find the method definition starting from the line after [TestMethod]
107
+ for (let i = testMethodLine; i < lines.length; i++) {
108
+ const line = lines[i].trim();
109
+ // skip empty lines and section headers
110
+ if (line === '' || line.startsWith('[')) {
111
+ continue;
112
+ }
113
+ // find the method definition
114
+ if (!methodFound && isMethodDefinition(line)) {
115
+ methodName = extractMethodName(line);
116
+ methodFound = true;
117
+ // if the method is defined in a single line, we can directly set the end line
118
+ const openBraces = (line.match(/{/g) || []).length;
119
+ const closeBraces = (line.match(/}/g) || []).length;
120
+ braceCount += openBraces - closeBraces;
121
+ if (braceCount === 0 && openBraces > 0) {
122
+ // single line method definition
123
+ methodEndLine = i;
124
+ break;
125
+ }
126
+ continue;
127
+ }
128
+ // if we have found the method definition, count braces
129
+ if (methodFound) {
130
+ const openBraces = (line.match(/{/g) || []).length;
131
+ const closeBraces = (line.match(/}/g) || []).length;
132
+ braceCount += openBraces - closeBraces;
133
+ if (braceCount === 0) {
134
+ methodEndLine = i;
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ if (methodFound && methodEndLine !== -1) {
140
+ return {
141
+ startLine: methodStartLine,
142
+ endLine: methodEndLine,
143
+ methodName: methodName
144
+ };
145
+ }
146
+ return null;
147
+ }
148
+ /**
149
+ * check if a line is a method definition
150
+ */
151
+ function isMethodDefinition(line) {
152
+ // simple regex to match method definitions
153
+ // supports public, protected, internal, static, async, and method name with parameters
154
+ const methodPattern = /^\s*(public|function|protected|internal)?\s*(static\s+)?(async\s+)?\w+\s+\w+\s*\(/;
155
+ return methodPattern.test(line);
156
+ }
157
+ /**
158
+ * extract method name from a method definition line
159
+ */
160
+ function extractMethodName(line) {
161
+ const match = line.match(/\b(\w+)\s*\(/);
162
+ return match ? match[1] : '';
163
+ }
164
+ /**
165
+ * delete specific testt method block from lines
166
+ */
167
+ function removeTestMethod(lines, method) {
168
+ const newLines = [...lines];
169
+ // delete methodn block(include [TestMethod] tag)
170
+ newLines.splice(method.startLine, method.endLine - method.startLine + 1);
171
+ return newLines;
172
+ }
173
+ /**
174
+ * clean extra empty line, ensure only one empty line between methods
175
+ */
176
+ function cleanupEmptyLines(lines) {
177
+ const result = [];
178
+ let emptyLineCount = 0;
179
+ for (let i = 0; i < lines.length; i++) {
180
+ const line = lines[i];
181
+ const isEmptyLine = line.trim() === '';
182
+ if (isEmptyLine) {
183
+ emptyLineCount++;
184
+ // keep one empty line between methods
185
+ if (emptyLineCount === 1) {
186
+ result.push(line);
187
+ }
188
+ }
189
+ else {
190
+ emptyLineCount = 0;
191
+ result.push(line);
192
+ }
193
+ }
194
+ // remove trailing empty lines
195
+ while (result.length > 0 && result[result.length - 1].trim() === '') {
196
+ result.pop();
197
+ }
198
+ return result;
199
+ }
200
+ function removeFailedTestCasesInTestFile(vsTestRes, testFilePath) {
201
+ const failedTestMethods = vsTestRes?.failedTests?.map(test => test.name) || [];
202
+ const succeedTestCode = removeFailedTests(testFilePath, failedTestMethods);
203
+ fs.writeFileSync(testFilePath, succeedTestCode, 'utf-8');
204
+ console.log(`Removed failed test cases from file: ${testFilePath}`);
205
+ }
206
+ // const testCode = removeFailedTests("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelperTests.cs", ["GetSqmidFromCookie_InvalidBlisIdFormat_ReturnsEmptyString", "GetSqmidFromCookie_MissingUsrLocCookie_ReturnsEmptyString"]);
207
+ // console.log(testCode);
208
+ //# sourceMappingURL=removeFailedTestMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeFailedTestMethods.js","sourceRoot":"","sources":["../../src/utils/removeFailedTestMethods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,8CA2CC;AA0JD,0EAKC;AArND,uCAAyB;AAGzB,kDAAmD;AAQnD,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,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,yBAAa,CAAC,CAAC;QAE3C,mCAAmC;QACnC,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;Q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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\nimport { LINESEPARATOR } from '../types/constants';\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(LINESEPARATOR);\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/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AAC,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>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyTestCode = verifyTestCode;
4
+ const getCodeStructurePath_1 = require("./getCodeStructurePath");
5
+ const getTestCodeInfo_1 = require("./getTestCodeInfo");
6
+ const msBuild_1 = require("../vs/msBuild");
7
+ const vsTest_1 = require("../vs/vsTest");
8
+ async function verifyTestCode(testCode, testProjectPath) {
9
+ const startTime = Date.now();
10
+ const { success: buildSuccess, message: buildMessage, buildErrors } = await (0, msBuild_1.runMsBuild)(testProjectPath);
11
+ if (!buildSuccess) {
12
+ console.error(`build failed: ${buildMessage}`);
13
+ return { success: false, message: buildMessage, buildErrors: buildErrors, testResult: null };
14
+ }
15
+ const testProjectDll = (0, getCodeStructurePath_1.getBuiltDllPath)(testProjectPath);
16
+ const testClassName = (0, getTestCodeInfo_1.getTestClassName)(testCode);
17
+ const { success: testSuccess, message: testMessage, testResult } = await (0, vsTest_1.runTestClass)(testProjectDll, testClassName);
18
+ if (!testSuccess) {
19
+ console.error(`test failed: ${testMessage}`);
20
+ return { success: false, message: testMessage, buildErrors: null, testResult };
21
+ }
22
+ console.log(`Verify time: ${(Date.now() - startTime) / 1000} seconds`);
23
+ return { success: true, message: "", buildErrors: null, testResult: null };
24
+ }
25
+ //# sourceMappingURL=verifyTestCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifyTestCode.js","sourceRoot":"","sources":["../../src/utils/verifyTestCode.ts"],"names":[],"mappings":";;AAMA,wCAkBC;AAvBD,iEAAyD;AACzD,uDAAqD;AACrD,2CAA2C;AAC3C,yCAA4C;AAErC,KAAK,UAAU,cAAc,CAAC,QAAgB,EAAE,eAAuB;IAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,oBAAU,EAAC,eAAe,CAAC,CAAC;IACxG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,iBAAiB,YAAY,EAAE,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACjG,CAAC;IAED,MAAM,cAAc,GAAG,IAAA,sCAAe,EAAC,eAAe,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,IAAA,kCAAgB,EAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,qBAAY,EAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IACrH,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,WAAW,EAAE,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACnF,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;IACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AAC/E,CAAC","sourcesContent":["import { VerifyResult } from \"../types/verifyResult\";\r\nimport { getBuiltDllPath } from \"./getCodeStructurePath\";\r\nimport { getTestClassName } from \"./getTestCodeInfo\";\r\nimport { runMsBuild } from \"../vs/msBuild\";\r\nimport { runTestClass } from \"../vs/vsTest\";\r\n\r\nexport async function verifyTestCode(testCode: string, testProjectPath: string): Promise<VerifyResult> {\r\n const startTime = Date.now();\r\n const { success: buildSuccess, message: buildMessage, buildErrors } = await runMsBuild(testProjectPath);\r\n if (!buildSuccess) {\r\n console.error(`build failed: ${buildMessage}`);\r\n return { success: false, message: buildMessage, buildErrors: buildErrors, testResult: null };\r\n }\r\n\r\n const testProjectDll = getBuiltDllPath(testProjectPath);\r\n const testClassName = getTestClassName(testCode);\r\n const { success: testSuccess, message: testMessage, testResult } = await runTestClass(testProjectDll, testClassName);\r\n if (!testSuccess) {\r\n console.error(`test failed: ${testMessage}`);\r\n return { success: false, message: testMessage, buildErrors: null, testResult };\r\n }\r\n\r\n console.log(`Verify time: ${(Date.now() - startTime) / 1000} seconds`);\r\n return { success: true, message: \"\", buildErrors: null, testResult: null };\r\n}"]}
@@ -0,0 +1 @@
1
+ export declare function writeFailedVerifyResult(sourceCodePath: string, genCnt: number, sourceCodeProjectPath: string, errorMessage: string, isBuildFailure: boolean): void;
@@ -0,0 +1,67 @@
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.writeFailedVerifyResult = writeFailedVerifyResult;
37
+ const path = __importStar(require("path"));
38
+ const fs = __importStar(require("fs"));
39
+ const getOrCreateDir_1 = require("./getOrCreateDir");
40
+ const fileUtils_1 = require("./fileUtils");
41
+ const TESTFILEINFODIR = './failedVerifyResults';
42
+ const BUILDERRORDIRNAME = 'buildErrors';
43
+ const TESTERRORDIRNAME = 'testErrors';
44
+ function writeFailedVerifyResult(sourceCodePath, genCnt, sourceCodeProjectPath, errorMessage, isBuildFailure) {
45
+ const sourceFileName = path.basename(sourceCodePath, '.cs');
46
+ let testFileName = `${sourceFileName}Tests${genCnt}.cs`;
47
+ const errorSubDir = isBuildFailure ? BUILDERRORDIRNAME : TESTERRORDIRNAME;
48
+ const classifiedFileDir = path.join(TESTFILEINFODIR, errorSubDir);
49
+ let testFileDir = (0, getOrCreateDir_1.getTmpCacheDir)(classifiedFileDir);
50
+ if (sourceCodeProjectPath && fs.existsSync(sourceCodeProjectPath)) {
51
+ // Get the directory containing the .csproj file
52
+ const projectDir = path.dirname(sourceCodeProjectPath);
53
+ // Get the relative path from project directory to source file
54
+ const relativePath = path.relative(projectDir, sourceCodePath);
55
+ // Parse the relative path
56
+ const parsedPath = path.parse(relativePath);
57
+ testFileDir = (0, getOrCreateDir_1.getTmpCacheDir)(path.join(classifiedFileDir, parsedPath.dir));
58
+ }
59
+ const testFilePath = path.join(testFileDir, testFileName);
60
+ (0, fileUtils_1.writeTestCode)(errorMessage, testFilePath);
61
+ console.log(`Generated error message written to: ${testFilePath}`);
62
+ }
63
+ // writeFailedVerifyResult("Q:\\MyProject\\TestTestReport\\TestTestReport\\Multiply.cs", 4,
64
+ // "Q:\\MyProject\\TestTestReport\\TestTestReport\\TestTestReport.csproj",
65
+ // "Sample error message222",
66
+ // true);
67
+ //# sourceMappingURL=writeFailedVerifyResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeFailedVerifyResult.js","sourceRoot":"","sources":["../../src/utils/writeFailedVerifyResult.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0DAqBC;AA9BD,2CAA6B;AAC7B,uCAAyB;AAEzB,qDAAkD;AAClD,2CAA4C;AAE5C,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAChD,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AACtC,SAAgB,uBAAuB,CAAC,cAAsB,EAAE,MAAc,EAAE,qBAA6B,EAAE,YAAoB,EAAE,cAAuB;IACxJ,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC5D,IAAI,YAAY,GAAG,GAAG,cAAc,QAAQ,MAAM,KAAK,CAAC;IACxD,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC1E,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAClE,IAAI,WAAW,GAAG,IAAA,+BAAc,EAAC,iBAAiB,CAAC,CAAC;IAEpD,IAAI,qBAAqB,IAAI,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAChE,gDAAgD;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACvD,8DAA8D;QAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC/D,0BAA0B;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5C,WAAW,GAAG,IAAA,+BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE1D,IAAA,yBAAa,EAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,uCAAuC,YAAY,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,4FAA4F;AAC5F,+EAA+E;AAC/E,mCAAmC;AACnC,gBAAgB","sourcesContent":["import * as path from 'path';\r\nimport * as fs from 'fs';\r\n\r\nimport { getTmpCacheDir } from './getOrCreateDir';\r\nimport { writeTestCode } from './fileUtils';\r\n\r\nconst TESTFILEINFODIR = './failedVerifyResults';\r\nconst BUILDERRORDIRNAME = 'buildErrors';\r\nconst TESTERRORDIRNAME = 'testErrors';\r\nexport function writeFailedVerifyResult(sourceCodePath: string, genCnt: number, sourceCodeProjectPath: string, errorMessage: string, isBuildFailure: boolean) {\r\n const sourceFileName = path.basename(sourceCodePath, '.cs');\r\n let testFileName = `${sourceFileName}Tests${genCnt}.cs`;\r\n const errorSubDir = isBuildFailure ? BUILDERRORDIRNAME : TESTERRORDIRNAME;\r\n const classifiedFileDir = path.join(TESTFILEINFODIR, errorSubDir);\r\n let testFileDir = getTmpCacheDir(classifiedFileDir);\r\n \r\n if (sourceCodeProjectPath && fs.existsSync(sourceCodeProjectPath)) {\r\n // Get the directory containing the .csproj file\r\n const projectDir = path.dirname(sourceCodeProjectPath);\r\n // Get the relative path from project directory to source file\r\n const relativePath = path.relative(projectDir, sourceCodePath);\r\n // Parse the relative path\r\n const parsedPath = path.parse(relativePath);\r\n testFileDir = getTmpCacheDir(path.join(classifiedFileDir, parsedPath.dir));\r\n } \r\n \r\n const testFilePath = path.join(testFileDir, testFileName);\r\n \r\n writeTestCode(errorMessage, testFilePath);\r\n console.log(`Generated error message written to: ${testFilePath}`);\r\n}\r\n\r\n// writeFailedVerifyResult(\"Q:\\\\MyProject\\\\TestTestReport\\\\TestTestReport\\\\Multiply.cs\", 4,\r\n// \"Q:\\\\MyProject\\\\TestTestReport\\\\TestTestReport\\\\TestTestReport.csproj\",\r\n// \"Sample error message222\",\r\n// true);\r\n"]}
@@ -0,0 +1 @@
1
+ export declare function writeGenCode(sourceCodePath: string, genCode: string, genCnt: number, sourceCodeProjectPath: string): void;
@@ -0,0 +1,63 @@
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.writeGenCode = writeGenCode;
37
+ const path = __importStar(require("path"));
38
+ const fs = __importStar(require("fs"));
39
+ const getOrCreateDir_1 = require("./getOrCreateDir");
40
+ const fileUtils_1 = require("./fileUtils");
41
+ const TESTFILEDIR = './testFiles';
42
+ function writeGenCode(sourceCodePath, genCode, genCnt, sourceCodeProjectPath) {
43
+ const sourceFileName = path.basename(sourceCodePath, '.cs');
44
+ let testFileName = `${sourceFileName}Tests${genCnt}.cs`;
45
+ let testFileDir = (0, getOrCreateDir_1.getTmpCacheDir)(TESTFILEDIR);
46
+ if (sourceCodeProjectPath && fs.existsSync(sourceCodeProjectPath)) {
47
+ // Get the directory containing the .csproj file
48
+ const projectDir = path.dirname(sourceCodeProjectPath);
49
+ // Get the relative path from project directory to source file
50
+ const relativePath = path.relative(projectDir, sourceCodePath);
51
+ // Parse the relative path
52
+ const parsedPath = path.parse(relativePath);
53
+ testFileDir = (0, getOrCreateDir_1.getTmpCacheDir)(path.join(TESTFILEDIR, parsedPath.dir));
54
+ }
55
+ const testFilePath = path.join(testFileDir, testFileName);
56
+ (0, fileUtils_1.writeTestCode)(genCode, testFilePath);
57
+ console.log(`Generated code written to: ${testFilePath}`);
58
+ }
59
+ // writeGenCode("Q:\\MyProject\\TestTestReport\\TestTestReport\\TestFolder\\Summary.cs",
60
+ // "public class SummaryTests { }",
61
+ // 2,
62
+ // "Q:\\MyProject\\TestTestReport\\TestTestReport\\TestTestReport.csproj");
63
+ //# sourceMappingURL=writeGenCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeGenCode.js","sourceRoot":"","sources":["../../src/utils/writeGenCode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,oCAmBC;AA1BD,2CAA6B;AAC7B,uCAAyB;AAEzB,qDAAkD;AAClD,2CAA4C;AAE5C,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,SAAgB,YAAY,CAAC,cAAsB,EAAE,OAAe,EAAE,MAAc,EAAE,qBAA6B;IAC/G,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAC5D,IAAI,YAAY,GAAG,GAAG,cAAc,QAAQ,MAAM,KAAK,CAAC;IACxD,IAAI,WAAW,GAAG,IAAA,+BAAc,EAAC,WAAW,CAAC,CAAC;IAE9C,IAAI,qBAAqB,IAAI,EAAE,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAChE,gDAAgD;QAChD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACvD,8DAA8D;QAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC/D,0BAA0B;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC5C,WAAW,GAAG,IAAA,+BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE1D,IAAA,yBAAa,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,8BAA8B,YAAY,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,yFAAyF;AACzF,uCAAuC;AACvC,UAAU;AACV,gFAAgF","sourcesContent":["import * as path from 'path';\r\nimport * as fs from 'fs';\r\n\r\nimport { getTmpCacheDir } from './getOrCreateDir';\r\nimport { writeTestCode } from './fileUtils';\r\n\r\nconst TESTFILEDIR = './testFiles';\r\nexport function writeGenCode(sourceCodePath: string, genCode: string, genCnt: number, sourceCodeProjectPath: string) {\r\n const sourceFileName = path.basename(sourceCodePath, '.cs');\r\n let testFileName = `${sourceFileName}Tests${genCnt}.cs`;\r\n let testFileDir = getTmpCacheDir(TESTFILEDIR);\r\n\r\n if (sourceCodeProjectPath && fs.existsSync(sourceCodeProjectPath)) {\r\n // Get the directory containing the .csproj file\r\n const projectDir = path.dirname(sourceCodeProjectPath);\r\n // Get the relative path from project directory to source file\r\n const relativePath = path.relative(projectDir, sourceCodePath);\r\n // Parse the relative path\r\n const parsedPath = path.parse(relativePath);\r\n testFileDir = getTmpCacheDir(path.join(TESTFILEDIR, parsedPath.dir));\r\n }\r\n \r\n const testFilePath = path.join(testFileDir, testFileName);\r\n \r\n writeTestCode(genCode, testFilePath);\r\n console.log(`Generated code written to: ${testFilePath}`);\r\n}\r\n\r\n// writeGenCode(\"Q:\\\\MyProject\\\\TestTestReport\\\\TestTestReport\\\\TestFolder\\\\Summary.cs\",\r\n// \"public class SummaryTests { }\",\r\n// 2,\r\n// \"Q:\\\\MyProject\\\\TestTestReport\\\\TestTestReport\\\\TestTestReport.csproj\");"]}
@@ -0,0 +1,13 @@
1
+ export declare function runMsBuild(projectPath: string): Promise<any>;
2
+ export declare function buildErrorHandler(error: any): {
3
+ success: boolean;
4
+ };
5
+ export declare function buildCloseHandler(code: any, stdout: any, stderr: any): {
6
+ success: boolean;
7
+ message: string;
8
+ buildErrors: import("../types/buildResult").BuildResult[];
9
+ } | {
10
+ success: boolean;
11
+ message: any;
12
+ buildErrors: any;
13
+ };