1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
import { Ctx, Cmd } from './ctx';
import { execFile, spawnSync } from 'child_process';
import { LanguageClient } from 'vscode-languageclient/node';
import path = require('path');
import { getDebugConfiguration } from './debug';
import { getPathForExecutable } from './toolchain';
import { promises as fs, PathLike, constants, writeFileSync} from "fs";
export function runDebugTest(ctx: Ctx): Cmd {
return async(debugConfig: any) => {
const fn = debugConfig.function;
const cwd = debugConfig.cwd;
const pkg = path.basename(cwd);
var args = [];
args.push("test");
args.push(cwd);
args.push(`-test-name:${fn}`);
args.push("-debug");
for(var i = 0; i < ctx.config.collections.length; i++) {
const name = ctx.config.collections[i].name;
const path = ctx.config.collections[i].path;
if(name === "core") {
continue;
}
args.push(`-collection:${name}=${path}`);
}
const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
if(workspaceFolder === undefined) {
return;
}
const odinExecution = execFile("odin", args, {cwd : workspaceFolder}, (err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage(err.message);
}
});
const executableName = path.join(workspaceFolder, pkg);
odinExecution.on("exit", (code) => {
if(code !== 0) {
throw Error("Odin test failed!");
}
vscode.debug.startDebugging(undefined, getDebugConfiguration(ctx.config, executableName)).then(r => console.log("Result", r));
});
};
}
export function runTest(ctx: Ctx): Cmd {
return async(debugConfig: any) => {
const fn = debugConfig.function;
const cwd = debugConfig.cwd;
const pkg = path.basename(cwd);
var args = [];
args.push("test");
args.push(cwd);
args.push(`-test-name:${fn}`);
for(var i = 0; i < ctx.config.collections.length; i++) {
const name = ctx.config.collections[i].name;
const path = ctx.config.collections[i].path;
if(name === "core") {
continue;
}
args.push(`-collection:${name}=${path}`);
}
const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
if(workspaceFolder === undefined) {
return;
}
var definition = {
type: "shell",
command: "run",
args: args,
cwd: workspaceFolder,
};
const shellExec = new vscode.ShellExecution("odin", args, { cwd: workspaceFolder});
const target = vscode.workspace.workspaceFolders![0];
var task = new vscode.Task(definition, target, "Run Test", "odin", shellExec);
vscode.tasks.executeTask(task);
};
}
|