-
Notifications
You must be signed in to change notification settings - Fork 971
Expand file tree
/
Copy pathrun-e2e.js
More file actions
2385 lines (2090 loc) · 98.1 KB
/
Copy pathrun-e2e.js
File metadata and controls
2385 lines (2090 loc) · 98.1 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const { spawn, spawnSync } = require('child_process');
const {
ensureDownloadCache,
projectDownloadCache,
removePathWithoutFollowingLinks,
resolveDownloadCacheRoot,
} = require('./e2e-download-cache');
const {
markErrorNonRetryable,
runWithRetries,
terminateOrphanedDescendants,
} = require('./e2e-download-retry');
const { shouldAllowAdvisoryTestFailure } = require('./e2e-process-failure.cjs');
const { runWithProcessTreeTimeout } = require('./e2e-process-runner.cjs');
const extensionRoot = path.resolve(__dirname, '..');
const extensionPackageJson = JSON.parse(fs.readFileSync(path.join(extensionRoot, 'package.json'), 'utf8'));
const repoRoot = path.resolve(extensionRoot, '..');
const verifyExtesterFeedOnly = process.argv.includes('--verify-extester-feed');
const artifactsDir = path.join(extensionRoot, '.test-artifacts');
const shardName = sanitizePathSegment(process.env.ASPIRE_EXTENSION_E2E_SHARD || 'all');
const resultsDir = path.join(extensionRoot, '.test-results', 'e2e', shardName);
const runId = `${process.pid}-${Date.now()}`;
const diagnosticsStorageRoot = path.join(extensionRoot, '.test-storage');
const requestedTempRoot = verifyExtesterFeedOnly ? '' : process.env.ASPIRE_EXTENSION_E2E_TEMP_ROOT || os.tmpdir();
// Everything below that can reject the environment runs before the per-run root exists, and
// nothing after `mkdtempSync` does more than join strings. Module scope is outside the cleanup
// `finally` that `main()` installs, so a throw once the root exists leaves an `aev-*` directory
// behind with nothing alive to remove it; work that can fail belongs in `main()` instead, which is
// why `prepareRunDirectories` is a function rather than a module-scope block.
const testSpec = process.env.ASPIRE_EXTENSION_E2E_SPEC || 'out/test-e2e/**/*.e2e.test.js';
const matchedTestSpecs = verifyExtesterFeedOnly ? [] : findSpecMatches(testSpec);
// Java specs need the Java language server and the Java debug adapter (neither of which Aspire
// ships) and a Java workspace in place of the scaffolded C# one, so they cannot share a run with
// the other specs. Which specs are running is the whole requirement, so it is read off them rather
// than from an opt-in variable: as an opt-in, both Java shards ran in CI with nothing setting it,
// skipped every test, and reported green.
//
// ASPIRE_EXTENSION_E2E_ENABLE_JAVA remains as an explicit override for running a Java spec through
// a glob, or for forcing the Java workspace off while debugging the runner.
const enableJavaE2E = process.env.ASPIRE_EXTENSION_E2E_ENABLE_JAVA
? process.env.ASPIRE_EXTENSION_E2E_ENABLE_JAVA === 'true'
: matchedTestSpecs.length > 0 && matchedTestSpecs.every(isJavaSpecPath);
const useJavaStarterWorkspace = enableJavaE2E
&& matchedTestSpecs.length > 0
&& matchedTestSpecs.every(specPath => path.basename(specPath).toLowerCase().startsWith('javastarterprojectmodel.'));
// redhat.java supplies the language server, which is what produces workspace diagnostics and the
// classpath the debug adapter launches against. vscjava.vscode-java-debug supplies the `java` debug
// adapter the Aspire debugger delegates to, and vscjava.vscode-java-dependency is a hard activation
// dependency of it. capabilities.ts only advertises the `java` capability - which is what makes the
// CLI hand the AppHost launch back to the extension - when the first two are both installed.
const REQUIRED_JAVA_EXTENSION_IDS = ['redhat.java', 'vscjava.vscode-java-debug', 'vscjava.vscode-java-dependency'];
const extesterVersion = extensionPackageJson.devDependencies?.['vscode-extension-tester'];
if (!extesterVersion) {
throw new Error('vscode-extension-tester must be pinned in extension/package.json devDependencies.');
}
// The feed preflight must not touch the shared cache: it runs before any download and only
// verifies package availability, so resolving the cache root there would be wasted Git discovery.
const downloadCacheRoot = verifyExtesterFeedOnly ? '' : resolveDownloadCacheRoot(repoRoot);
// Keep this below VS Code 1.131.0 while ExTester is pinned to 8.23.0. VS Code 1.130.0 contains
// Contents/MacOS/Code plus an Electron -> Code compatibility symlink, but VS Code 1.131.0 removes
// that legacy path and ExTester 8.23.0 only launches it. ExTester 8.24.0 adds the fallback, but its
// tarball is not anonymously available from dotnet-public-npm yet.
const vscodeVersion = resolveCachedVsCodeVersion(process.env.ASPIRE_EXTENSION_E2E_VSCODE_VERSION || '1.130.0');
assertVsCodeVersionCompatibleWithExtester(vscodeVersion, extesterVersion);
if (!verifyExtesterFeedOnly) {
fs.mkdirSync(requestedTempRoot, { recursive: true });
}
const tempRoot = verifyExtesterFeedOnly ? '' : fs.realpathSync.native(requestedTempRoot);
const shortRunRoot = verifyExtesterFeedOnly ? '' : fs.mkdtempSync(path.join(tempRoot, 'aev-'));
const e2eNuGetPackages = path.join(downloadCacheRoot, 'nuget-packages', shardName);
const isolatedAspireHome = path.join(shortRunRoot, 'aspire-home');
const storageDir = path.join(shortRunRoot, 'storage');
const extensionsDir = path.join(shortRunRoot, 'extensions');
// A single-file Java AppHost is restored and launched by the CLI's AppHost server. In a dev build
// that server resolves Aspire packages through the repository's own NuGet configuration, so a
// workspace under the OS temp directory fails with "No code generator found for language: Java"
// (and, with an isolated ASPIRE_HOME, "No Aspire AppHost server is available"). The Java workspace
// therefore lives inside the repository.
//
// It deliberately is not one of the gitignored scratch directories: `aspire ls` skips ignored
// paths, so an AppHost under `.test-workspaces/` is discovered as zero candidates. It also sits
// under `extension/` rather than the repository root, because an AppHost at the root fails code
// generation with "No code generator found for language: Java". The runner deletes this directory
// at the start and end of every run.
const javaScratchWorkspaceRoot = path.join(extensionRoot, 'java-e2e-workspace');
const workspaceRoot = process.env.ASPIRE_EXTENSION_E2E_WORKSPACE_ROOT
? path.resolve(process.env.ASPIRE_EXTENSION_E2E_WORKSPACE_ROOT)
: enableJavaE2E
? javaScratchWorkspaceRoot
: path.join(shortRunRoot, 'workspace');
const workspaceMarkerFile = path.join(workspaceRoot, '.aspire-extension-e2e-workspace');
const storageDiagnosticsDir = path.join(diagnosticsStorageRoot, shardName, runId);
const workspaceDiagnosticsDir = path.join(extensionRoot, '.test-workspaces', shardName, runId);
const recordingsDir = path.join(extensionRoot, '.test-recordings', shardName);
const defaultVsixPath = path.join(artifactsDir, 'aspire-extension-e2e.vsix');
const stateFile = path.join(resultsDir, 'extension-state.json');
const controlFile = path.join(resultsDir, 'extension-control.json');
const extesterNodeModules = path.join(extensionRoot, 'node_modules');
const extesterModule = path.join(extesterNodeModules, 'vscode-extension-tester');
const extesterCli = path.join(extesterModule, 'out', 'cli.js');
// ExTester unpacks VS Code into `<storage>/vscode-temp-<random>` and removes it in a `finally`
// that a killed process never reaches. See node_modules/vscode-extension-tester/out/util/codeUtil.js.
const EXTESTER_UNPACK_DIRECTORY_PREFIX = 'vscode-temp-';
// `/bin/sh` leaves a word alone only when every character in it is inert: no whitespace to split
// on, no `$` or backtick to expand, no `;`, `&`, `|`, `(`, `)`, `<`, `>` or newline to end the
// command, no `*`, `?` or `[` to glob, and no quote or backslash to change the parse. This is an
// allowlist rather than a metacharacter blocklist so a character whose meaning depends on position
// (`~`, `#`, `!`) forces a projection instead of having to be reasoned about.
const POSIX_SHELL_INERT_PATH_PATTERN = /^[A-Za-z0-9._/+,=:@%-]+$/;
// Windows needs the same allowlist over a different alphabet, because `cmd.exe /d /s /c` strips
// the quotes Node wraps the command in and parses whatever is left. `\` and `:` are ordinary path
// characters rather than escapes there, and `~` has to stay legal: the 8.3 short names Windows
// hands out (`C:\Users\RUNNER~1\AppData\Local\Temp` on hosted runners) would otherwise be unable
// to host the projection that stands in for a rejected path. Excluded are `%` and `!` (variable
// and delayed expansion), `^` (escape), `&`, `|`, `<`, `>`, `(`, `)` and quotes (command syntax),
// and space, `,`, `;` and `=`, every one of which terminates the command token.
const WINDOWS_COMMAND_INERT_PATH_PATTERN = /^[A-Za-z0-9._\\/:+@~-]+$/;
const isWindows = process.platform === 'win32';
const COMMAND_INERT_PATH_PATTERN = isWindows ? WINDOWS_COMMAND_INERT_PATH_PATTERN : POSIX_SHELL_INERT_PATH_PATTERN;
const COMMAND_INTERPRETER_NAME = isWindows ? 'cmd.exe' : '/bin/sh';
const COMMAND_INERT_PATH_ALPHABET = isWindows ? '._-+@~:\\/' : '._-+,=:@%/';
const primaryAppHostProject = path.join(workspaceRoot, 'AspireE2E.AppHost', 'AspireE2E.AppHost.csproj');
const runRootNuGetConfigPath = path.join(shortRunRoot, 'NuGet.config');
const workspaceNuGetConfigPath = path.join(workspaceRoot, 'NuGet.config');
const enableAzureFunctionsE2E = process.env.ASPIRE_EXTENSION_E2E_ENABLE_AZURE_FUNCTIONS === 'true';
const advisoryIssue = process.env.ASPIRE_EXTENSION_E2E_ADVISORY_ISSUE || '';
let cliPathForCleanup;
const csharpFileHeader = `// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
`;
/**
* Clears the previous run's results and creates the directories this run writes into.
*
* This is deliberately not module scope even though everything it needs is: it removes and creates
* directories, and every one of those calls can fail on a stale Windows file lock or a read-only
* mount. Module scope is outside the cleanup `finally` that `main()` installs, so a throw there
* would strand the `aev-*` root that `mkdtempSync` had already created.
*/
function prepareRunDirectories() {
removePath(resultsDir, { recursive: true, force: true });
removePath(recordingsDir, { recursive: true, force: true });
for (const directory of [artifactsDir, resultsDir, diagnosticsStorageRoot, isolatedAspireHome, storageDir, extensionsDir]) {
fs.mkdirSync(directory, { recursive: true });
}
}
function prepareNuGetPackageCache() {
fs.mkdirSync(e2eNuGetPackages, { recursive: true });
for (const entry of fs.readdirSync(e2eNuGetPackages, { withFileTypes: true })) {
// E2E builds reuse package versions, so only repository-built Aspire packages can be stale.
// Keep third-party packages warm across runs, and isolate each shard so concurrent runs do not
// remove packages another shard is restoring.
if (/^aspire(?:\.|$)/i.test(entry.name)) {
removePathWithoutFollowingLinks(path.join(e2eNuGetPackages, entry.name), { recursive: true, force: true });
}
}
}
function getRunTestsTimeoutMs() {
const configured = Number(process.env.ASPIRE_EXTENSION_E2E_RUN_TESTS_TIMEOUT_MS || 2400000);
if (!Number.isFinite(configured) || configured <= 0) {
throw new Error(`ASPIRE_EXTENSION_E2E_RUN_TESTS_TIMEOUT_MS must be a positive number. Got '${process.env.ASPIRE_EXTENSION_E2E_RUN_TESTS_TIMEOUT_MS}'.`);
}
return configured;
}
/**
* Returns a path ExTester can be given for its storage folder that the platform's command
* interpreter will not reinterpret.
*
* ExTester builds shell command strings out of this path and interpolates it unquoted into
* each of them:
*
* - `exec(`unzip -qo ${input}`, { cwd: target })` unpacks `.zip` archives on macOS and Linux --
* see `node_modules/vscode-extension-tester/out/util/unpack.js`.
* - `exec(`${this.getChromeDriverBinaryPath(version)} -v`)` reads the version of an already
* downloaded ChromeDriver on every platform, Windows included -- see
* `node_modules/vscode-extension-tester/out/util/driverUtil.js`.
*
* `exec` hands its string to `/bin/sh -c` or `cmd.exe /d /s /c`, so every construct in the path is
* live: a space splits it into two arguments, `repo(1)` is a syntax error under `sh`, and
* `repo&whoami` runs a second command under `cmd`. That path is now the download cache, which
* lives inside the repository, so it is wherever the developer cloned rather than something this
* runner chooses.
*
* The ChromeDriver check is why this has to happen on Windows even though Windows unpacks
* in-process with `unzipper`. `downloadChromeDriver` runs it whenever the binary already exists,
* which is exactly the warm hit this cache is built to produce, and it swallows the failure and
* downloads again. A checkout under `C:\src\my repo` would therefore never get a warm ChromeDriver
* and would never say why.
*
* Standing a link from the run's own temporary root in front of the cache keeps the command a
* single inert word. Windows gets a junction rather than a symlink because junctions need neither
* elevation nor Developer Mode.
*/
function projectCommandSafeStagingDirectory(stagingDirectory) {
if (COMMAND_INERT_PATH_PATTERN.test(stagingDirectory)) {
return stagingDirectory;
}
const linkPath = path.join(shortRunRoot, 'cache-staging');
if (!COMMAND_INERT_PATH_PATTERN.test(linkPath)) {
throw new Error(`The download cache path '${stagingDirectory}' contains characters '${COMMAND_INTERPRETER_NAME}' would reinterpret, which ExTester cannot be pointed at, and the per-run temporary root '${shortRunRoot}' cannot stand in for it because it has the same problem. Point ASPIRE_EXTENSION_E2E_TEMP_ROOT or ASPIRE_EXTENSION_E2E_CACHE_ROOT at a path built only from letters, digits and '${COMMAND_INERT_PATH_ALPHABET}'.`);
}
removePathWithoutFollowingLinks(linkPath);
fs.symlinkSync(stagingDirectory, linkPath, isWindows ? 'junction' : 'dir');
return linkPath;
}
function getSetupDownloadRetryOptions(stagingDirectory, downloadDirectory) {
return {
attempts: getPositiveIntegerEnvironmentVariable('ASPIRE_EXTENSION_E2E_SETUP_DOWNLOAD_RETRY_ATTEMPTS', 5),
retryDelayMs: getPositiveIntegerEnvironmentVariable('ASPIRE_EXTENSION_E2E_SETUP_DOWNLOAD_RETRY_DELAY_MS', 15000),
beforeRetry: () => cleanPartialExtesterDownloads(stagingDirectory),
timeout: getPositiveIntegerEnvironmentVariable('ASPIRE_EXTENSION_E2E_SETUP_DOWNLOAD_TIMEOUT_MS', 240000),
// Orphans are matched by the path ExTester was actually given, which is the projection rather
// than the candidate whenever the cache path is not inert to the command interpreter.
terminateOrphansUnder: downloadDirectory,
};
}
function getPositiveIntegerEnvironmentVariable(name, defaultValue) {
const configured = Number(process.env[name] || defaultValue);
if (!Number.isInteger(configured) || configured <= 0) {
throw new Error(`${name} must be a positive integer. Got '${process.env[name]}'.`);
}
return configured;
}
function redactStateFileForArtifacts() {
const state = readJsonIfExists(stateFile);
if (!state) {
return;
}
redactDashboardUrls(state);
fs.writeFileSync(stateFile, JSON.stringify(state, null, 2));
}
function redactDashboardUrls(value) {
if (!value || typeof value !== 'object') {
return;
}
if (Array.isArray(value)) {
for (const item of value) {
redactDashboardUrls(item);
}
return;
}
for (const [key, item] of Object.entries(value)) {
if (key === 'dashboardUrl' && typeof item === 'string') {
value[key] = sanitizeDashboardUrlForDiagnostics(item);
}
else {
redactDashboardUrls(item);
}
}
}
function redactDebugSessionForDiagnostics(session) {
return {
...session,
dashboardUrl: sanitizeDashboardUrlForDiagnostics(session.dashboardUrl),
};
}
function sanitizeDashboardUrlForDiagnostics(url) {
if (!url) {
return url;
}
try {
return new URL(stripResourceSuffix(url)).origin;
}
catch {
return '<redacted>';
}
}
function stripResourceSuffix(url) {
const idx = url.indexOf('/?resource=');
return idx !== -1 ? url.substring(0, idx) : url;
}
main().catch(error => {
console.error(error instanceof Error ? error.stack ?? error.message : String(error));
process.exitCode = 1;
});
function shouldUseShellForCommand(command) {
// npm and corepack are .cmd shims on Windows. Node.js 20+ intentionally refuses
// to spawn .cmd/.bat files with shell:false, so use cmd.exe only for those tools.
return process.platform === 'win32' && (command === 'npm' || command === 'corepack');
}
function assertSpecMatches(spec) {
if (matchedTestSpecs.length === 0) {
throw new Error(`E2E spec '${spec}' did not match any compiled test files under ${path.relative(extensionRoot, path.join(extensionRoot, 'out', 'test-e2e'))}. Run corepack yarn@1.22.22 compile-e2e and check ASPIRE_EXTENSION_E2E_SPEC.`);
}
}
function logE2eConfiguration() {
console.log('Aspire extension E2E configuration:');
console.log(` shard: ${shardName}`);
console.log(` spec: ${testSpec}`);
console.log(` matched specs: ${matchedTestSpecs.map(file => path.relative(extensionRoot, file)).join(', ')}`);
console.log(` VS Code: ${vscodeVersion}`);
console.log(` ExTester: ${extesterVersion}`);
console.log(` download cache: ${downloadCacheRoot}`);
console.log(` current CLI regressions: ${process.env.ASPIRE_EXTENSION_E2E_SKIP_CURRENT_CLI_REGRESSIONS === 'true' ? 'skipped' : 'included'}`);
console.log(` Azure Functions: ${enableAzureFunctionsE2E ? 'enabled' : 'disabled'}`);
console.log(` Java: ${enableJavaE2E ? 'enabled' : 'disabled'}`);
console.log(` results: ${path.relative(extensionRoot, resultsDir)}`);
console.log(` storage diagnostics: ${path.relative(extensionRoot, storageDiagnosticsDir)}`);
console.log(` workspace diagnostics: ${path.relative(extensionRoot, workspaceDiagnosticsDir)}`);
}
/**
* Reports whether a compiled spec file belongs to the Java suites.
*
* Naming is the contract: every Java spec is `java*.e2e.test.js`, which is also what the workflow's
* `java-*` shards point at. Matching on the file name rather than a hard-coded list means a new
* Java spec is picked up by adding the shard, with nothing else to remember.
*/
function isJavaSpecPath(specPath) {
return path.basename(specPath).toLowerCase().startsWith('java');
}
function logStep(name) {
console.log(`\n--- ${name} ---`);
}
function findSpecMatches(spec) {
const absolutePattern = path.resolve(extensionRoot, spec);
if (!hasGlobSyntax(spec)) {
return fs.existsSync(absolutePattern) ? [absolutePattern] : [];
}
const root = getGlobSearchRoot(absolutePattern);
if (!root || !fs.existsSync(root)) {
return [];
}
const patternRegex = globToRegExp(toPosixPath(absolutePattern));
return getFilesRecursive(root).filter(file => patternRegex.test(toPosixPath(file)));
}
function getGlobSearchRoot(pattern) {
const firstGlobIndex = pattern.search(/[*?\[\]{}]/);
if (firstGlobIndex === -1) {
return path.dirname(pattern);
}
const prefix = pattern.slice(0, firstGlobIndex);
const lastSeparator = Math.max(prefix.lastIndexOf(path.sep), prefix.lastIndexOf('/'), prefix.lastIndexOf('\\'));
return lastSeparator === -1 ? extensionRoot : prefix.slice(0, lastSeparator);
}
function getFilesRecursive(directory) {
const entries = fs.readdirSync(directory, { withFileTypes: true });
return entries.flatMap(entry => {
const entryPath = path.join(directory, entry.name);
return entry.isDirectory() ? getFilesRecursive(entryPath) : [entryPath];
});
}
function hasGlobSyntax(value) {
return /[*?\[\]{}]/.test(value);
}
function globToRegExp(pattern) {
let expression = '^';
for (let i = 0; i < pattern.length; i++) {
const character = pattern[i];
const nextCharacter = pattern[i + 1];
if (character === '*' && nextCharacter === '*' && pattern[i + 2] === '/') {
expression += '(?:.*/)?';
i += 2;
}
else if (character === '*' && nextCharacter === '*') {
expression += '.*';
i++;
}
else if (character === '*') {
expression += '[^/]*';
}
else if (character === '?') {
expression += '[^/]';
}
else if (character === '{') {
const endBrace = pattern.indexOf('}', i + 1);
if (endBrace !== -1) {
const alternatives = pattern.slice(i + 1, endBrace).split(',').map(escapeRegExp).join('|');
expression += `(?:${alternatives})`;
i = endBrace;
}
else {
expression += escapeRegExp(character);
}
}
else {
expression += escapeRegExp(character);
}
}
return new RegExp(`${expression}$`);
}
function escapeRegExp(value) {
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function toPosixPath(value) {
return path.resolve(value).replace(/^\\\\\?\\/, '').split(path.sep).join('/');
}
function writeVsCodeLocaleFile() {
const userDataDirectory = path.join(storageDir, 'settings', 'User');
fs.mkdirSync(userDataDirectory, { recursive: true });
fs.writeFileSync(path.join(userDataDirectory, 'locale.json'), JSON.stringify({ locale: 'en' }, undefined, 2));
}
function startRecording() {
const mode = getRecordingMode();
if (mode === 'off') {
return undefined;
}
if (process.platform !== 'linux') {
console.warn(`Skipping Aspire extension E2E recording because '${mode}' recording is only supported on Linux runners.`);
return undefined;
}
const display = process.env.DISPLAY;
if (!display) {
console.warn('Skipping Aspire extension E2E recording because DISPLAY is not set.');
return undefined;
}
const ffmpegCheck = spawnSync('ffmpeg', ['-version'], { encoding: 'utf8', stdio: 'ignore', timeout: 15000 });
if (ffmpegCheck.error || ffmpegCheck.status !== 0) {
console.warn('Skipping Aspire extension E2E recording because ffmpeg is not available.');
return undefined;
}
fs.mkdirSync(recordingsDir, { recursive: true });
const outputPath = path.join(recordingsDir, `${runId}.mp4`);
const displayInput = display.includes('.') ? display : `${display}.0`;
const args = [
'-y',
'-video_size',
process.env.ASPIRE_EXTENSION_E2E_RECORDING_SIZE || '1280x1024',
'-framerate',
process.env.ASPIRE_EXTENSION_E2E_RECORDING_FRAMERATE || '15',
'-f',
'x11grab',
'-draw_mouse',
'1',
'-i',
displayInput,
'-an',
'-c:v',
'libx264',
'-preset',
'ultrafast',
'-pix_fmt',
'yuv420p',
outputPath,
];
const logPath = path.join(recordingsDir, `${runId}.ffmpeg.log`);
const logFd = fs.openSync(logPath, 'w');
const ffmpeg = spawn('ffmpeg', args, {
stdio: ['ignore', logFd, logFd],
detached: false,
});
ffmpeg.on('error', error => {
console.warn(`Aspire extension E2E recording failed to start: ${error.message}`);
});
const closed = new Promise(resolve => {
ffmpeg.once('close', (exitCode, signal) => resolve({ exitCode, signal }));
ffmpeg.once('error', error => resolve({ error }));
});
return {
mode,
outputPath,
logPath,
pid: ffmpeg.pid,
closed,
closeLog: () => fs.closeSync(logFd),
};
}
function getRecordingMode() {
const configured = (process.env.ASPIRE_EXTENSION_E2E_RECORDING_MODE || 'off').toLowerCase();
if (configured === 'off' || configured === 'failure' || configured === 'always') {
return configured;
}
throw new Error(`ASPIRE_EXTENSION_E2E_RECORDING_MODE must be 'off', 'failure', or 'always'. Got '${process.env.ASPIRE_EXTENSION_E2E_RECORDING_MODE}'.`);
}
async function stopRecording(recording, testFailure) {
if (!recording) {
return;
}
let stoppedGracefully = false;
try {
if (recording.pid) {
stoppedGracefully = await stopRecordingProcess(recording.pid, recording.closed);
}
else {
await waitForProcessClose(recording.closed, 15000);
stoppedGracefully = true;
}
}
finally {
recording.closeLog();
}
const keepRecording = recording.mode === 'always' || (recording.mode === 'failure' && testFailure);
if (!keepRecording) {
fs.rmSync(recording.outputPath, { force: true });
fs.rmSync(recording.logPath, { force: true });
return;
}
if (stoppedGracefully && fs.existsSync(recording.outputPath)) {
console.log(`Aspire extension E2E recording saved to ${recording.outputPath}`);
}
else {
console.warn(`Aspire extension E2E recording was requested but was not saved cleanly. Check ${recording.logPath}.`);
}
}
async function stopRecordingProcess(pid, closed) {
signalProcess(pid, 'SIGINT');
if (await waitForProcessClose(closed, 15000)) {
return true;
}
signalProcess(pid, 'SIGTERM');
if (await waitForProcessClose(closed, 5000)) {
return false;
}
signalProcess(pid, 'SIGKILL');
if (await waitForProcessClose(closed, 5000)) {
return false;
}
throw new Error(`ffmpeg recording process ${pid} did not exit after SIGINT, SIGTERM, and SIGKILL.`);
}
function signalProcess(pid, signal) {
try {
process.kill(pid, signal);
}
catch (error) {
if (!error || error.code !== 'ESRCH') {
throw error;
}
}
}
function waitForProcessClose(closed, timeoutMs) {
return new Promise(resolve => {
const timeout = setTimeout(() => resolve(false), timeoutMs);
closed.then(() => {
clearTimeout(timeout);
resolve(true);
}, () => {
clearTimeout(timeout);
resolve(true);
});
});
}
async function main() {
let recording;
let testFailure;
let cleanupFailed = false;
try {
if (verifyExtesterFeedOnly) {
verifyExtesterFeed();
return;
}
assertSpecMatches(testSpec);
prepareRunDirectories();
prepareNuGetPackageCache();
logE2eConfiguration();
const bundledCliPath = resolveCliPath();
// A dev-build CLI resolves its AppHost server and code generators relative to its own location,
// so a copy under the temp root cannot run a single-file Java AppHost - it fails with "No code
// generator found for language: Java". Java runs therefore use the CLI in place. Nothing in the
// Java spec writes to the CLI directory, and cleanup only ever invokes `aspire stop`.
const cliPath = enableJavaE2E ? bundledCliPath : isolateCliPath(bundledCliPath);
cliPathForCleanup = cliPath;
validateCliPath(cliPath);
const appHostSdkVersion = resolveAppHostSdkVersion(cliPath);
prepareWorkspaceFixture(cliPath, appHostSdkVersion);
prepareJavaWorkspace(bundledCliPath, appHostSdkVersion);
restoreWorkspaceFixture();
const vsixPath = process.env.ASPIRE_EXTENSION_E2E_VSIX
? path.resolve(process.env.ASPIRE_EXTENSION_E2E_VSIX)
: packageVsix();
if (!fs.existsSync(vsixPath)) {
throw new Error(`VSIX not found at ${vsixPath}`);
}
validateVsix(vsixPath);
const azureFunctionsVsixPaths = resolveAzureFunctionsVsixPaths();
if (enableAzureFunctionsE2E) {
validateAzureFunctionsCoreTools();
}
ensureExtester();
patchExtesterLaunchLocale();
writeVsCodeLocaleFile();
const extestEnv = getAspireCliEnvironment({
ASPIRE_EXTENSION_E2E_CLI_PATH: cliPath,
ASPIRE_EXTENSION_E2E_EXTENSION_ROOT: extensionRoot,
ASPIRE_EXTENSION_E2E_REPO_ROOT: repoRoot,
ASPIRE_EXTENSION_E2E_RESULTS_DIR: resultsDir,
ASPIRE_EXTENSION_E2E_RUN_ROOT: shortRunRoot,
ASPIRE_EXTENSION_E2E_WORKSPACE_ROOT: workspaceRoot,
ASPIRE_EXTENSION_E2E_STATE_FILE: stateFile,
ASPIRE_EXTENSION_E2E_CONTROL_FILE: controlFile,
// The state and control files live at a stable per-shard path, so both sides stamp this to
// ignore an extension host left behind by an earlier run that is still polling them.
ASPIRE_EXTENSION_E2E_RUN_ID: runId,
ASPIRE_EXTENSION_E2E_ENABLE_BRIDGE: 'true',
NUGET_PACKAGES: e2eNuGetPackages,
ASPIRE_EXTENSION_E2E_NUGET_PACKAGES: e2eNuGetPackages,
ASPIRE_EXTENSION_E2E_SKIP_CURRENT_CLI_REGRESSIONS: process.env.ASPIRE_EXTENSION_E2E_SKIP_CURRENT_CLI_REGRESSIONS === 'true' ? 'true' : 'false',
ASPIRE_EXTENSION_E2E_PRIMARY_APPHOST: primaryAppHostProject,
ASPIRE_EXTENSION_E2E_APPHOST_SDK_VERSION: appHostSdkVersion,
ASPIRE_EXTENSION_E2E_EXTESTER_MODULE: extesterModule,
ASPIRE_EXTENSION_E2E_ENABLE_AZURE_FUNCTIONS: enableAzureFunctionsE2E ? 'true' : 'false',
VSCODE_NLS_CONFIG: JSON.stringify({ locale: 'en', availableLanguages: {} }),
LANG: 'C.UTF-8',
LC_ALL: 'C.UTF-8',
NODE_PATH: [extesterNodeModules, process.env.NODE_PATH].filter(Boolean).join(path.delimiter),
// ExTester's loadCodeVersion prefers CODE_VERSION over the --code_version argument, so an
// ambient value would make it download a version the cache key does not describe and leave
// a later run reusing the wrong install offline. Pinning it here makes the argument and the
// key authoritative. See node_modules/vscode-extension-tester/out/extester.js.
CODE_VERSION: vscodeVersion,
// The cache discovers stable install layouts (`VSCode-linux-x64`, `Visual Studio Code.app`)
// and the stream is not part of its key, so an ambient CODE_TYPE=insider would download an
// Insiders build that artifact discovery then cannot find. Nothing here asks for Insiders.
CODE_TYPE: 'stable',
});
if (process.env.ASPIRE_EXTENSION_E2E_UNSET_CLI_START_TIMEOUT === 'true') {
extestEnv.ASPIRE_CLI_START_TIMEOUT = undefined;
}
const downloadCache = ensureDownloadCache({
cacheRoot: downloadCacheRoot,
vscodeVersion,
extesterVersion,
platform: process.platform,
architecture: process.arch,
populate(stagingDirectory) {
const downloadDirectory = projectCommandSafeStagingDirectory(stagingDirectory);
const setupDownloadRetryOptions = getSetupDownloadRetryOptions(stagingDirectory, downloadDirectory);
logStep('Downloading VS Code');
runWithRetry(process.execPath, [extesterCli, 'get-vscode', '--storage', downloadDirectory, '--code_version', vscodeVersion], extestEnv, setupDownloadRetryOptions);
logStep('Downloading ChromeDriver');
runWithRetry(process.execPath, [extesterCli, 'get-chromedriver', '--storage', downloadDirectory, '--code_version', vscodeVersion], extestEnv, setupDownloadRetryOptions);
},
});
console.log(`Extension E2E download cache ${downloadCache.cacheHit ? 'hit' : 'populated'}: ${downloadCache.cacheDirectory}`);
projectDownloadCache(downloadCache, storageDir);
// Installed before any VSIX because the fallback path copies unpacked extension directories in.
// VS Code only scans the extensions directory while extensions.json is absent; once install-vsix
// has written that file it is the authoritative list, and a directory that is not in it is
// ignored and then removed. Copying after the first install therefore silently installs nothing.
installJavaExtensions(extestEnv);
logStep('Installing VSIX');
run(process.execPath, [extesterCli, 'install-vsix', '--storage', storageDir, '--extensions_dir', extensionsDir, '--vsix_file', vsixPath], extestEnv, { timeout: 300000 });
for (const azureFunctionsVsix of azureFunctionsVsixPaths) {
logStep(`Installing ${azureFunctionsVsix.displayName} VSIX`);
run(process.execPath, [extesterCli, 'install-vsix', '--storage', storageDir, '--extensions_dir', extensionsDir, '--vsix_file', azureFunctionsVsix.path], extestEnv, { timeout: 300000 });
}
assertJavaExtensionsRegistered();
recording = startRecording();
try {
logStep('Running VS Code extension E2E tests');
const runTestsArgs = [extesterCli, 'run-tests', testSpec, '--storage', storageDir, '--extensions_dir', extensionsDir, '--code_version', vscodeVersion, '--code_settings', path.join(extensionRoot, 'test-e2e', 'settings.json'), '--mocha_config', path.join(extensionRoot, '.mocharc.e2e.js'), '--offline'];
await runWithProcessTreeTimeout(process.execPath, runTestsArgs, {
diagnosticsSuffix: ` Diagnostics are under ${path.relative(extensionRoot, resultsDir)} and ${path.relative(extensionRoot, storageDiagnosticsDir)}.`,
quoteShellArgument: quoteWindowsShellArgument,
spawn,
spawnOptions: {
cwd: extensionRoot,
env: { ...process.env, ...extestEnv },
stdio: 'inherit',
detached: process.platform !== 'win32',
},
terminateProcessTree,
timeout: getRunTestsTimeoutMs(),
useShell: shouldUseShellForCommand(process.execPath),
});
}
catch (error) {
testFailure = error;
}
}
finally {
const cleanupErrors = [];
await runCleanupStep('stop recording', () => stopRecording(recording, testFailure), cleanupErrors);
await runCleanupStep('stop workspace AppHost', stopWorkspaceAppHost, cleanupErrors);
await runCleanupStep('redact extension state', redactStateFileForArtifacts, cleanupErrors);
await runCleanupStep('redact test results', () => redactTextFilesForArtifacts(resultsDir), cleanupErrors);
await runCleanupStep('copy storage diagnostics', copyStorageDiagnostics, cleanupErrors);
await runCleanupStep('copy workspace diagnostics', copyWorkspaceDiagnostics, cleanupErrors);
await runCleanupStep('cleanup temporary run root', cleanupTemporaryRunRoot, cleanupErrors);
if (cleanupErrors.length > 0) {
cleanupFailed = true;
// Node prints an AggregateError without its `errors`, so a cleanup failure would otherwise
// reach CI as a bare "one or more steps failed" with nothing naming the step that broke.
const cleanupFailure = new AggregateError(
cleanupErrors,
`One or more E2E cleanup steps failed:\n ${cleanupErrors.map(error => error.stack ?? error.message).join('\n ')}`);
if (testFailure) {
console.error(cleanupFailure);
}
else {
testFailure = cleanupFailure;
}
}
}
if (testFailure) {
printFailureDiagnosticsSummary();
// Only completed test failures become advisory. Structured setup, spawn, signal, timeout, and
// cleanup failures keep the shard blocking even when mocha.json recorded completed test cases.
if (advisoryIssue && shouldAllowAdvisoryTestFailure(testFailure, readMochaResults(), cleanupFailed)) {
console.warn(`::warning title=VS Code extension E2E test failure advisory::${shardName} has completed test failures tracked by ${advisoryIssue}. Diagnostics were uploaded for investigation.`);
return;
}
throw testFailure;
}
printSuccessDiagnosticsSummary();
}
async function runCleanupStep(name, action, cleanupErrors) {
try {
await action();
}
catch (error) {
const cleanupError = error instanceof Error ? error : new Error(String(error));
cleanupError.message = `${name}: ${cleanupError.message}`;
cleanupErrors.push(cleanupError);
}
}
function resolveCliPath() {
if (process.env.ASPIRE_EXTENSION_E2E_CLI_PATH) {
const configuredPath = path.resolve(process.env.ASPIRE_EXTENSION_E2E_CLI_PATH);
if (!fs.existsSync(configuredPath)) {
throw new Error(`ASPIRE_EXTENSION_E2E_CLI_PATH points to a missing file: ${configuredPath}`);
}
return configuredPath;
}
if (process.env.CI) {
throw new Error('ASPIRE_EXTENSION_E2E_CLI_PATH is required in CI so E2E tests run against a known Aspire CLI build.');
}
const candidatePaths = process.platform === 'win32'
? [
path.join(repoRoot, 'artifacts', 'bin', 'aspire', 'Debug', 'net10.0', 'aspire.exe'),
path.join(repoRoot, 'artifacts', 'bin', 'Aspire.Cli', 'Debug', 'net10.0', 'aspire.exe'),
]
: [
path.join(repoRoot, 'artifacts', 'bin', 'aspire', 'Debug', 'net10.0', 'aspire'),
path.join(repoRoot, 'artifacts', 'bin', 'Aspire.Cli', 'Debug', 'net10.0', 'aspire'),
];
const candidatePath = candidatePaths.find(p => fs.existsSync(p));
if (!candidatePath) {
throw new Error(`ASPIRE_EXTENSION_E2E_CLI_PATH is not set and no local Aspire CLI was found. Checked: ${candidatePaths.join(', ')}`);
}
return candidatePath;
}
function isolateCliPath(resolvedCliPath) {
const sourceDirectory = path.dirname(resolvedCliPath);
const isolatedDirectory = path.join(shortRunRoot, 'cli');
fs.rmSync(isolatedDirectory, { recursive: true, force: true });
fs.cpSync(sourceDirectory, isolatedDirectory, { recursive: true });
fs.rmSync(path.join(isolatedDirectory, '.aspire-install.json'), { force: true });
const isolatedCliPath = path.join(isolatedDirectory, path.basename(resolvedCliPath));
if (!fs.existsSync(isolatedCliPath)) {
throw new Error(`Isolated Aspire CLI copy did not contain ${path.basename(resolvedCliPath)} from ${sourceDirectory}.`);
}
if (process.platform !== 'win32') {
fs.chmodSync(isolatedCliPath, fs.statSync(isolatedCliPath).mode | 0o700);
}
return isolatedCliPath;
}
function validateCliPath(resolvedCliPath) {
const result = spawnSync(resolvedCliPath, ['--version'], {
cwd: extensionRoot,
env: getAspireCliEnvironment(),
shell: false,
encoding: 'utf8',
timeout: 60000,
});
if (result.error) {
throw new Error(`Unable to execute Aspire CLI at ${resolvedCliPath}: ${result.error.message}`);
}
if (result.status !== 0) {
throw new Error(`Aspire CLI at ${resolvedCliPath} failed --version with code ${result.status ?? `signal ${result.signal ?? 'unknown'}`}.\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`);
}
}
function resolveAzureFunctionsVsixPaths() {
if (!enableAzureFunctionsE2E) {
return [];
}
// Aspire advertises its azure-functions launch capability only when both the C# and
// Azure Functions extensions are installed. Install C# with its required .NET runtime
// dependency, plus the Azure Resource Groups extension that Functions activates directly.
// All dependencies must be explicit because the E2E VS Code instance runs offline.
return [
{
displayName: '.NET Install Tool',
path: resolveRequiredVsixPath('ASPIRE_EXTENSION_E2E_DOTNET_RUNTIME_VSIX'),
},
{
displayName: 'C#',
path: resolveRequiredVsixPath('ASPIRE_EXTENSION_E2E_CSHARP_VSIX'),
},
{
displayName: 'Azure Resource Groups',
path: resolveRequiredVsixPath('ASPIRE_EXTENSION_E2E_AZURE_RESOURCE_GROUPS_VSIX'),
},
{
displayName: 'Azure Functions',
path: resolveRequiredVsixPath('ASPIRE_EXTENSION_E2E_AZURE_FUNCTIONS_VSIX'),
},
];
}
/**
* Copies the Java Spring Boot playground into the run's workspace.
*
* The playground cannot be used as the workspace root directly, because `prepareWorkspaceFixture`
* deletes and rewrites whatever it is pointed at. Copying also keeps each run reproducible: the
* generated SDK, the Gradle build output, and the language server's own `bin/` all start absent, so
* a test asserting that build inputs were not copied into the output directory is measuring this
* run rather than whatever a previous local build left behind.
*/
function copyJavaPlaygroundIntoWorkspace(bundledCliPath) {
if (!enableJavaE2E) {
return;
}
const source = path.join(repoRoot, 'playground', 'JavaSpringBoot');
if (!fs.existsSync(source)) {
throw new Error(`The Java E2E specs require the Java playground at ${source}.`);
}
assertWorkspaceRootIsNotGitIgnored();
// `.aspire/` is generated rather than checked in, so it has to exist before the copy: it is what
// the AppHost's `import aspire.*` statements resolve against, and the generated sources are the
// very thing the diagnostics test measures.
ensureJavaAppHostSdkGenerated(bundledCliPath, path.join(source, 'JavaSpringBoot.AppHost.Java'));
logStep('Copying the Java Spring Boot playground into the E2E workspace');
fs.cpSync(source, workspaceRoot, {
recursive: true,
// Anything the language server or a build produced locally would defeat the point of a clean
// run, and `bin/` in particular is what one of the tests asserts about. `.aspire/` is kept
// deliberately - it holds the generated SDK under test.
filter: sourcePath => !/[\\/](?:\.gradle|build|bin|target|node_modules)(?:[\\/]|$)/.test(sourcePath),
});
// The scaffolded settings point at the isolated CLI copy, which the Java AppHost needs just as
// much as the C# one. Merge rather than replace so that stays in effect.
const settingsPath = path.join(workspaceRoot, '.vscode', 'settings.json');
const settings = fs.existsSync(settingsPath) ? JSON.parse(fs.readFileSync(settingsPath, 'utf8')) : {};
// A Gradle import that fetches wrapper distributions and toolchains on demand takes far longer
// than the language server's default readiness window, and an unimported project reports every
// Aspire import as unresolved.
settings['java.import.gradle.wrapper.enabled'] = true;
settings['java.configuration.updateBuildConfiguration'] = 'automatic';
// The language server keeps its project metadata, and therefore its compiler output, in its own
// workspace storage by default. That hides the directories the "does not copy build inputs" spec
// asserts about: with nothing under the project's own bin/, the spec passes without ever
// observing what the build produced. Putting the metadata back at the project root is what makes
// that assertion able to fail.
settings['java.import.generatesMetadataFilesAtProjectRoot'] = true;
fs.writeFileSync(settingsPath, JSON.stringify(settings, undefined, 2));
// The scaffolded C# fixture cannot coexist with a repository-internal workspace: it inherits the
// repository's central package management and fails to restore with NU1507. The Java spec never
// uses it, so remove it and unpin the pinned AppHost so discovery finds the Java AppHost.
for (const scaffolded of ['AspireE2E.AppHost', 'AspireE2E.Worker']) {
fs.rmSync(path.join(workspaceRoot, scaffolded), { recursive: true, force: true });
}
fs.rmSync(path.join(workspaceRoot, 'aspire.config.json'), { force: true });
}
function prepareJavaWorkspace(bundledCliPath, appHostSdkVersion) {
if (!enableJavaE2E) {
return;
}
if (!useJavaStarterWorkspace) {
copyJavaPlaygroundIntoWorkspace(bundledCliPath);
return;
}
assertWorkspaceRootIsNotGitIgnored();
logStep('Generating the Java starter in the E2E workspace');
for (const entry of fs.readdirSync(workspaceRoot)) {
fs.rmSync(path.join(workspaceRoot, entry), { recursive: true, force: true });
}
const result = spawnSync(bundledCliPath, [
'new',
'aspire-java-starter',
'--name',
'JavaStarter',
'--output',
workspaceRoot,
'--version',
appHostSdkVersion,
'--localhost-tld',
'false',
'--suppress-agent-init',
'--non-interactive',
'--nologo',
], {
cwd: extensionRoot,
env: getAspireCliEnvironment(),
shell: false,
encoding: 'utf8',
timeout: 600000,
});
if (result.error) {
throw new Error(`Unable to generate the Java starter: ${result.error.message}`);
}
if (result.status !== 0) {
throw new Error(`Generating the Java starter failed with code ${result.status ?? `signal ${result.signal ?? 'unknown'}`}.
stdout:
${result.stdout}
stderr:
${result.stderr}`);
}
fs.writeFileSync(workspaceMarkerFile, `${runId}\n`);
ensureJavaAppHostSdkGenerated(bundledCliPath, workspaceRoot);
const settingsPath = path.join(workspaceRoot, '.vscode', 'settings.json');
const settings = fs.existsSync(settingsPath) ? JSON.parse(fs.readFileSync(settingsPath, 'utf8')) : {};