Skip to content

Commit c2d94c8

Browse files
authored
Use d8's writeFile in test_split_module. NFC (#24082)
1 parent e0ac117 commit c2d94c8

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

test/other/test_split_module.post.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ function saveProfileData() {
55
var offset = _malloc(len);
66
var actualLen = __write_profile(offset, len);
77
var profile_data = HEAPU8.subarray(offset, offset + len);
8-
if (typeof fs === 'undefined') {
9-
// TODO: Use D8's writeFile when
10-
// https://chromium-review.googlesource.com/c/v8/v8/+/4159854 lands.
11-
console.log(JSON.stringify(Array.from(profile_data)));
12-
} else {
8+
if (typeof writeFile !== 'undefined') {
9+
console.log('using writeFile')
10+
writeFile('profile.data', profile_data);
11+
} else if (typeof fs !== 'undefined') {
12+
console.log('using fs.writeFileSync')
1313
fs.writeFileSync('profile.data', profile_data);
14+
} else {
15+
console.log(JSON.stringify(Array.from(profile_data)));
1416
}
1517
console.log('profile size is', actualLen, 'bytes (allocated', len, 'bytes)');
1618
console.log('wrote profile data')

test/test_other.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -13373,12 +13373,7 @@ def test_split_module(self, customLoader, jspi, opt):
1337313373
self.require_jspi()
1337413374
self.emcc_args += ['-g', '-sJSPI_EXPORTS=say_hello']
1337513375
self.emcc_args += ['-sEXPORTED_FUNCTIONS=_malloc,_free']
13376-
output = self.do_other_test('test_split_module.c')
13377-
if self.js_engines == [config.V8_ENGINE]:
13378-
# TODO remove this when https://chromium-review.googlesource.com/c/v8/v8/+/4159854
13379-
# lands.
13380-
# d8 doesn't support writing a file yet, so extract it from the output.
13381-
create_file('profile.data', bytearray(json.loads(output[output.find('['):output.find(']') + 1])), True)
13376+
self.do_other_test('test_split_module.c')
1338213377
self.assertExists('test_split_module.wasm')
1338313378
self.assertExists('test_split_module.wasm.orig')
1338413379
self.assertExists('profile.data')

0 commit comments

Comments
 (0)