@@ -238,16 +238,27 @@ func Test_PackageWasm(t *testing.T) {
238
238
return expectedEnsureSubDirRuns .verifyExpectation (t , parent , name )
239
239
}
240
240
241
+ // Handle lookup for wasm_exec.js from lib folder in Go 1.24 and newer:
242
+ goroot := runtime .GOROOT ()
243
+ wasmExecJSPath := filepath .Join (goroot , "lib" , "wasm" , "wasm_exec.js" )
244
+ _ , err := os .Stat (wasmExecJSPath )
245
+ execJSLibExists := err == nil || ! os .IsNotExist (err )
246
+
241
247
expectedExistRuns := mockExistRuns {
242
248
expected : []mockExist {
243
249
{"myTest.wasm" , false },
244
250
{"myTest.wasm" , true },
251
+ {wasmExecJSPath , execJSLibExists },
245
252
},
246
253
}
247
254
utilExistsMock = func (path string ) bool {
248
255
return expectedExistRuns .verifyExpectation (t , path )
249
256
}
250
257
258
+ if ! execJSLibExists { // Expect location from Go < 1.24 to have been copied:
259
+ wasmExecJSPath = filepath .Join (goroot , "misc" , "wasm" , "wasm_exec.js" )
260
+ }
261
+
251
262
expectedWriteFileRuns := mockWriteFileRuns {
252
263
expected : []mockWriteFile {
253
264
{filepath .Join ("myTestTarget" , "wasm" , "index.html" ), nil },
@@ -265,15 +276,15 @@ func Test_PackageWasm(t *testing.T) {
265
276
expectedCopyFileRuns := mockCopyFileRuns {
266
277
expected : []mockCopyFile {
267
278
{source : "myTest.png" , target : filepath .Join ("myTestTarget" , "wasm" , "icon.png" )},
268
- {source : filepath . Join ( runtime . GOROOT (), "misc" , "wasm" , "wasm_exec.js" ) , target : filepath .Join ("myTestTarget" , "wasm" , "wasm_exec.js" )},
279
+ {source : wasmExecJSPath , target : filepath .Join ("myTestTarget" , "wasm" , "wasm_exec.js" )},
269
280
{source : "myTest.wasm" , target : filepath .Join ("myTestTarget" , "wasm" , "myTest.wasm" )},
270
281
},
271
282
}
272
283
utilCopyFileMock = func (source , target string ) error {
273
284
return expectedCopyFileRuns .verifyExpectation (t , false , source , target )
274
285
}
275
286
276
- err : = p .doPackage (wasmBuildTest )
287
+ err = p .doPackage (wasmBuildTest )
277
288
assert .Nil (t , err )
278
289
wasmBuildTest .verifyExpectation ()
279
290
expectedTotalCount (t , len (expectedEnsureSubDirRuns .expected ), expectedEnsureSubDirRuns .current )
0 commit comments