Skip to content

Commit 7c0fa03

Browse files
authored
Merge pull request #14 from HSD-ESD/13-cancellation-of-simulation-works-not-properly
13 cancellation of simulation works not properly
2 parents 4c522d1 + 5300d2f commit 7c0fa03

File tree

5 files changed

+339
-202
lines changed

5 files changed

+339
-202
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## [1.0.4] - 2023-11-24
4+
- Bug-Fix: cancellation-request not working properly
5+
- Feature: execution-time of testcases
6+
- Feature: parametrized name of VUnit-run-script in VSCode-extension-settings
7+
- Feature: executing test-suites in GUI-Mode disabled by default
8+
9+
## [1.0.0] - 2023-06-12
10+
- First Release

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ The following configuration properties are available:
4545

4646
Property | Description
4747
--------------------------------------|---------------------------------------------------------------
48-
`vunit-by-hgb.python` | Path to python executable.
49-
`vunit-by-hgb.shellOptions` | VUnit run.py command line options when running tests.
50-
`vunit-by-hgb.guiOptions` | VUnit run.py command line options when running GUI (-g should not be added here).
51-
`vunit-by-hgb.exportJsonOptions` | VUnit run.py command line options when discovering test with --export-json.
52-
`vunit-by-hgb.matchProblems` | Display Errors and Warnings from VUnit as Problems
53-
`vunit-by-hgb.matchAssertionFailure` | Display Assertion-Failures from VUnit as Problems
48+
`vunit-by-hgb.scriptname` | consistent name of all VUnit-run-scripts (default: `run.py`)
49+
`vunit-by-hgb.python` | Path to python executable.
50+
`vunit-by-hgb.shellOptions` | VUnit run.py command line options when running tests.
51+
`vunit-by-hgb.guiOptions` | VUnit run.py command line options when running GUI (-g should not be added here).
52+
`vunit-by-hgb.exportJsonOptions` | VUnit run.py command line options when discovering test with --export-json.
53+
`vunit-by-hgb.showExecutionTime` | Display Execution-Time for every testcase
54+
`vunit-by-hgb.executeMultipleGuiTestcases` | Executing multiple GUI-Testcases at once
55+
`vunit-by-hgb.matchProblems` | Display Errors and Warnings from VUnit as Problems
56+
`vunit-by-hgb.matchAssertionFailure` | Display Assertion-Failures from VUnit as Problems
5457

5558
## Related Projects
56-
- HDLRegression is an alternative to VUnit. Use [HDLRegressionByHGB](https://github.com/HSD-ESD/HDLRegression-by-HGB)to run HDLRegression tests from the VS-Code sidebar. (currently under development)
59+
- HDLRegression is an alternative to VUnit. Use [HDLRegressionByHGB](https://github.com/HSD-ESD/HDLRegression-by-HGB) to run HDLRegression tests from the VS-Code sidebar. (currently under development)
5760

5861
## License
5962

package.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"publisher": "P2L2",
77
"license": "SEE LICENSE IN LICENSE",
88
"version": "1.0.3",
9-
"preview": true,
109
"icon": "img/vunit-by-hgb-logo.png",
1110
"repository": {
1211
"type": "git",
@@ -49,11 +48,11 @@
4948
"type": "object",
5049
"title": "VUnit by HGB",
5150
"properties": {
52-
"vunit-by-hgb.runpy": {
53-
"title": "run.py",
54-
"description": "Path to VUnit python script (run.py) relative to workspaceFolder.",
51+
"vunit-by-hgb.scriptname": {
52+
"title": "Script-Name",
53+
"description": "Default name for VUnit-Scripts",
5554
"type": "string",
56-
"scope": "window"
55+
"default": "run.py"
5756
},
5857
"vunit-by-hgb.python": {
5958
"title": "Python executable",
@@ -76,6 +75,16 @@
7675
"type": "string",
7776
"default": ""
7877
},
78+
"vunit-by-hgb.showExecutionTime": {
79+
"description": "Display Execution-Time for every testcase",
80+
"type": "boolean",
81+
"default": true
82+
},
83+
"vunit-by-hgb.executeMultipleGuiTestcases": {
84+
"description": "Executing multiple GUI-Testcases at once",
85+
"type": "boolean",
86+
"default": false
87+
},
7988
"vunit-by-hgb.matchProblems": {
8089
"description": "Display Errors and Warnings from VUnit as Problems",
8190
"type": "boolean",

src/VUnit/VUnit.ts

+28-54
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export class VUnit {
4949
this.mOutputChannel = vscode.window.createOutputChannel("VUnitByHGB.VUnit");
5050
}
5151

52-
public async GetVunitVersion(runPy : string): Promise<string> {
52+
public async GetVersion(vunitScript : string): Promise<string> {
5353
return new Promise((resolve, reject) => {
5454
let version: string | undefined;
55-
this.RunVunit(runPy, ['--version'], (vunit: ChildProcess): void => {
55+
this.Run(vunitScript, ['--version'], (vunit: ChildProcess): void => {
5656
let proc: any = vunit;
5757
readline
5858
.createInterface({
@@ -75,21 +75,32 @@ export class VUnit {
7575
});
7676
}
7777

78-
public async FindRunPy(
79-
workspaceFolder: vscode.WorkspaceFolder
80-
): Promise<string[]> {
78+
public async FindScripts(workspaceFolder : vscode.WorkspaceFolder): Promise<string[]>
79+
{
80+
const vunitScriptName : string | undefined = vscode.workspace.getConfiguration().get("vunit-by-hgb.scriptname");
81+
let vunitScripts: string[] = new Array<string>();
82+
83+
if (!vunitScriptName)
84+
{
85+
return vunitScripts;
86+
}
87+
8188
let results = await vscode.workspace.findFiles(
82-
new vscode.RelativePattern(workspaceFolder, '**/run.py'),
89+
new vscode.RelativePattern(workspaceFolder, `**/${vunitScriptName}`),
8390
'**/{vunit,examples,acceptance/artificial}/{vhdl,verilog}'
8491
);
85-
let runPy: string[] = results.map((file) => {
92+
93+
vunitScripts = results.map((file) => {
8694
return file.fsPath;
8795
});
88-
return runPy;
96+
97+
vunitScripts.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
98+
99+
return vunitScripts;
89100
}
90101

91-
public async RunVunit(
92-
runPy: string,
102+
public async Run(
103+
vunitScript: string,
93104
vunitArgs: string[],
94105
vunitProcess: (vunit: ChildProcess) => void = () => {}
95106
): Promise<string> {
@@ -98,22 +109,22 @@ export class VUnit {
98109
return new Promise((resolve, reject) => {
99110
if (!this.GetWorkspaceRoot()) {
100111
return reject(new Error('Workspace root not defined.'));
101-
} else if (!runPy) {
112+
} else if (!vunitScript) {
102113
return reject(
103114
new Error('Unable to determine path of VUnit run script.')
104115
);
105-
} else if (!fs.existsSync(runPy)) {
106-
return reject(Error(`VUnit run script ${runPy} does not exist.`));
116+
} else if (!fs.existsSync(vunitScript)) {
117+
return reject(Error(`VUnit run script ${vunitScript} does not exist.`));
107118
}
108119
const python = vscode.workspace
109120
.getConfiguration()
110121
.get('vunit-by-hgb.python') as string;
111-
const args = ['"' + runPy + '"'].concat(vunitArgs);
122+
const args = ['"' + vunitScript + '"'].concat(vunitArgs);
112123
this.mOutputChannel.appendLine('');
113124
this.mOutputChannel.appendLine('===========================================');
114125
this.mOutputChannel.appendLine('Running VUnit: ' + python + ' ' + args.join(' '));
115126
let vunit = spawn(python, args, {
116-
cwd: path.dirname(runPy),
127+
cwd: path.dirname(vunitScript),
117128
shell: true,
118129
});
119130
vunit.on('close', (code) => {
@@ -144,44 +155,7 @@ export class VUnit {
144155
return "";
145156
}
146157

147-
public async GetRunPy(): Promise<string> {
148-
return new Promise((resolve, reject) => {
149-
const workspaceFolder = (vscode.workspace.workspaceFolders || [])[0];
150-
if (!workspaceFolder) {
151-
return reject(
152-
new Error('No workspace folder open when getting run.py')
153-
);
154-
}
155-
156-
const runPyConf = vscode.workspace
157-
.getConfiguration()
158-
.get('vunit-by-hgb.runpy');
159-
if (runPyConf) {
160-
resolve(path.join(workspaceFolder.uri.fsPath, runPyConf as string));
161-
} else if (vscode.workspace.getConfiguration().get('vunit-by-hgb.findRunPy')) {
162-
this.FindRunPy(workspaceFolder).then((res) => {
163-
if (res.length === 0) {
164-
reject(new Error('run.py not found or configured.'));
165-
} else if (res.length === 1) {
166-
resolve(res[0]);
167-
} else {
168-
reject(
169-
new Error(
170-
'Multiple run.py files found in workspace (' +
171-
res.join(', ') +
172-
').'
173-
)
174-
);
175-
}
176-
});
177-
} else {
178-
reject('run.py not found');
179-
}
180-
});
181-
}
182-
183-
public async GetVunitData(workDir: string, runPy:string): Promise<VunitExportData> {
184-
//const runPyDirectory : string = path.dirname(runPy);
158+
public async GetData(workDir: string, vunitScript:string): Promise<VunitExportData> {
185159
const vunitJson = path.join(workDir, `${uuid()}.json`);
186160
fs.mkdirSync(path.dirname(vunitJson), { recursive: true });
187161

@@ -196,7 +170,7 @@ export class VUnit {
196170

197171
let vunitProcess : any;
198172

199-
await this.RunVunit(runPy, options, (vunit: ChildProcess) => {
173+
await this.Run(vunitScript, options, (vunit: ChildProcess) => {
200174

201175
vunitProcess = vunit;
202176

0 commit comments

Comments
 (0)