15
15
const { defineConfig } = require ( "@vscode/test-cli" ) ;
16
16
const path = require ( "path" ) ;
17
17
const { version, publisher, name } = require ( "./package.json" ) ;
18
- const { preview } = require ( "./scripts/versions" ) ;
19
18
20
19
const isCIBuild = process . env [ "CI" ] === "1" ;
21
20
const isFastTestRun = process . env [ "FAST_TEST_RUN" ] === "1" ;
@@ -41,51 +40,67 @@ if (dataDir) {
41
40
if ( process . platform === "darwin" && process . arch === "x64" ) {
42
41
launchArgs . push ( "--disable-gpu" ) ;
43
42
}
44
- const isStableRun = process . env [ "VSCODE_VERSION" ] !== "insiders" ;
43
+
44
+ const installExtensions = [ ] ;
45
+ let vsixPath = process . env [ "VSCODE_SWIFT_VSIX" ] ;
45
46
let versionStr = version ;
46
- if ( ! isStableRun ) {
47
- const segments = version . split ( "." ) . map ( v => parseInt ( v , 10 ) ) ;
48
- versionStr = preview ( { major : segments [ 0 ] , minor : segments [ 1 ] , patch : segments [ 2 ] } ) ;
49
- }
50
- let vsixPath = isStableRun
51
- ? process . env [ "VSCODE_SWIFT_VSIX" ]
52
- : process . env [ "VSCODE_SWIFT_PRERELEASE_VSIX" ] ;
53
- const install = [ ] ;
54
- const installExtensions = [ "vadimcn.vscode-lldb" , "llvm-vs-code-extensions.lldb-dap" ] ;
47
+ let extensionDevelopmentPath ;
55
48
if ( vsixPath ) {
49
+ // https://github.com/swiftlang/vscode-swift/issues/1751
50
+ // Will install extensions before CI tests run
51
+ installExtensions . push ( "vadimcn.vscode-lldb" , "llvm-vs-code-extensions.lldb-dap" ) ;
52
+
53
+ // Absolute path to vsix needed
56
54
if ( ! path . isAbsolute ( vsixPath ) ) {
57
55
vsixPath = path . join ( __dirname , vsixPath ) ;
58
56
}
59
- console . log ( "Installing " + vsixPath ) ;
57
+ console . log ( "Installing VSIX " + vsixPath ) ;
60
58
installExtensions . push ( vsixPath ) ;
59
+
60
+ // Determine version to use
61
+ const match = / s w i f t - v s c o d e - ( \d + .\d + .\d + ( - d e v ) ? ) ( - \d + ) ? .v s i x / g. exec ( path . basename ( vsixPath ) ) ;
62
+ if ( match ) {
63
+ versionStr = match [ 1 ] ;
64
+ }
65
+ console . log ( "Running tests against extension version " + versionStr ) ;
66
+
67
+ extensionDevelopmentPath = `${ __dirname } /.vscode-test/extensions/${ publisher } .${ name } -${ versionStr } ` ;
68
+ console . log ( "Running tests against extension development path " + extensionDevelopmentPath ) ;
61
69
}
62
70
71
+ const vscodeVersion = process . env [ "VSCODE_VERSION" ] ?? "stable" ;
72
+ console . log ( "Running tests against VS Code version " + vscodeVersion ) ;
73
+
74
+ const installConfigs = [ ] ;
63
75
for ( const ext of installExtensions ) {
64
- install . push ( {
76
+ installConfigs . push ( {
65
77
label : `installExtension-${ ext } ` ,
66
78
installExtensions : [ ext ] ,
67
- launchArgs,
79
+ launchArgs : launchArgs . concat ( "--disable-extensions" ) ,
68
80
files : [ "dist/test/sleep.test.js" ] ,
69
- version : process . env [ "VSCODE_VERSION" ] ?? "stable" ,
81
+ version : vscodeVersion ,
82
+ skipExtensionDependencies : true ,
70
83
reuseMachineInstall : ! isCIBuild ,
71
84
} ) ;
72
85
}
73
86
87
+ const env = {
88
+ ...process . env ,
89
+ RUNNING_UNDER_VSCODE_TEST_CLI : "1" ,
90
+ } ;
91
+ console . log ( "Running tests against environment:\n" + JSON . stringify ( env , undefined , 2 ) ) ;
92
+
74
93
module . exports = defineConfig ( {
75
94
tests : [
76
- ...install ,
95
+ ...installConfigs ,
77
96
{
78
97
label : "integrationTests" ,
79
98
files : [ "dist/test/common.js" , "dist/test/integration-tests/**/*.test.js" ] ,
80
- version : process . env [ "VSCODE_VERSION" ] ?? "stable" ,
99
+ version : vscodeVersion ,
81
100
workspaceFolder : "./assets/test" ,
82
101
launchArgs,
83
- extensionDevelopmentPath : vsixPath
84
- ? [ `${ __dirname } /.vscode-test/extensions/${ publisher } .${ name } -${ versionStr } ` ]
85
- : undefined ,
86
- env : {
87
- VSCODE_TEST : "1" ,
88
- } ,
102
+ extensionDevelopmentPath,
103
+ env,
89
104
mocha : {
90
105
ui : "tdd" ,
91
106
color : true ,
@@ -102,7 +117,7 @@ module.exports = defineConfig({
102
117
} ,
103
118
} ,
104
119
} ,
105
- skipExtensionDependencies : install . length > 0 ,
120
+ skipExtensionDependencies : installConfigs . length > 0 ,
106
121
reuseMachineInstall : ! isCIBuild ,
107
122
} ,
108
123
{
@@ -116,15 +131,11 @@ module.exports = defineConfig({
116
131
"dist/test/integration-tests/testexplorer/TestExplorerIntegration.test.js" ,
117
132
"dist/test/integration-tests/commands/dependency.test.js" ,
118
133
] ,
119
- version : process . env [ "VSCODE_VERSION" ] ?? "stable" ,
134
+ version : vscodeVersion ,
120
135
workspaceFolder : "./assets/test.code-workspace" ,
121
136
launchArgs,
122
- extensionDevelopmentPath : vsixPath
123
- ? [ `${ __dirname } /.vscode-test/extensions/${ publisher } .${ name } -${ versionStr } ` ]
124
- : undefined ,
125
- env : {
126
- VSCODE_TEST : "1" ,
127
- } ,
137
+ extensionDevelopmentPath,
138
+ env,
128
139
mocha : {
129
140
ui : "tdd" ,
130
141
color : true ,
@@ -141,17 +152,15 @@ module.exports = defineConfig({
141
152
} ,
142
153
} ,
143
154
} ,
144
- skipExtensionDependencies : install . length > 0 ,
155
+ skipExtensionDependencies : installConfigs . length > 0 ,
145
156
reuseMachineInstall : ! isCIBuild ,
146
157
} ,
147
158
{
148
159
label : "unitTests" ,
149
160
files : [ "dist/test/common.js" , "dist/test/unit-tests/**/*.test.js" ] ,
150
- version : process . env [ "VSCODE_VERSION" ] ?? "stable" ,
161
+ version : vscodeVersion ,
151
162
launchArgs : launchArgs . concat ( "--disable-extensions" ) ,
152
- env : {
153
- VSCODE_TEST : "1" ,
154
- } ,
163
+ env,
155
164
mocha : {
156
165
ui : "tdd" ,
157
166
color : true ,
0 commit comments