From 4358d159d9855367cd42ef755e500e0dd66b4439 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Wed, 20 Nov 2024 10:36:40 -0500 Subject: [PATCH 1/2] Initial work for generating a report and exiting when finished Signed-off-by: worksofliam --- .vscode/launch.json | 17 +++++++++++++++++ src/sandbox.ts | 3 ++- src/testing/index.ts | 24 +++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index e7a30837e..78cb12fd7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -34,6 +34,23 @@ "testing": "true" } }, + { + "name": "Extension Tests (Report)", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "outFiles": [ + "${workspaceFolder}/dist/**/*.js" + ], + "sourceMaps": true, + "preLaunchTask": "${defaultBuildTask}", + "env": { + "testing": "true", + "report_and_exit": "/Users/barry/Repos/vscode-ibmi/report.json" + } + }, { "name": "Extension Tests (Individual)", "type": "extensionHost", diff --git a/src/sandbox.ts b/src/sandbox.ts index 818760f29..64e041eca 100644 --- a/src/sandbox.ts +++ b/src/sandbox.ts @@ -103,6 +103,7 @@ export async function handleStartup() { let server: string | undefined = env.SANDBOX_SERVER; let username: string | undefined = env.SANDBOX_USER; let password: string | undefined = env.SANDBOX_PASS; + let reloadSettings: boolean = env.SANDBOX_RELOAD_SETTINGS === `true`; // If Sandbox mode is enabled, then the server and username can be inherited from the branch name if (env.VSCODE_IBMI_SANDBOX) { @@ -155,7 +156,7 @@ export async function handleStartup() { }); } - const connectionResult = await commands.executeCommand(`code-for-ibmi.connectDirect`, connectionData); + const connectionResult = await commands.executeCommand(`code-for-ibmi.connectDirect`, connectionData, reloadSettings); if (connectionResult) { await initialSetup(connectionData.username); diff --git a/src/testing/index.ts b/src/testing/index.ts index b4c76b3c3..de0d6127b 100644 --- a/src/testing/index.ts +++ b/src/testing/index.ts @@ -1,5 +1,7 @@ import { env } from "process"; -import vscode from "vscode"; +import vscode, { commands } from "vscode"; +import path from "path"; +import fs from "fs"; import { instance } from "../instantiate"; import { ActionSuite } from "./action"; import { ComponentSuite } from "./components"; @@ -49,6 +51,7 @@ export interface TestCase { const testingEnabled = env.testing === `true`; const testIndividually = env.individual === `true`; +const report_and_exit = env.report_and_exit !== undefined ? env.report_and_exit : undefined; let testSuitesTreeProvider: TestSuitesTreeProvider; export function initialise(context: vscode.ExtensionContext) { @@ -81,6 +84,8 @@ export function initialise(context: vscode.ExtensionContext) { } async function runTests() { + const connection = instance.getConnection()!; + for (const suite of suites) { try { suite.status = "running"; @@ -117,6 +122,23 @@ async function runTests() { testSuitesTreeProvider.refresh(suite); } } + + if (report_and_exit) { + const connectionDetail = { + system: connection.currentConnectionName, + user: connection.currentConnectionName, + ccsids: connection.getCcsids(), + variants: connection.variantChars + }; + + const contents = { + connection: connectionDetail, + suites, + } + fs.writeFileSync(report_and_exit, JSON.stringify(contents)); + console.log(`vscode-ibmi test report written to ${report_and_exit}`); + commands.executeCommand(`workbench.action.closeWindow`); + } } async function runTest(test: TestCase) { From 3395a8d0a629eda6c840bb83c62de8ca3a18cf4d Mon Sep 17 00:00:00 2001 From: worksofliam Date: Wed, 20 Nov 2024 20:48:07 -0500 Subject: [PATCH 2/2] Use correct props for connection detail Signed-off-by: worksofliam --- src/testing/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testing/index.ts b/src/testing/index.ts index de0d6127b..d3e2f70f1 100644 --- a/src/testing/index.ts +++ b/src/testing/index.ts @@ -125,8 +125,8 @@ async function runTests() { if (report_and_exit) { const connectionDetail = { - system: connection.currentConnectionName, - user: connection.currentConnectionName, + system: connection.currentHost, + user: connection.currentUser, ccsids: connection.getCcsids(), variants: connection.variantChars };