File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
packages/npm-packages/ruby-wasm-wasi/test Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,17 @@ import { WASI } from "wasi";
4
4
import { RubyVM } from "../src/index" ;
5
5
import * as preview2Shim from "@bytecodealliance/preview2-shim"
6
6
7
- const rubyModule = ( async ( ) => {
7
+ const memoize = ( fn ) => {
8
+ let result ;
9
+ return async ( ) => {
10
+ if ( ! result ) {
11
+ result = await fn ( ) ;
12
+ }
13
+ return result ;
14
+ } ;
15
+ } ;
16
+
17
+ const getRubyModule = memoize ( async ( ) => {
8
18
let binaryPath ;
9
19
if ( process . env . RUBY_ROOT ) {
10
20
binaryPath = path . join ( process . env . RUBY_ROOT , "./usr/local/bin/ruby" ) ;
@@ -18,7 +28,7 @@ const rubyModule = (async () => {
18
28
}
19
29
const binary = await fs . readFile ( binaryPath ) ;
20
30
return await WebAssembly . compile ( binary . buffer ) ;
21
- } ) ( ) ;
31
+ } ) ;
22
32
23
33
const initModuleRubyVM = async ( { suppressStderr } = { suppressStderr : false } ) => {
24
34
let preopens = { } ;
@@ -38,7 +48,7 @@ const initModuleRubyVM = async ({ suppressStderr } = { suppressStderr: false })
38
48
preopens,
39
49
} ) ;
40
50
41
- const module = await rubyModule ;
51
+ const module = await getRubyModule ( ) ;
42
52
const { vm } = await RubyVM . instantiateModule ( { module, wasip1 : wasi } )
43
53
return vm ;
44
54
} ;
Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ const initRubyVM = async (rubyModule, args) => {
32
32
} ;
33
33
34
34
describe ( "Packaging validation" , ( ) => {
35
- if ( ! process . env . RUBY_NPM_PACKAGE_ROOT ) {
35
+ if (
36
+ ! process . env . RUBY_NPM_PACKAGE_ROOT ||
37
+ ( process . env . ENABLE_COMPONENT_TESTS && process . env . ENABLE_COMPONENT_TESTS !== 'false' )
38
+ ) {
36
39
test . skip ( "skip" , ( ) => { } ) ;
37
40
return ;
38
41
}
You can’t perform that action at this time.
0 commit comments