@@ -9,8 +9,8 @@ import * as log from './log'
99
1010const delay = ( ms : number ) => new Promise ( resolve => setTimeout ( resolve , ms ) )
1111
12- /** Fixed envbench environment name - one isolated Blockbench install for the action. */
13- const ENVIRONMENT = 'animated-java-ci'
12+ /** Default envbench environment name - one isolated Blockbench install for the action. */
13+ const DEFAULT_ENVIRONMENT = 'animated-java-ci'
1414
1515export interface RunningBlockbench {
1616 debugPort : number
@@ -46,12 +46,16 @@ function numericSemver(a: string, b: string): number {
4646 * Ensure the isolated Blockbench environment exists (downloading Blockbench on
4747 * first use) and return the path to its portable executable.
4848 */
49- async function ensurePortable ( eb : Envbench , blockbenchVersion : string ) : Promise < string > {
50- if ( ( await eb . environmentExists ( ENVIRONMENT ) ) !== 'env' ) {
49+ async function ensurePortable (
50+ eb : Envbench ,
51+ environment : string ,
52+ blockbenchVersion : string
53+ ) : Promise < string > {
54+ if ( ( await eb . environmentExists ( environment ) ) !== 'env' ) {
5155 log . info ( `Provisioning Blockbench (${ blockbenchVersion } ) via envbench...` )
5256 let lastPercent = - 1
5357 await eb . createEnvironment (
54- ENVIRONMENT ,
58+ environment ,
5559 { blockbenchVersion : blockbenchVersion as NamedBlockbenchVersion , force : true } ,
5660 {
5761 onDownloadStart : version => log . info ( `Downloading Blockbench ${ version } ` ) ,
@@ -66,7 +70,7 @@ async function ensurePortable(eb: Envbench, blockbenchVersion: string): Promise<
6670 )
6771 }
6872
69- const env = await eb . getEnvironment ( ENVIRONMENT )
73+ const env = await eb . getEnvironment ( environment )
7074 let version : ResolvedBlockbenchVersion | '' = ''
7175 try {
7276 version = await eb . resolveVersion ( env . blockbench_version )
@@ -91,11 +95,16 @@ async function ensurePortable(eb: Envbench, blockbenchVersion: string): Promise<
9195 * Launch Blockbench with the Chrome DevTools Protocol enabled and wait until its
9296 * endpoint answers. The caller is expected to already be running under
9397 * `xvfb-run` (the action wrapper does this) so no window appears.
98+ *
99+ * `environment` names the isolated envbench install, so separate tools don't share one.
94100 */
95- export async function launchBlockbench ( blockbenchVersion : string ) : Promise < RunningBlockbench > {
101+ export async function launchBlockbench (
102+ blockbenchVersion : string ,
103+ environment = DEFAULT_ENVIRONMENT
104+ ) : Promise < RunningBlockbench > {
96105 const eb = new Envbench ( )
97106 await eb . ensureStorageFolder ( )
98- const userDataDir = join ( eb . storageDir , ENVIRONMENT )
107+ const userDataDir = join ( eb . storageDir , environment )
99108
100109 // Clear a stale Chromium singleton lock a previously hard-killed run may have left.
101110 await killByUserData ( userDataDir )
@@ -107,11 +116,11 @@ export async function launchBlockbench(blockbenchVersion: string): Promise<Runni
107116 }
108117 }
109118
110- await ensurePortable ( eb , blockbenchVersion )
119+ await ensurePortable ( eb , environment , blockbenchVersion )
111120 grantFsPermission ( userDataDir , 'animated_java' )
112121 const debugPort = await getFreePort ( )
113122
114- const child = await eb . launch ( ENVIRONMENT , {
123+ const child = await eb . launch ( environment , {
115124 extraArgs : [
116125 `--remote-debugging-port=${ debugPort } ` ,
117126 '--remote-allow-origins=*' ,
0 commit comments