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
#!/usr/bin/env node
/**
* Basic test for RusTorch WASM examples
*/
import fs from 'fs';
import path from 'path';
console.log('๐งช Running RusTorch WASM tests...');
// Test 1: Check if WASM files exist
const pkgDir = './pkg';
const wasmFile = path.join(pkgDir, 'rustorch_bg.wasm');
const jsFile = path.join(pkgDir, 'rustorch.js');
if (!fs.existsSync(wasmFile)) {
console.error('โ WASM file not found:', wasmFile);
console.log('๐ก Run "npm run build-wasm" first');
process.exit(1);
}
if (!fs.existsSync(jsFile)) {
console.error('โ JS binding file not found:', jsFile);
console.log('๐ก Run "npm run build-wasm" first');
process.exit(1);
}
console.log('โ
WASM files found');
console.log('โ
JS binding files found');
// Test 2: Check file sizes
const wasmStats = fs.statSync(wasmFile);
const jsStats = fs.statSync(jsFile);
console.log(`๐ WASM file size: ${(wasmStats.size / 1024).toFixed(2)} KB`);
console.log(`๐ JS file size: ${(jsStats.size / 1024).toFixed(2)} KB`);
if (wasmStats.size < 1000) {
console.warn('โ ๏ธ WASM file seems too small, build might be incomplete');
process.exit(1);
}
console.log('โ
All tests passed!');
console.log('๐ RusTorch WASM examples are ready to run');