@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.
- package/ai-dev-tools-csharp-copilot-core-0.0.19.tgz +0 -0
- package/azure-pipelines.yml +52 -0
- package/out/analyze/cecil.d.ts +1 -0
- package/out/analyze/cecil.js +42 -0
- package/out/analyze/cecil.js.map +1 -0
- package/out/analyze/checkCodeSyntax.d.ts +7 -0
- package/out/analyze/checkCodeSyntax.js +67 -0
- package/out/analyze/checkCodeSyntax.js.map +1 -0
- package/out/analyze/generateCodeDependency.d.ts +6 -0
- package/out/analyze/generateCodeDependency.js +122 -0
- package/out/analyze/generateCodeDependency.js.map +1 -0
- package/out/analyze/installAnalyzerTool.d.ts +1 -0
- package/out/analyze/installAnalyzerTool.js +82 -0
- package/out/analyze/installAnalyzerTool.js.map +1 -0
- package/out/atmpCache/deps/EplantRequestCategoryCondition_Conditions_Eplant_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +281 -0
- package/out/atmpCache/deps/IdentitySelectAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
- package/out/atmpCache/deps/SqmidHelperTests_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsTests_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
- package/out/atmpCache/deps/SqmidHelper_Utils_HttpRequestParser_Overview_Workflows_SharedSegmentsPlugins_SharedSegments_SharedSegments_CSServiceFundamental_code_D.deps +1 -0
- package/out/atmpCache/deps/ToListCountAnalyzerTests_ToListinatorTests_test_AIUnitTestExample_code_d.deps +4037 -0
- package/out/atmpCache/deps/ToListCountAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
- package/out/atmpCache/deps/ToListCountCodeFixProvider_ToListinatorCodeFixes_src_AIUnitTestExample_code_d.deps +1 -0
- package/out/atmpCache/deps/ToListForEachAnalyzer_ToListinatorAnalyzers_src_AIUnitTestExample_code_d.deps +1 -0
- package/out/atmpCache/dllref/ToListinatorTests_ToListinatorTests_test_AIUnitTestExample_code_d.dllref +202 -0
- package/out/batch/generateCodeTests.d.ts +6 -0
- package/out/batch/generateCodeTests.js +147 -0
- package/out/batch/generateCodeTests.js.map +1 -0
- package/out/batch/getFolderCodeFile.d.ts +1 -0
- package/out/batch/getFolderCodeFile.js +19 -0
- package/out/batch/getFolderCodeFile.js.map +1 -0
- package/out/batch/getProjectCodeFile.d.ts +4 -0
- package/out/batch/getProjectCodeFile.js +87 -0
- package/out/batch/getProjectCodeFile.js.map +1 -0
- package/out/batch/getSolutionCodeFile.d.ts +8 -0
- package/out/batch/getSolutionCodeFile.js +70 -0
- package/out/batch/getSolutionCodeFile.js.map +1 -0
- package/out/benchmark/formatToMarkdown.d.ts +2 -0
- package/out/benchmark/formatToMarkdown.js +101 -0
- package/out/benchmark/formatToMarkdown.js.map +1 -0
- package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
- package/out/benchmark/generateBenchmarkReport.js +82 -0
- package/out/benchmark/generateBenchmarkReport.js.map +1 -0
- package/out/codeCoverage/codeCoverage.d.ts +6 -0
- package/out/codeCoverage/codeCoverage.js +35 -0
- package/out/codeCoverage/codeCoverage.js.map +1 -0
- package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
- package/out/codeCoverage/codeCoverageReport.js +72 -0
- package/out/codeCoverage/codeCoverageReport.js.map +1 -0
- package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js +80 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.js +27 -0
- package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
- package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
- package/out/codeCoverage/reportTool.d.ts +2 -0
- package/out/codeCoverage/reportTool.js +22 -0
- package/out/codeCoverage/reportTool.js.map +1 -0
- package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
- package/out/codeCoverage/simplifyCoverageXml.js +116 -0
- package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
- package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
- package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
- package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
- package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
- package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
- package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
- package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
- package/out/codebk/childProcessManager.d.ts +1 -0
- package/out/codebk/childProcessManager.js +50 -0
- package/out/codebk/childProcessManager.js.map +1 -0
- package/out/codebk/msBuidSpawn.d.ts +1 -0
- package/out/codebk/msBuidSpawn.js +58 -0
- package/out/codebk/msBuidSpawn.js.map +1 -0
- package/out/codebk/msBuild.d.ts +1 -0
- package/out/codebk/msBuild.js +123 -0
- package/out/codebk/msBuild.js.map +1 -0
- package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
- package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
- package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
- package/out/codebk/old/xapGuideline-fm.liquid +149 -0
- package/out/codebk/old/xapGuideline.liquid +37 -0
- package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
- package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
- package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
- package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverage.js +54 -0
- package/out/codebk/oldExec/codeCoverage.js.map +1 -0
- package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverageReport.js +64 -0
- package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
- package/out/codebk/oldExec/containsMethods.d.ts +1 -0
- package/out/codebk/oldExec/containsMethods.js +74 -0
- package/out/codebk/oldExec/containsMethods.js.map +1 -0
- package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
- package/out/codebk/oldExec/generateCodeDependency.js +95 -0
- package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
- package/out/codebk/oldExec/msBuild.d.ts +1 -0
- package/out/codebk/oldExec/msBuild.js +53 -0
- package/out/codebk/oldExec/msBuild.js.map +1 -0
- package/out/codebk/oldExec/vsTest.d.ts +1 -0
- package/out/codebk/oldExec/vsTest.js +71 -0
- package/out/codebk/oldExec/vsTest.js.map +1 -0
- package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
- package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
- package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
- package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
- package/out/codebk/testbuildkill.d.ts +1 -0
- package/out/codebk/testbuildkill.js +37 -0
- package/out/codebk/testbuildkill.js.map +1 -0
- package/out/command/index.d.ts +2 -0
- package/out/command/index.js +85 -0
- package/out/command/index.js.map +1 -0
- package/out/command/utGenWrapper.d.ts +3 -0
- package/out/command/utGenWrapper.js +40 -0
- package/out/command/utGenWrapper.js.map +1 -0
- package/out/exit/childProcessManager.d.ts +2 -0
- package/out/exit/childProcessManager.js +43 -0
- package/out/exit/childProcessManager.js.map +1 -0
- package/out/exit/setupProcessSignalHandler.d.ts +1 -0
- package/out/exit/setupProcessSignalHandler.js +18 -0
- package/out/exit/setupProcessSignalHandler.js.map +1 -0
- package/out/gen/autoFix.d.ts +4 -0
- package/out/gen/autoFix.js +125 -0
- package/out/gen/autoFix.js.map +1 -0
- package/out/gen/csharpUtGen.d.ts +2 -0
- package/out/gen/csharpUtGen.js +151 -0
- package/out/gen/csharpUtGen.js.map +1 -0
- package/out/gen/ensureValidLLMResponse.d.ts +1 -0
- package/out/gen/ensureValidLLMResponse.js +19 -0
- package/out/gen/ensureValidLLMResponse.js.map +1 -0
- package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
- package/out/gen/postGen/extractCodeFromResponse.js +37 -0
- package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
- package/out/gen/postGen/postGenProcess.d.ts +1 -0
- package/out/gen/postGen/postGenProcess.js +36 -0
- package/out/gen/postGen/postGenProcess.js.map +1 -0
- package/out/gen/postGen/removeComments.d.ts +1 -0
- package/out/gen/postGen/removeComments.js +92 -0
- package/out/gen/postGen/removeComments.js.map +1 -0
- package/out/gen/postGen/removeSingleLines.d.ts +1 -0
- package/out/gen/postGen/removeSingleLines.js +28 -0
- package/out/gen/postGen/removeSingleLines.js.map +1 -0
- package/out/gen/postGen/repairRequiredNameSpaces.d.ts +1 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js +116 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
- package/out/gen/postGen/validateTestCode.d.ts +1 -0
- package/out/gen/postGen/validateTestCode.js +14 -0
- package/out/gen/postGen/validateTestCode.js.map +1 -0
- package/out/gen/preGen/excludeFileName.d.ts +1 -0
- package/out/gen/preGen/excludeFileName.js +49 -0
- package/out/gen/preGen/excludeFileName.js.map +1 -0
- package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
- package/out/gen/preGen/excludeSpecificTag.js +18 -0
- package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
- package/out/gen/preGen/preGenProcess.d.ts +1 -0
- package/out/gen/preGen/preGenProcess.js +22 -0
- package/out/gen/preGen/preGenProcess.js.map +1 -0
- package/out/gen/preGen/validateCode.d.ts +3 -0
- package/out/gen/preGen/validateCode.js +62 -0
- package/out/gen/preGen/validateCode.js.map +1 -0
- package/out/index.d.ts +2 -0
- package/out/index.js +8 -0
- package/out/index.js.map +1 -0
- package/out/llm/model/Gpt4o.d.ts +1 -0
- package/out/llm/model/Gpt4o.js +91 -0
- package/out/llm/model/Gpt4o.js.map +1 -0
- package/out/llm/model/claude4.d.ts +1 -0
- package/out/llm/model/claude4.js +3 -0
- package/out/llm/model/claude4.js.map +1 -0
- package/out/llm/preparePrompt.d.ts +2 -0
- package/out/llm/preparePrompt.js +110 -0
- package/out/llm/preparePrompt.js.map +1 -0
- package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
- package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
- package/out/llm/prompt/generateUtAutoFix.liquid +19 -0
- package/out/llm/prompt/generateUtDependency.liquid +3 -0
- package/out/llm/prompt/generateUtGuidelines.liquid +29 -0
- package/out/llm/prompt/generateUtSystem.liquid +5 -0
- package/out/llm/prompt/generateUtTemplate.liquid +30 -0
- package/out/llm/prompt/generateUtUserInput.liquid +4 -0
- package/out/llm/prompt/testAfGuidelines.liquid +6 -0
- package/out/llm/prompt/userCustomPrompt.liquid +0 -0
- package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
- package/out/llm/prompt/xap/xapUtGuideline-240804.liquid +36 -0
- package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
- package/out/llm/sendRequestToLLM.d.ts +4 -0
- package/out/llm/sendRequestToLLM.js +12 -0
- package/out/llm/sendRequestToLLM.js.map +1 -0
- package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
- package/out/llm/sendRequestToSelfHostLLM.js +41 -0
- package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
- package/out/metrics/appInsightTelemetry.d.ts +6 -0
- package/out/metrics/appInsightTelemetry.js +77 -0
- package/out/metrics/appInsightTelemetry.js.map +1 -0
- package/out/metrics/machineId.d.ts +11 -0
- package/out/metrics/machineId.js +85 -0
- package/out/metrics/machineId.js.map +1 -0
- package/out/setup/setup.d.ts +1 -0
- package/out/setup/setup.js +10 -0
- package/out/setup/setup.js.map +1 -0
- package/out/setup/setupConsole.d.ts +1 -0
- package/out/setup/setupConsole.js +23 -0
- package/out/setup/setupConsole.js.map +1 -0
- package/out/setup/setupLLMRequest.d.ts +2 -0
- package/out/setup/setupLLMRequest.js +10 -0
- package/out/setup/setupLLMRequest.js.map +1 -0
- package/out/tools/devenvcom.cmd +13 -0
- package/out/tools/devenvexe.cmd +13 -0
- package/out/tools/msbuildexe.cmd +13 -0
- package/out/tools/vstestexe.cmd +13 -0
- package/out/types/benchmark.d.ts +11 -0
- package/out/types/benchmark.js +3 -0
- package/out/types/benchmark.js.map +1 -0
- package/out/types/buildResult.d.ts +8 -0
- package/out/types/buildResult.js +3 -0
- package/out/types/buildResult.js.map +1 -0
- package/out/types/constants.d.ts +3 -0
- package/out/types/constants.js +7 -0
- package/out/types/constants.js.map +1 -0
- package/out/types/genResult.d.ts +10 -0
- package/out/types/genResult.js +3 -0
- package/out/types/genResult.js.map +1 -0
- package/out/types/testResult.d.ts +12 -0
- package/out/types/testResult.js +3 -0
- package/out/types/testResult.js.map +1 -0
- package/out/types/verifyResult.d.ts +8 -0
- package/out/types/verifyResult.js +3 -0
- package/out/types/verifyResult.js.map +1 -0
- package/out/utils/checkTestProject.d.ts +2 -0
- package/out/utils/checkTestProject.js +79 -0
- package/out/utils/checkTestProject.js.map +1 -0
- package/out/utils/checkXapCode.d.ts +2 -0
- package/out/utils/checkXapCode.js +59 -0
- package/out/utils/checkXapCode.js.map +1 -0
- package/out/utils/delay.d.ts +1 -0
- package/out/utils/delay.js +7 -0
- package/out/utils/delay.js.map +1 -0
- package/out/utils/detectTestFramework.d.ts +1 -0
- package/out/utils/detectTestFramework.js +32 -0
- package/out/utils/detectTestFramework.js.map +1 -0
- package/out/utils/fileUtils.d.ts +2 -0
- package/out/utils/fileUtils.js +42 -0
- package/out/utils/fileUtils.js.map +1 -0
- package/out/utils/generateCodeSha256.d.ts +1 -0
- package/out/utils/generateCodeSha256.js +46 -0
- package/out/utils/generateCodeSha256.js.map +1 -0
- package/out/utils/getCodeStructurePath.d.ts +5 -0
- package/out/utils/getCodeStructurePath.js +155 -0
- package/out/utils/getCodeStructurePath.js.map +1 -0
- package/out/utils/getOrCreateDir.d.ts +2 -0
- package/out/utils/getOrCreateDir.js +63 -0
- package/out/utils/getOrCreateDir.js.map +1 -0
- package/out/utils/getTestCodeInfo.d.ts +2 -0
- package/out/utils/getTestCodeInfo.js +121 -0
- package/out/utils/getTestCodeInfo.js.map +1 -0
- package/out/utils/getTestFile.d.ts +13 -0
- package/out/utils/getTestFile.js +295 -0
- package/out/utils/getTestFile.js.map +1 -0
- package/out/utils/parseBuildResult.d.ts +3 -0
- package/out/utils/parseBuildResult.js +44 -0
- package/out/utils/parseBuildResult.js.map +1 -0
- package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
- package/out/utils/parseSyntaxCheckResult.js +38 -0
- package/out/utils/parseSyntaxCheckResult.js.map +1 -0
- package/out/utils/parseVstestResult.d.ts +3 -0
- package/out/utils/parseVstestResult.js +61 -0
- package/out/utils/parseVstestResult.js.map +1 -0
- package/out/utils/removeFailedTestMethods.d.ts +3 -0
- package/out/utils/removeFailedTestMethods.js +207 -0
- package/out/utils/removeFailedTestMethods.js.map +1 -0
- package/out/utils/runCommand.d.ts +1 -0
- package/out/utils/runCommand.js +14 -0
- package/out/utils/runCommand.js.map +1 -0
- package/out/utils/spawnExec.d.ts +1 -0
- package/out/utils/spawnExec.js +80 -0
- package/out/utils/spawnExec.js.map +1 -0
- package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
- package/out/utils/verifyBuildErrorCausedFile.js +60 -0
- package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
- package/out/utils/verifyTestCode.d.ts +2 -0
- package/out/utils/verifyTestCode.js +25 -0
- package/out/utils/verifyTestCode.js.map +1 -0
- package/out/utils/writeGenCode.d.ts +1 -0
- package/out/utils/writeGenCode.js +50 -0
- package/out/utils/writeGenCode.js.map +1 -0
- package/out/vs/msBuild.d.ts +13 -0
- package/out/vs/msBuild.js +81 -0
- package/out/vs/msBuild.js.map +1 -0
- package/out/vs/vsTest.d.ts +15 -0
- package/out/vs/vsTest.js +107 -0
- package/out/vs/vsTest.js.map +1 -0
- package/out/vs/vsTools.d.ts +7 -0
- package/out/vs/vsTools.js +177 -0
- package/out/vs/vsTools.js.map +1 -0
- package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
- package/out/vsPlugin/interactionConstants.d.ts +2 -0
- package/out/vsPlugin/interactionConstants.js +10 -0
- package/out/vsPlugin/interactionConstants.js.map +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
- package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
- package/out/vsPlugin/stdListener.d.ts +3 -0
- package/out/vsPlugin/stdListener.js +57 -0
- package/out/vsPlugin/stdListener.js.map +1 -0
- package/package.json +33 -0
- package/tools/devenvcom.cmd +13 -0
- package/tools/devenvexe.cmd +13 -0
- package/tools/msbuildexe.cmd +13 -0
- package/tools/vstestexe.cmd +13 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
These guideline ONLY apply when the source code is a XAP class. Ignore all these rules for non-XAP classes.
|
|
2
|
+
### XAP code unit test Guideline
|
|
3
|
+
- XAP class introduction:
|
|
4
|
+
- inherits from one of the following interfaces: IPlugin, IConditionPlugin, Workflow, IExperiment, IPluginDataStore, IAsyncPlugin.
|
|
5
|
+
- implements an Execute method.
|
|
6
|
+
- Use ExecutionServices.CreateInstance<I{className}>() to create an instance of the XAP class, where the interface name is the class name prefixed with "I".
|
|
7
|
+
- For example, for a XAP class named SampleWorkflow, create the instance: **var sampleWorkflow = ExecutionServices.CreateInstance<ISampleWorkflow>()**.
|
|
8
|
+
- ExecutionServices.CreateInstance can only be used to create XAP class instances, MUST not be used to create non-XAP class instance.
|
|
9
|
+
- The parameters of the Execute method in XAP class instance is different with source code.
|
|
10
|
+
- The parameters with types: **PluginServices**, **PluginOutput<T>** or decorated with the **[ConfigFile("{configFileName}")]** attribute are deleted, try to mock these types is invalid and not allowed.
|
|
11
|
+
- For example, for a Execute definition of SampleWorkflow is: **PluginResult Execute(PluginServices ps, PluginOutput<Resp> resp, [ConfigFile("config.ini")] EplantConfig eplantConfig, OsResponse osResp = null, EplantRequest req = null)**, call the Execute with SampleWorkflow instance: **sampleWorkflow.Execute(Task.FromResult(osResp), Task.FromResult(req)).Result**.
|
|
12
|
+
- For the remaining parameters
|
|
13
|
+
- MUST ensure that the argument types in test code match the method's declared parameter types exactly.
|
|
14
|
+
- MUST keep the original order and be wrapped using Task.FromResult({value}).
|
|
15
|
+
- The parameters of type **PluginOutput<T>** in Execute method must be treated as method outputs
|
|
16
|
+
- MUST access the value of type PluginOutput<T> using XAP class instance with the **parameter name**.
|
|
17
|
+
- For example, one XAP class named SampleWorkflow, its Execute method signature: **Execute(PluginServices pluginServices, PluginOutput<Resp> pluginResp, Request req = null)**, SampleWorkflow instance is sampleWorkflow,use **sampleWorkflow.pluginResult** can get the output value.
|
|
18
|
+
- MUST get the fields of type **T** of **PluginOutput<T>** using **Result** property.
|
|
19
|
+
- For example, there's one field named **Key** of **Resp**, for PluginOutput<Resp> pluginOutput, **MUST** get **Key** using: **sampleWorkflow.pluginResp.Result.Key**.
|
|
20
|
+
- **MUST** assert the value of type **PluginOutput<T>**, example:
|
|
21
|
+
```
|
|
22
|
+
Assert.NotNull(sampleWorkflow.pluginResult.Result.Key);
|
|
23
|
+
Assert.AreEqual(sampleWorkflow.pluginResult.Result.Key, "key");
|
|
24
|
+
```
|
|
25
|
+
- Bond stucture will be used in XAP class, treat these structures as regular C# classes.
|
|
26
|
+
- MUST import bond namespaces when using bond structures in test code.
|
|
27
|
+
- Bond structure can import other bond structures using namespaces, get dependent structures definition from user input by name and treat all as regular C# class.
|
|
28
|
+
- MUST use ExecutionServices.CreateInstance<{bond structure name}>() to create an instance of bond structure.
|
|
29
|
+
- Bond structure fields without **optional** modifier is **required** and MUST ensure that all required fields are assigned valid non-null values in test code.
|
|
30
|
+
- For following bond structure, after creating the instance, MUST assign valid non-null value to all fields except **WalletContent**
|
|
31
|
+
```
|
|
32
|
+
struct EplantUser
|
|
33
|
+
{
|
|
34
|
+
1: uint64 Score;
|
|
35
|
+
2: int64 Created;
|
|
36
|
+
3: string Market;
|
|
37
|
+
4: vector<string> Trees;
|
|
38
|
+
5: EplantUserWeatherContent WeatherContent;
|
|
39
|
+
6: bool MergeNotifyWeather;
|
|
40
|
+
7: optional EplantUserWalletContent WalletContent;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
- One confusing example, for the required fields, there's still null checks in the source code, like **if (eplantUser?.Market == null)**. In this case, just test the case when eplantUser is null.
|
|
44
|
+
- MUST take care type convertion
|
|
45
|
+
- To convert IList type to IEnumerable type, must use AsEnumerable(), e.g. IEnumerable osResponses = osResponseList.AsEnumerable()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const tree_kill_1 = __importDefault(require("tree-kill"));
|
|
8
|
+
const msbuildCommand = `"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin\\amd64\\MSBuild.exe" "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj" /t:Build /m /nr:true /v:minimal`;
|
|
9
|
+
const child = (0, child_process_1.exec)(msbuildCommand);
|
|
10
|
+
const pid = child.pid;
|
|
11
|
+
// setTimeout(() => {
|
|
12
|
+
// console.log('Trying to kill...');
|
|
13
|
+
// // child.kill(); // 默认发送 SIGTERM(Windows 下为 TerminateProcess)
|
|
14
|
+
// treeKill(pid, (err) => {
|
|
15
|
+
// if (err) {
|
|
16
|
+
// console.error(`Failed to kill pid=${pid}:`, err.message);
|
|
17
|
+
// } else {
|
|
18
|
+
// console.log(`Killed pid=${pid}`);
|
|
19
|
+
// }
|
|
20
|
+
// });
|
|
21
|
+
// }, 30000);
|
|
22
|
+
// setTimeout(() => {
|
|
23
|
+
// console.log('exit...');
|
|
24
|
+
// }, 40000);
|
|
25
|
+
process.on('SIGINT', async () => {
|
|
26
|
+
console.log('🛑 SIGINT received (Ctrl+C)');
|
|
27
|
+
(0, tree_kill_1.default)(pid, (err) => {
|
|
28
|
+
if (err) {
|
|
29
|
+
console.error(`Failed to kill pid=${pid}:`, err.message);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log(`Killed pid=${pid}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// process.exit(0);
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=testbuildkill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testbuildkill.js","sourceRoot":"","sources":["../../src/codebk/testbuildkill.ts"],"names":[],"mappings":";;;;;AAAA,iDAA4C;AAE5C,0DAAiC;AAEjC,MAAM,cAAc,GAAG,iQAAiQ,CAAC;AACzR,MAAM,KAAK,GAAG,IAAA,oBAAI,EAAC,cAAc,CAAC,CAAC;AACnC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;AACtB,qBAAqB;AACrB,sCAAsC;AACtC,kEAAkE;AAClE,4BAA4B;AAC5B,yBAAyB;AACzB,4EAA4E;AAC5E,uBAAuB;AACvB,oDAAoD;AACpD,gBAAgB;AAChB,cAAc;AAGd,aAAa;AAEb,qBAAqB;AACrB,oCAAoC;AACpC,qBAAqB;AAGrB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC3C,IAAA,mBAAQ,EAAC,GAAG,EAAG,CAAC,GAAG,EAAE,EAAE;QACf,IAAI,GAAG,EAAE,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,sBAAsB,GAAG,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;IACL,CAAC,CAAC,CAAC;IACP,mBAAmB;AACvB,CAAC,CAAC,CAAC","sourcesContent":["import { exec, spawn } from 'child_process';\r\n\r\nimport treeKill from 'tree-kill';\r\n\r\nconst msbuildCommand = `\"C:\\\\Program Files\\\\Microsoft Visual Studio\\\\2022\\\\Enterprise\\\\MSBuild\\\\Current\\\\Bin\\\\amd64\\\\MSBuild.exe\" \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\" /t:Build /m /nr:true /v:minimal`;\r\nconst child = exec(msbuildCommand);\r\nconst pid = child.pid;\r\n// setTimeout(() => {\r\n// console.log('Trying to kill...');\r\n// // child.kill(); // 默认发送 SIGTERM(Windows 下为 TerminateProcess)\r\n// treeKill(pid, (err) => {\r\n// if (err) {\r\n// console.error(`Failed to kill pid=${pid}:`, err.message);\r\n// } else {\r\n// console.log(`Killed pid=${pid}`);\r\n// }\r\n// });\r\n \r\n \r\n// }, 30000);\r\n\r\n// setTimeout(() => {\r\n// console.log('exit...');\r\n// }, 40000);\r\n\r\n\r\nprocess.on('SIGINT', async () => {\r\n console.log('🛑 SIGINT received (Ctrl+C)');\r\n treeKill(pid, (err) => {\r\n if (err) {\r\n console.error(`Failed to kill pid=${pid}:`, err.message);\r\n } else {\r\n console.log(`Killed pid=${pid}`);\r\n }\r\n });\r\n // process.exit(0);\r\n});\r\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const utGenWrapper_1 = require("./utGenWrapper");
|
|
8
|
+
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
9
|
+
const helpers_1 = require("yargs/helpers");
|
|
10
|
+
const setupProcessSignalHandler_1 = require("../exit/setupProcessSignalHandler");
|
|
11
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelper.cs', '--keepFailedTest', "1", "--af", "1"];
|
|
12
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\Conditions\\EplantRequestCategoryCondition.cs', '--keepFailedTest', "1", "--af", "1"];
|
|
13
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\ResponseBuilders\\EplantMigrateResponseBuilder.cs', '--keepFailedTest', "1", "--af", "1"];
|
|
14
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Overview\\HttpRequestParser\\Utils\\WeatherParamsHttpConverter.cs', '--keepFailedTest', "1", "--af", "1"];
|
|
15
|
+
// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\RequestBuilders\\EplantRankRequestBuilder.cs', '--keepFailedTest', "1", "--af", "1"];
|
|
16
|
+
function main() {
|
|
17
|
+
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
18
|
+
// Yargs(hideBin(hardcodedArgs))
|
|
19
|
+
.scriptName('xap-ut')
|
|
20
|
+
.option('source', {
|
|
21
|
+
describe: 'where the test copilot is running',
|
|
22
|
+
choices: ['local', 'vsplugin'],
|
|
23
|
+
default: 'local',
|
|
24
|
+
type: 'string',
|
|
25
|
+
})
|
|
26
|
+
.option('mode', {
|
|
27
|
+
alias: 'm',
|
|
28
|
+
describe: 'test copilot work mode.', // Note: only generate is supported now
|
|
29
|
+
choices: ['generate', 'repair'],
|
|
30
|
+
default: 'generate',
|
|
31
|
+
type: 'string',
|
|
32
|
+
})
|
|
33
|
+
.option('keepFailedTest', {
|
|
34
|
+
describe: 'whether to keep failed test cases',
|
|
35
|
+
choices: [0, 1], // 0 means delete failed test cases, 1 means keep failed test cases
|
|
36
|
+
default: 1,
|
|
37
|
+
type: 'number',
|
|
38
|
+
})
|
|
39
|
+
.option('enableCov', {
|
|
40
|
+
describe: 'whether to run coverage',
|
|
41
|
+
choices: [0, 1], // 0 means not run coverage, 1 means run coverage
|
|
42
|
+
default: 0,
|
|
43
|
+
type: 'number',
|
|
44
|
+
})
|
|
45
|
+
.option('LLMModel', {
|
|
46
|
+
describe: 'use which LLM model', // Note: only gpt4o is supported now
|
|
47
|
+
default: "gpt4o",
|
|
48
|
+
type: 'string',
|
|
49
|
+
})
|
|
50
|
+
.option('sourceCodePath', {
|
|
51
|
+
alias: 's',
|
|
52
|
+
describe: 'source code file path / project path or solution path for batch generation',
|
|
53
|
+
type: 'string',
|
|
54
|
+
})
|
|
55
|
+
.option('testCodePath', {
|
|
56
|
+
alias: 't',
|
|
57
|
+
describe: 'Target file or directory',
|
|
58
|
+
type: 'string',
|
|
59
|
+
})
|
|
60
|
+
.option('autofix', {
|
|
61
|
+
alias: 'af',
|
|
62
|
+
describe: 'whether to auto fix generated test code',
|
|
63
|
+
choices: [0, 1], // 0 means not auto fix, 1 means auto fix
|
|
64
|
+
default: 0,
|
|
65
|
+
type: 'number',
|
|
66
|
+
})
|
|
67
|
+
.command('utcmd', 'Generate unit test using command line', () => { }, (c) => {
|
|
68
|
+
console.log('Command executed with options:', c);
|
|
69
|
+
(0, utGenWrapper_1.generateUtCode)(c);
|
|
70
|
+
})
|
|
71
|
+
.command('utbenchmark', 'Generate unit test report for all project/solution files using command line', () => { }, (c) => {
|
|
72
|
+
console.log('Command executed with options:', c);
|
|
73
|
+
(0, utGenWrapper_1.generateBatchUtCode)(c);
|
|
74
|
+
})
|
|
75
|
+
.command('utvsplugin', 'Generate unit test by interact with Visual Studio plugin', () => { }, (c) => {
|
|
76
|
+
console.log('Command executed with options:', c);
|
|
77
|
+
(0, utGenWrapper_1.generateUtWithVsPlugin)(c);
|
|
78
|
+
})
|
|
79
|
+
.help()
|
|
80
|
+
.alias('help', 'h')
|
|
81
|
+
.parse();
|
|
82
|
+
}
|
|
83
|
+
(0, setupProcessSignalHandler_1.setupSignalHandlers)();
|
|
84
|
+
main();
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/command/index.ts"],"names":[],"mappings":";;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AAQ;KACjB,CACJ;SACA,MAAM,CACH,cAAc,EACd;QACI,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,MAAM,CACH,SAAS,EACT;QACI,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,yCAAyC;QACnD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,yCAAyC;QAC1D,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,QAAQ;KACjB,CACJ;SACA,OAAO,CACJ,OAAO,EACP,uCAAuC,EACvC,GAAG,EAAE,GAAE,CAAC,EACR,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,6BAAc,EAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CACJ;SACA,OAAO,CACJ,aAAa,EACb,6EAA6E,EAC7E,GAAG,EAAE,GAAE,CAAC,EACR,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,kCAAmB,EAAC,CAAC,CAAC,CAAC;IAC3B,CAAC,CACJ;SACA,OAAO,CACJ,YAAY,EACZ,0DAA0D,EAC1D,GAAG,EAAE,GAAE,CAAC,EACR,CAAC,CAAC,EAAE,EAAE;QACF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACjD,IAAA,qCAAsB,EAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CACJ;SACA,IAAI,EAAE;SACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;SAClB,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,IAAA,+CAAmB,GAAE,CAAC;AACtB,IAAI,EAAE,CAAC","sourcesContent":["#!/usr/bin/env node\r\n\r\nimport { generateBatchUtCode, generateUtCode, generateUtWithVsPlugin } from './utGenWrapper';\r\n\r\nimport Yargs from 'yargs/yargs';\r\nimport { hideBin } from 'yargs/helpers';\r\nimport { setupSignalHandlers } from '../exit/setupProcessSignalHandler';\r\n\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\Conditions\\\\EplantRequestCategoryCondition.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\ResponseBuilders\\\\EplantMigrateResponseBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\WeatherParamsHttpConverter.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\n// const hardcodedArgs = ['', '', 'utcmd', '--s', 'D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs', '--keepFailedTest', \"1\", \"--af\", \"1\"];\r\nfunction main() {\r\n Yargs(hideBin(process.argv))\r\n // Yargs(hideBin(hardcodedArgs))\r\n .scriptName('xap-ut')\r\n .option(\r\n 'source',\r\n {\r\n describe: 'where the test copilot is running',\r\n choices: ['local', 'vsplugin'],\r\n default: 'local',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'mode',\r\n {\r\n alias: 'm',\r\n describe: 'test copilot work mode.', // Note: only generate is supported now\r\n choices: ['generate', 'repair'],\r\n default: 'generate',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'keepFailedTest',\r\n {\r\n describe: 'whether to keep failed test cases',\r\n choices: [0, 1], // 0 means delete failed test cases, 1 means keep failed test cases\r\n default: 1,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'enableCov',\r\n {\r\n describe: 'whether to run coverage',\r\n choices: [0, 1], // 0 means not run coverage, 1 means run coverage\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .option(\r\n 'LLMModel',\r\n {\r\n describe: 'use which LLM model', // Note: only gpt4o is supported now\r\n default: \"gpt4o\",\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'sourceCodePath',\r\n {\r\n alias: 's',\r\n describe: 'source code file path / project path or solution path for batch generation',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'testCodePath',\r\n {\r\n alias: 't',\r\n describe: 'Target file or directory',\r\n type: 'string',\r\n }\r\n )\r\n .option(\r\n 'autofix',\r\n {\r\n alias: 'af',\r\n describe: 'whether to auto fix generated test code',\r\n choices: [0, 1], // 0 means not auto fix, 1 means auto fix\r\n default: 0,\r\n type: 'number',\r\n }\r\n )\r\n .command(\r\n 'utcmd',\r\n 'Generate unit test using command line',\r\n () => {},\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtCode(c);\r\n }\r\n ) \r\n .command(\r\n 'utbenchmark',\r\n 'Generate unit test report for all project/solution files using command line',\r\n () => {},\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateBatchUtCode(c);\r\n }\r\n )\r\n .command(\r\n 'utvsplugin',\r\n 'Generate unit test by interact with Visual Studio plugin',\r\n () => {},\r\n (c) => {\r\n console.log('Command executed with options:', c);\r\n generateUtWithVsPlugin(c);\r\n }\r\n )\r\n .help()\r\n .alias('help', 'h')\r\n .parse();\r\n}\r\n\r\nsetupSignalHandlers();\r\nmain();"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateUtCode = generateUtCode;
|
|
4
|
+
exports.generateBatchUtCode = generateBatchUtCode;
|
|
5
|
+
exports.generateUtWithVsPlugin = generateUtWithVsPlugin;
|
|
6
|
+
const stdListener_1 = require("../vsPlugin/stdListener");
|
|
7
|
+
const constants_1 = require("../types/constants");
|
|
8
|
+
const generateCodeTests_1 = require("../batch/generateCodeTests");
|
|
9
|
+
const csharpUtGen_1 = require("../gen/csharpUtGen");
|
|
10
|
+
async function generateUtCode(c) {
|
|
11
|
+
const autofix = c.autofix === 1;
|
|
12
|
+
const keepFailedTest = c.keepFailedTest === 1;
|
|
13
|
+
await (0, csharpUtGen_1.generateCsharpUtCode)(c.sourceCodePath, c.testCodePath, autofix, keepFailedTest, constants_1.CSVSPLUGIN);
|
|
14
|
+
}
|
|
15
|
+
async function generateBatchUtCode(c) {
|
|
16
|
+
const autofix = c.autofix === 1;
|
|
17
|
+
const keepFailedTest = c.keepFailedTest === 1;
|
|
18
|
+
await (0, generateCodeTests_1.generateBatchTests)(c.sourceCodePath, autofix, keepFailedTest);
|
|
19
|
+
}
|
|
20
|
+
async function generateUtWithVsPlugin(c) {
|
|
21
|
+
try {
|
|
22
|
+
const autofix = c.autofix === 1;
|
|
23
|
+
if (autofix) {
|
|
24
|
+
(0, stdListener_1.startStdListener)();
|
|
25
|
+
}
|
|
26
|
+
const keepFailedTest = c.keepFailedTest === 1;
|
|
27
|
+
await (0, csharpUtGen_1.generateCsharpUtCode)(c.sourceCodePath, c.testCodePath, autofix, keepFailedTest, constants_1.CSVSPLUGIN, true);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error("Error generateUtWithVsPlugin:", error);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
// Ensure the listener is closed after processing
|
|
34
|
+
if (c.autofix === 1 && stdListener_1.readLineInterface) {
|
|
35
|
+
stdListener_1.readLineInterface.close();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// generateUtCode({sourceCodePath: "D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelper.cs", keepFailedTest: 1})
|
|
40
|
+
//# sourceMappingURL=utGenWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utGenWrapper.js","sourceRoot":"","sources":["../../src/command/utGenWrapper.ts"],"names":[],"mappings":";;AAMA,wCAIC;AAED,kDAIC;AAED,wDAgBC;AAlCD,yDAA8E;AAE9E,kDAAgD;AAChD,kEAAgE;AAChE,oDAA0D;AAEnD,KAAK,UAAU,cAAc,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC;IAChC,MAAM,cAAc,GAAG,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC;IAC9C,MAAM,IAAA,kCAAoB,EAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAU,CAAC,CAAC;AACtG,CAAC;AAEM,KAAK,UAAU,mBAAmB,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC;IAChC,MAAM,cAAc,GAAG,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC;IAC9C,MAAM,IAAA,sCAAkB,EAAC,CAAC,CAAC,cAAc,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;AACxE,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAAC,CAAC;IAC1C,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC;QAChC,IAAI,OAAO,EAAE,CAAC;YACV,IAAA,8BAAgB,GAAE,CAAC;QACvB,CAAC;QACD,MAAM,cAAc,GAAG,CAAC,CAAC,cAAc,KAAK,CAAC,CAAC;QAC9C,MAAM,IAAA,kCAAoB,EAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAU,EAAE,IAAI,CAAC,CAAC;IAC5G,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;YAAS,CAAC;QACP,iDAAiD;QACjD,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,IAAI,+BAAiB,EAAE,CAAC;YACvC,+BAAiB,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC;AACL,CAAC;AAGD,iNAAiN","sourcesContent":["import { readLineInterface, startStdListener } from \"../vsPlugin/stdListener\";\r\n\r\nimport { CSVSPLUGIN } from \"../types/constants\";\r\nimport { generateBatchTests } from \"../batch/generateCodeTests\";\r\nimport { generateCsharpUtCode } from \"../gen/csharpUtGen\";\r\n\r\nexport async function generateUtCode(c) {\r\n const autofix = c.autofix === 1;\r\n const keepFailedTest = c.keepFailedTest === 1;\r\n await generateCsharpUtCode(c.sourceCodePath, c.testCodePath, autofix, keepFailedTest, CSVSPLUGIN);\r\n}\r\n\r\nexport async function generateBatchUtCode(c) {\r\n const autofix = c.autofix === 1;\r\n const keepFailedTest = c.keepFailedTest === 1;\r\n await generateBatchTests(c.sourceCodePath, autofix, keepFailedTest);\r\n}\r\n\r\nexport async function generateUtWithVsPlugin(c) {\r\n try {\r\n const autofix = c.autofix === 1;\r\n if (autofix) {\r\n startStdListener();\r\n }\r\n const keepFailedTest = c.keepFailedTest === 1;\r\n await generateCsharpUtCode(c.sourceCodePath, c.testCodePath, autofix, keepFailedTest, CSVSPLUGIN, true);\r\n } catch (error) {\r\n console.error(\"Error generateUtWithVsPlugin:\", error);\r\n } finally {\r\n // Ensure the listener is closed after processing\r\n if (c.autofix === 1 && readLineInterface) {\r\n readLineInterface.close();\r\n }\r\n }\r\n}\r\n\r\n\r\n// generateUtCode({sourceCodePath: \"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs\", keepFailedTest: 1})"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.childProcessSet = void 0;
|
|
7
|
+
exports.killAllChildProcesses = killAllChildProcesses;
|
|
8
|
+
const tree_kill_1 = __importDefault(require("tree-kill"));
|
|
9
|
+
exports.childProcessSet = new Set();
|
|
10
|
+
function isProcessAlive(pid) {
|
|
11
|
+
try {
|
|
12
|
+
process.kill(pid, 0);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function killPidAsync(pid) {
|
|
20
|
+
return new Promise(async (resolve) => {
|
|
21
|
+
if (!isProcessAlive(pid)) {
|
|
22
|
+
console.log(`PID ${pid} already exited`);
|
|
23
|
+
return resolve();
|
|
24
|
+
}
|
|
25
|
+
console.log(`Killing child process with PID: ${pid}`);
|
|
26
|
+
(0, tree_kill_1.default)(pid, "SIGKILL", (err) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
console.error(`Failed to kill pid=${pid}:`, err.message);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log(`Killed pid=${pid}`);
|
|
32
|
+
}
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async function killAllChildProcesses() {
|
|
38
|
+
const pids = Array.from(exports.childProcessSet);
|
|
39
|
+
console.log('Killing all child processes: ' + pids.join(', '));
|
|
40
|
+
await Promise.all(pids.map((pid) => killPidAsync(pid)));
|
|
41
|
+
console.log('All child processes have been killed.');
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=childProcessManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childProcessManager.js","sourceRoot":"","sources":["../../src/exit/childProcessManager.ts"],"names":[],"mappings":";;;;;;AAgCA,sDAKC;AArCD,0DAAiC;AAEpB,QAAA,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjD,SAAS,cAAc,CAAC,GAAW;IAC/B,IAAI,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC7B,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACjC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,iBAAiB,CAAC,CAAC;YACzC,OAAO,OAAO,EAAE,CAAC;QACrB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;QACtD,IAAA,mBAAQ,EAAC,GAAG,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;YAC7B,IAAI,GAAG,EAAE,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,sBAAsB,GAAG,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAC7D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAEM,KAAK,UAAU,qBAAqB;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import treeKill from \"tree-kill\";\r\n\r\nexport const childProcessSet = new Set<number>();\r\n\r\nfunction isProcessAlive(pid: number): boolean {\r\n try {\r\n process.kill(pid, 0);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\nfunction killPidAsync(pid: number): Promise<void> {\r\n return new Promise(async (resolve) => {\r\n if (!isProcessAlive(pid)) {\r\n console.log(`PID ${pid} already exited`);\r\n return resolve();\r\n }\r\n \r\n console.log(`Killing child process with PID: ${pid}`);\r\n treeKill(pid, \"SIGKILL\", (err) => {\r\n if (err) {\r\n console.error(`Failed to kill pid=${pid}:`, err.message);\r\n } else {\r\n console.log(`Killed pid=${pid}`);\r\n }\r\n resolve();\r\n });\r\n });\r\n}\r\n\r\nexport async function killAllChildProcesses(): Promise<void> {\r\n const pids = Array.from(childProcessSet);\r\n console.log('Killing all child processes: ' + pids.join(', '));\r\n await Promise.all(pids.map((pid) => killPidAsync(pid)));\r\n console.log('All child processes have been killed.');\r\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setupSignalHandlers(): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupSignalHandlers = setupSignalHandlers;
|
|
4
|
+
const childProcessManager_1 = require("./childProcessManager");
|
|
5
|
+
const stdListener_1 = require("../vsPlugin/stdListener");
|
|
6
|
+
function setupSignalHandlers() {
|
|
7
|
+
process.on('SIGINT', async () => {
|
|
8
|
+
console.log('SIGINT received (Ctrl+C)');
|
|
9
|
+
await (0, childProcessManager_1.killAllChildProcesses)();
|
|
10
|
+
stdListener_1.readLineInterface?.close();
|
|
11
|
+
process.exit(0);
|
|
12
|
+
});
|
|
13
|
+
process.on('exit', () => {
|
|
14
|
+
childProcessManager_1.childProcessSet.clear();
|
|
15
|
+
console.log('Process exiting...');
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=setupProcessSignalHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupProcessSignalHandler.js","sourceRoot":"","sources":["../../src/exit/setupProcessSignalHandler.ts"],"names":[],"mappings":";;AAIA,kDAYC;AAhBD,+DAA+E;AAE/E,yDAA4D;AAE5D,SAAgB,mBAAmB;IAC/B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,IAAA,2CAAqB,GAAE,CAAC;QAC9B,+BAAiB,EAAE,KAAK,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,qCAAe,CAAC,KAAK,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { childProcessSet, killAllChildProcesses } from \"./childProcessManager\";\r\n\r\nimport { readLineInterface } from \"../vsPlugin/stdListener\";\r\n\r\nexport function setupSignalHandlers() {\r\n process.on('SIGINT', async () => {\r\n console.log('SIGINT received (Ctrl+C)');\r\n await killAllChildProcesses();\r\n readLineInterface?.close();\r\n process.exit(0);\r\n });\r\n\r\n process.on('exit', () => {\r\n childProcessSet.clear();\r\n console.log('Process exiting...');\r\n });\r\n}"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GenResult } from "../types/genResult";
|
|
2
|
+
export declare function autoFixTestCode(prompts: any[], sourceCodePath: string, testCode: string, testProjectPath: string, testFilePath: string, isXapCode: boolean, isVsPlugin: boolean, retryTimes?: number, isBenchmark?: boolean): Promise<GenResult>;
|
|
3
|
+
export declare function generateAutoFixCode(prompts: any[], generatedCode: string, errorMessage: string, isBuildFailure: boolean, testFilePath: string, isXapCode: boolean): Promise<string>;
|
|
4
|
+
export declare function autoRetryTestCode(prompts: any[], sourceCodePath: string, testCode: string, testProjectPath: string, testFilePath: string, isXapCode: boolean, retryTimes?: number): Promise<GenResult>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.autoFixTestCode = autoFixTestCode;
|
|
4
|
+
exports.generateAutoFixCode = generateAutoFixCode;
|
|
5
|
+
exports.autoRetryTestCode = autoRetryTestCode;
|
|
6
|
+
const checkCodeSyntax_1 = require("../analyze/checkCodeSyntax");
|
|
7
|
+
const ensureValidLLMResponse_1 = require("./ensureValidLLMResponse");
|
|
8
|
+
const postGenProcess_1 = require("./postGen/postGenProcess");
|
|
9
|
+
const preparePrompt_1 = require("../llm/preparePrompt");
|
|
10
|
+
const verifyBuildErrorCausedFile_1 = require("../utils/verifyBuildErrorCausedFile");
|
|
11
|
+
const verifyTestCode_1 = require("../utils/verifyTestCode");
|
|
12
|
+
const getVsPluginVerifyResult_1 = require("../vsPlugin/getVsPluginVerifyResult");
|
|
13
|
+
const writeGenCode_1 = require("../utils/writeGenCode");
|
|
14
|
+
const fileUtils_1 = require("../utils/fileUtils");
|
|
15
|
+
async function autoFixTestCode(prompts, sourceCodePath, testCode, testProjectPath, testFilePath, isXapCode, isVsPlugin, retryTimes = 3, isBenchmark = false) {
|
|
16
|
+
const startTime = Date.now();
|
|
17
|
+
let generatedCode = testCode;
|
|
18
|
+
let testResult;
|
|
19
|
+
let buildResult;
|
|
20
|
+
let errorMessage;
|
|
21
|
+
let isBuildFailure = true;
|
|
22
|
+
try {
|
|
23
|
+
for (let i = 0; i <= retryTimes; i++) {
|
|
24
|
+
// write generated code, to review and improve code quality
|
|
25
|
+
isBenchmark && (0, writeGenCode_1.writeGenCode)(sourceCodePath, generatedCode, i);
|
|
26
|
+
// for case: generatedCode is invalid, just retry instead of auto fix process
|
|
27
|
+
if (!generatedCode) {
|
|
28
|
+
console.error(`Generated code is invalid, try to regenerate. \nGenerated code: \n${generatedCode}`);
|
|
29
|
+
generatedCode = await (0, ensureValidLLMResponse_1.ensureValidLLMResponse)(prompts, isXapCode);
|
|
30
|
+
// extract valid code from LLM response
|
|
31
|
+
generatedCode = (0, postGenProcess_1.postGenProcess)(generatedCode, isXapCode);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
// analyze generated code issue before verify: build, because build will cost much time.
|
|
35
|
+
const syntaxResult = await (0, checkCodeSyntax_1.checkCodeSyntax)(testFilePath);
|
|
36
|
+
if (syntaxResult.success) {
|
|
37
|
+
// if generated code passed the syntax check, verify the generated test code
|
|
38
|
+
// const { success, message, buildErrors, vsTestResult } = await verifyTestCode(generatedCode, testProjectPath);
|
|
39
|
+
const verifyResult = await verifyGeneratedCode(generatedCode, testProjectPath, testFilePath, isVsPlugin);
|
|
40
|
+
errorMessage = verifyResult.message;
|
|
41
|
+
testResult = verifyResult.testResult;
|
|
42
|
+
buildResult = verifyResult.buildErrors;
|
|
43
|
+
isBuildFailure = !testResult;
|
|
44
|
+
// if build errors caused by other code files instead of generate test code, abort generation
|
|
45
|
+
const validBuildError = (0, verifyBuildErrorCausedFile_1.verifyBuildErrorCausedFile)(testFilePath, buildResult);
|
|
46
|
+
if (!validBuildError) {
|
|
47
|
+
console.error("Due to build errors caused by other code files, abort generation, please fix it first.");
|
|
48
|
+
return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };
|
|
49
|
+
}
|
|
50
|
+
if (verifyResult.success) {
|
|
51
|
+
console.log("XapUt code generated successfully");
|
|
52
|
+
return { success: true, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };
|
|
53
|
+
}
|
|
54
|
+
console.error("Failed to verifyTestCode, error:", errorMessage);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
buildResult = syntaxResult.buildErrors;
|
|
58
|
+
errorMessage = syntaxResult.message;
|
|
59
|
+
console.error("Failed to check the generated UT code syntax, error:", errorMessage);
|
|
60
|
+
}
|
|
61
|
+
// keep test failed tast cases in test file automatically
|
|
62
|
+
// if (!isBuildFailure && vsTestRes.passed !== 0) {
|
|
63
|
+
// console.log("remove failed test cases in test file");
|
|
64
|
+
// removeFailedTestCasesInTestFile(vsTestRes, testCodePath);
|
|
65
|
+
// return { success: true, testCode: generatedCode };
|
|
66
|
+
// }
|
|
67
|
+
if (i === retryTimes) {
|
|
68
|
+
console.error(`Failed to generate ut code after ${retryTimes} attempts.`);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
// case: vs plugin no response or msbuild/vstest failed.
|
|
72
|
+
if (!buildResult && !testResult) {
|
|
73
|
+
console.error("!!!Verify process failed, retrying...");
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
generatedCode = await generateAutoFixCode(prompts, generatedCode, errorMessage, isBuildFailure, testFilePath, isXapCode);
|
|
77
|
+
}
|
|
78
|
+
console.log(`Autofix time: ${(Date.now() - startTime) / 1000} seconds`);
|
|
79
|
+
return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error("Error during auto-fix process:", error);
|
|
83
|
+
return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult: null, testResult: null };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function verifyGeneratedCode(generatedCode, testProjectPath, testFilePath, isVsPlugin = false) {
|
|
87
|
+
if (isVsPlugin) {
|
|
88
|
+
const vsVerifyResult = await (0, getVsPluginVerifyResult_1.verifyTestCodeByVsPlugin)(testFilePath);
|
|
89
|
+
return vsVerifyResult;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// verifyResult: { success, message, buildErrors, vsTestResult }
|
|
93
|
+
const verifyResult = await (0, verifyTestCode_1.verifyTestCode)(generatedCode, testProjectPath);
|
|
94
|
+
return verifyResult;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function generateAutoFixCode(prompts, generatedCode, errorMessage, isBuildFailure, testFilePath, isXapCode) {
|
|
98
|
+
console.log("start auto-fix process...");
|
|
99
|
+
const autofixPrompt = (0, preparePrompt_1.prepareUtAutoFixPrompt)(prompts, generatedCode, errorMessage, isBuildFailure);
|
|
100
|
+
// get valid code from LLM response with retry
|
|
101
|
+
const newGeneratedCode = await (0, ensureValidLLMResponse_1.ensureValidLLMResponse)(autofixPrompt, isXapCode);
|
|
102
|
+
// if generate code is valid, write test code to test project
|
|
103
|
+
!!newGeneratedCode && (0, fileUtils_1.writeTestCode)(newGeneratedCode, testFilePath);
|
|
104
|
+
return newGeneratedCode;
|
|
105
|
+
}
|
|
106
|
+
// use for quick dev test
|
|
107
|
+
async function autoRetryTestCode(prompts, sourceCodePath, testCode, testProjectPath, testFilePath, isXapCode, retryTimes = 3) {
|
|
108
|
+
const startTime = Date.now();
|
|
109
|
+
let generatedCode = testCode;
|
|
110
|
+
let vsTestRes;
|
|
111
|
+
for (let i = 0; i <= retryTimes; i++) {
|
|
112
|
+
if (i === retryTimes) {
|
|
113
|
+
console.error(`Failed to generate XapUt code after ${retryTimes} attempts.`);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
const autofixPrompt = prompts;
|
|
117
|
+
// get valid code from LLM response
|
|
118
|
+
generatedCode = await (0, ensureValidLLMResponse_1.ensureValidLLMResponse)(autofixPrompt, isXapCode);
|
|
119
|
+
// write test code to test project
|
|
120
|
+
(0, fileUtils_1.writeTestCode)(generatedCode, testFilePath);
|
|
121
|
+
}
|
|
122
|
+
console.log(`Autofix time: ${(Date.now() - startTime) / 1000} seconds`);
|
|
123
|
+
return { success: true, testFilePath: testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult: null, testResult: vsTestRes };
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=autoFix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoFix.js","sourceRoot":"","sources":["../../src/gen/autoFix.ts"],"names":[],"mappings":";;AAcA,0CA2FC;AAkBD,kDAkBC;AAID,8CA6BC;AA5KD,gEAA6D;AAC7D,qEAAkE;AAElE,6DAA0D;AAC1D,wDAA8D;AAE9D,oFAAiF;AACjF,4DAAyD;AACzD,iFAA+E;AAC/E,wDAAqD;AACrD,kDAAmD;AAE5C,KAAK,UAAU,eAAe,CACjC,OAAc,EACd,cAAsB,EACtB,QAAgB,EAChB,eAAuB,EACvB,YAAoB,EACpB,SAAkB,EAClB,UAAmB,EACnB,aAAqB,CAAC,EACtB,cAAuB,KAAK;IAE5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,aAAa,GAAG,QAAQ,CAAC;IAC7B,IAAI,UAAU,CAAC;IACf,IAAI,WAAW,CAAC;IAChB,IAAI,YAAY,CAAC;IACjB,IAAI,cAAc,GAAG,IAAI,CAAC;IAC1B,IAAI,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,2DAA2D;YAC3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AC7B,IAAI,SAAS,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,uCAAuC,UAAU,YAAY,CAAC,CAAC;YAC7E,MAAM;QACV,CAAC;QAED,MAAM,aAAa,GAAG,OAAO,CAAC;QAC9B,mCAAmC;QACnC,aAAa,GAAG,MAAM,IAAA,+CAAsB,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACvE,kCAAkC;QAClC,IAAA,yBAAa,EAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC;IAExE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAClJ,CAAC","sourcesContent":["import { GenResult } from \"../types/genResult\";\r\nimport { VerifyResult } from \"../types/verifyResult\";\r\nimport { checkCodeSyntax } from \"../analyze/checkCodeSyntax\";\r\nimport { ensureValidLLMResponse } from \"./ensureValidLLMResponse\";\r\nimport { parseSyntaxCheckErrors } from \"../utils/parseSyntaxCheckResult\";\r\nimport { postGenProcess } from \"./postGen/postGenProcess\";\r\nimport { prepareUtAutoFixPrompt } from \"../llm/preparePrompt\";\r\nimport { sendRequestToLLM } from \"../llm/sendRequestToLLM\";\r\nimport { verifyBuildErrorCausedFile } from \"../utils/verifyBuildErrorCausedFile\";\r\nimport { verifyTestCode } from \"../utils/verifyTestCode\";\r\nimport { verifyTestCodeByVsPlugin } from \"../vsPlugin/getVsPluginVerifyResult\";\r\nimport { writeGenCode } from \"../utils/writeGenCode\";\r\nimport { writeTestCode } from \"../utils/fileUtils\";\r\n\r\nexport async function autoFixTestCode(\r\n prompts: any[],\r\n sourceCodePath: string,\r\n testCode: string,\r\n testProjectPath: string,\r\n testFilePath: string,\r\n isXapCode: boolean,\r\n isVsPlugin: boolean,\r\n retryTimes: number = 3,\r\n isBenchmark: boolean = false\r\n): Promise<GenResult> {\r\n const startTime = Date.now();\r\n\r\n let generatedCode = testCode;\r\n let testResult;\r\n let buildResult;\r\n let errorMessage;\r\n let isBuildFailure = true;\r\n try {\r\n for (let i = 0; i <= retryTimes; i++) {\r\n // write generated code, to review and improve code quality\r\n isBenchmark && writeGenCode(sourceCodePath, generatedCode, i);\r\n\r\n // for case: generatedCode is invalid, just retry instead of auto fix process\r\n if (!generatedCode) {\r\n console.error(`Generated code is invalid, try to regenerate. \\nGenerated code: \\n${generatedCode}`);\r\n generatedCode = await ensureValidLLMResponse(prompts, isXapCode);\r\n // extract valid code from LLM response\r\n generatedCode = postGenProcess(generatedCode, isXapCode);\r\n continue;\r\n }\r\n\r\n // analyze generated code issue before verify: build, because build will cost much time.\r\n const syntaxResult = await checkCodeSyntax(testFilePath);\r\n if (syntaxResult.success) {\r\n // if generated code passed the syntax check, verify the generated test code\r\n // const { success, message, buildErrors, vsTestResult } = await verifyTestCode(generatedCode, testProjectPath);\r\n const verifyResult = await verifyGeneratedCode(generatedCode, testProjectPath, testFilePath, isVsPlugin);\r\n errorMessage = verifyResult.message;\r\n testResult = verifyResult.testResult;\r\n buildResult = verifyResult.buildErrors;\r\n isBuildFailure = !testResult;\r\n \r\n // if build errors caused by other code files instead of generate test code, abort generation\r\n const validBuildError = verifyBuildErrorCausedFile(testFilePath, buildResult);\r\n if (!validBuildError) {\r\n console.error(\"Due to build errors caused by other code files, abort generation, please fix it first.\");\r\n return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };\r\n }\r\n \r\n if (verifyResult.success) {\r\n console.log(\"XapUt code generated successfully\");\r\n return { success: true, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };\r\n }\r\n\r\n console.error(\"Failed to verifyTestCode, error:\", errorMessage);\r\n } else {\r\n buildResult = syntaxResult.buildErrors;\r\n errorMessage = syntaxResult.message;\r\n console.error(\"Failed to check the generated UT code syntax, error:\", errorMessage);\r\n }\r\n\r\n // keep test failed tast cases in test file automatically\r\n // if (!isBuildFailure && vsTestRes.passed !== 0) {\r\n // console.log(\"remove failed test cases in test file\");\r\n // removeFailedTestCasesInTestFile(vsTestRes, testCodePath);\r\n // return { success: true, testCode: generatedCode };\r\n // }\r\n\r\n if (i === retryTimes) {\r\n console.error(`Failed to generate ut code after ${retryTimes} attempts.`);\r\n break;\r\n }\r\n\r\n // case: vs plugin no response or msbuild/vstest failed.\r\n if (!buildResult && !testResult) {\r\n console.error(\"!!!Verify process failed, retrying...\");\r\n continue;\r\n }\r\n\r\n generatedCode = await generateAutoFixCode(prompts, generatedCode, errorMessage, isBuildFailure, testFilePath, isXapCode);\r\n }\r\n\r\n console.log(`Autofix time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult, testResult };\r\n } catch (error) {\r\n console.error(\"Error during auto-fix process:\", error);\r\n return { success: false, testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult: null, testResult: null };\r\n\r\n }\r\n}\r\n\r\nasync function verifyGeneratedCode(\r\n generatedCode: string,\r\n testProjectPath: string,\r\n testFilePath: string,\r\n isVsPlugin: boolean = false\r\n): Promise<VerifyResult> {\r\n if (isVsPlugin) {\r\n const vsVerifyResult = await verifyTestCodeByVsPlugin(testFilePath);\r\n return vsVerifyResult;\r\n } else {\r\n // verifyResult: { success, message, buildErrors, vsTestResult }\r\n const verifyResult = await verifyTestCode(generatedCode, testProjectPath);\r\n return verifyResult;\r\n }\r\n}\r\n\r\nexport async function generateAutoFixCode(\r\n prompts: any[],\r\n generatedCode: string,\r\n errorMessage: string,\r\n isBuildFailure: boolean,\r\n testFilePath: string,\r\n isXapCode: boolean\r\n): Promise<string> {\r\n console.log(\"start auto-fix process...\");\r\n const autofixPrompt = prepareUtAutoFixPrompt(prompts, generatedCode, errorMessage, isBuildFailure);\r\n\r\n // get valid code from LLM response with retry\r\n const newGeneratedCode = await ensureValidLLMResponse(autofixPrompt, isXapCode);\r\n\r\n // if generate code is valid, write test code to test project\r\n !!newGeneratedCode && writeTestCode(newGeneratedCode, testFilePath);\r\n\r\n return newGeneratedCode;\r\n}\r\n\r\n\r\n// use for quick dev test\r\nexport async function autoRetryTestCode(\r\n prompts: any[],\r\n sourceCodePath: string,\r\n testCode: string,\r\n testProjectPath: string,\r\n testFilePath: string,\r\n isXapCode: boolean,\r\n retryTimes: number = 3\r\n): Promise<GenResult> {\r\n const startTime = Date.now();\r\n\r\n let generatedCode = testCode;\r\n let vsTestRes;\r\n for (let i = 0; i <= retryTimes; i++) {\r\n if (i === retryTimes) {\r\n console.error(`Failed to generate XapUt code after ${retryTimes} attempts.`);\r\n break;\r\n }\r\n\r\n const autofixPrompt = prompts;\r\n // get valid code from LLM response\r\n generatedCode = await ensureValidLLMResponse(autofixPrompt, isXapCode);\r\n // write test code to test project\r\n writeTestCode(generatedCode, testFilePath);\r\n }\r\n\r\n console.log(`Autofix time: ${(Date.now() - startTime) / 1000} seconds`);\r\n\r\n return { success: true, testFilePath: testFilePath, testProjectPath, codeFilePath: sourceCodePath, buildResult: null, testResult: vsTestRes };\r\n}"]}
|