Skip to content

Commit 8fedba1

Browse files
committed
Fix UT vscode
1 parent 285d8b3 commit 8fedba1

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"request": "launch",
1111
"runtimeExecutable": "${execPath}",
1212
"env": {
13-
// "ANALYZER_4D_PATH":""
13+
"ANALYZER_4D_PATH":"",
14+
"TOOL4D_DOWNLOAD":"false"
1415
},
1516
"args": [
1617
"--extensionDevelopmentPath=${workspaceFolder}/editor",

editor/src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as lc from "vscode-languageclient/node";
77
import { Ctx } from "./ctx";
88
import { LabeledVersion } from './labeledVersion';
99
import { InfoPlistManager } from './infoplist';
10+
import { Logger } from './logger';
1011

1112
export class Config {
1213

@@ -60,6 +61,10 @@ export class Config {
6061
}
6162

6263
public IsTool4DEnabled(): boolean {
64+
if(process.env["TOOL4D_DOWNLOAD"]!=undefined)
65+
{
66+
return process.env["TOOL4D_DOWNLOAD"] == 'true';
67+
}
6368
return this._tool4dEnableFromSettings;
6469
}
6570

@@ -101,7 +106,7 @@ export class Config {
101106

102107
private get _serverPath() {
103108
const p = this._serverPathFromSettings;
104-
if (this._tool4dEnableFromSettings) {
109+
if (this.IsTool4DEnabled()) {
105110
return this._tool4DPath;
106111
}
107112
return p;

editor/src/test/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ export function run(): Promise<void> {
2828
return reject(err);
2929
}
3030

31+
3132
// Add files to the test suite
3233
files.filter(f => {
33-
34+
if(!currentVersion)
35+
return true;
3436
const versionFile = tests[f] ? tests[f] : currentVersion;
35-
console.log(f, versionFile, currentVersion, compareVersion(currentVersion, versionFile));
3637
return compareVersion(currentVersion, versionFile) >= 0;
3738
})
3839
.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

editor/src/test/runTest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ async function main() {
1515
// The path to test runner
1616
// Passed to --extensionTestsPath
1717
const extensionTestsPath = path.resolve(__dirname, './index');
18-
//process.env.ANALYZER_4D_PATH=process.env["ANALYZER_4D_PATH"]
1918
// Download VS Code, unzip it and run the integration test
2019
await runTests({ extensionDevelopmentPath, extensionTestsPath });
2120
} catch (err) {

editor/src/test/toolDownload.test.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ import * as assert from 'assert';
66
import * as vscode from 'vscode';
77
import * as fs from "fs";
88

9+
function prepareTargetFolder(inTarget)
10+
{
11+
if(fs.existsSync(inTarget)) {
12+
fs.rmSync(inTarget, {recursive:true});
13+
}
14+
fs.mkdirSync(inTarget);
15+
}
16+
917
//https://resources-download.4d.com/release/20.x/latest/latest/win/tool4d_win.tar.xz?debug
1018
suite('Download tool', () => {
1119
const downloadPath = getDocPath("Download");
12-
if(fs.existsSync(downloadPath)) {
13-
fs.rmSync(downloadPath, {recursive:true});
14-
}
15-
fs.mkdirSync(downloadPath);
1620

1721
const ext = vscode.extensions.getExtension('4D.4d-analyzer')!;
1822
test('Tool download stable', async () => {
23+
prepareTargetFolder(downloadPath);
24+
1925
let number = 21;
2026
await ext.activate();
2127

@@ -41,8 +47,9 @@ suite('Download tool', () => {
4147
}
4248
await testDownloadLTS(downloadPath, lastVersionAvailable, "stable");
4349
});
44-
4550
test('Tool download beta', async () => {
51+
prepareTargetFolder(downloadPath);
52+
4653
let number = 21;
4754
await ext.activate();
4855

@@ -61,7 +68,6 @@ suite('Download tool', () => {
6168
const lastVersionAvailable = await requestLabelVersion(`https://resources-download.4d.com/release/${number} Rx/latest/latest/win/tool4d_win.tar.xz?channel=beta`, "beta")
6269
lastVersionAvailable.changelist = 0;
6370

64-
6571
await testDownloadR(downloadPath, lastVersionAvailable, "beta");
6672
if (lastVersionAvailable.releaseVersion >= 2) {
6773
await testDownloadRVersion(downloadPath, lastVersionAvailable, "beta");
@@ -82,8 +88,7 @@ async function testDownloadR(downloadPath: string, labeledVersion: LabeledVersio
8288
assert(result.currentVersion.releaseVersion === labeledVersion.releaseVersion);
8389
assert(result.currentVersion.changelist > 0);
8490
} catch (e) {
85-
console.log("ERROR", e);
86-
assert(false);
91+
assert(false, e);
8792
}
8893
}
8994
else //If We are a 20R2
@@ -93,7 +98,7 @@ async function testDownloadR(downloadPath: string, labeledVersion: LabeledVersio
9398
const result = await toolPreparator.prepareLastToolWithoutProgress(downloadPath, false);
9499
assert(false);
95100
} catch (e) {
96-
assert(true);
101+
assert(true, e);
97102
}
98103
}
99104
}
@@ -107,7 +112,7 @@ async function testDownloadRVersion(downloadPath: string, labeledVersion: Labele
107112
assert(result.currentVersion.releaseVersion === labeledVersion.releaseVersion);
108113
assert(result.currentVersion.changelist > 0);
109114
} catch (e) {
110-
assert(false);
115+
assert(false, e);
111116
}
112117
}
113118

@@ -121,7 +126,7 @@ async function testDownloadLTS(downloadPath: string, labeledVersion: LabeledVers
121126
assert(result.currentVersion.releaseVersion === 0);
122127
assert(result.currentVersion.changelist > 0);
123128
} catch (e) {
124-
assert(false);
129+
assert(false, e);
125130
}
126131
}
127132
else //If We are a 20R2

0 commit comments

Comments
 (0)