Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Initial work for generating a report and exiting when finished #2358

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
24 changes: 23 additions & 1 deletion src/testing/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -117,6 +122,23 @@ async function runTests() {
testSuitesTreeProvider.refresh(suite);
}
}

if (report_and_exit) {
const connectionDetail = {
system: connection.currentHost,
user: connection.currentUser,
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) {
Expand Down