@@ -15,21 +15,20 @@ const P3_COMPONENT_FIXTURES_DIR = join(COMPONENT_FIXTURES_DIR, 'p3');
1515
1616suite ( 'Context (WASI P3)' , ( ) => {
1717 test ( 'context.get/set (sync export, sync call)' , async ( ) => {
18- const componentName = 'context-sync' ;
19- const componentPath = join (
20- P3_COMPONENT_FIXTURES_DIR ,
21- componentName ,
22- 'component.wasm'
23- ) ;
18+ const name = 'context-sync' ;
2419
2520 // NOTE: Despite not specifying the export as async (via jco transpile options in setupAsyncTest),
2621 // the export is async -- since the component lifted the function in an async manner.
2722 //
2823 // This test performs a sync call of an async lifted export.
2924 const { instance, cleanup } = await setupAsyncTest ( {
3025 component : {
31- name : componentName ,
32- path : componentPath ,
26+ name,
27+ path : join (
28+ P3_COMPONENT_FIXTURES_DIR ,
29+ name ,
30+ 'component.wasm'
31+ ) ,
3332 } ,
3433 } ) ;
3534
@@ -42,19 +41,17 @@ suite('Context (WASI P3)', () => {
4241 await cleanup ( ) ;
4342 } ) ;
4443
45- // TODO: re-enable after support of async task results
4644 test ( 'context.get/set (async export, async porcelain)' , async ( ) => {
47- const componentName = 'context-async' ;
48- const componentPath = join (
49- P3_COMPONENT_FIXTURES_DIR ,
50- componentName ,
51- 'component.wasm'
52- ) ;
45+ const name = 'context-async' ;
5346 const { instance, cleanup } = await setupAsyncTest ( {
5447 asyncMode : 'jspi' ,
5548 component : {
56- name : componentName ,
57- path : componentPath ,
49+ name,
50+ path : join (
51+ P3_COMPONENT_FIXTURES_DIR ,
52+ name ,
53+ 'component.wasm'
54+ ) ,
5855 } ,
5956 jco : {
6057 transpile : {
@@ -73,41 +70,49 @@ suite('Context (WASI P3)', () => {
7370 assert . strictEqual ( instance . pullContext instanceof AsyncFunction , true ) ;
7471
7572 await instance . pushContext ( 42 ) ;
76- // NOTE: context is wiped from task to task, and sync call tasks end as soon as they return
73+ // NOTE: context is wiped from task to task
7774 expect ( await instance . pullContext ( ) ) . toEqual ( 0 ) ;
7875
7976 await cleanup ( ) ;
8077 } ) ;
8178
82- // TODO: re-enable after support of async task results
83- // TODO: support *Sync() variants of task fns like yield()
84- test ( 'context.get/set (async export, sync porcelain)' , async ( ) => {
85- const componentName = 'context-async' ;
86- const componentPath = join (
87- P3_COMPONENT_FIXTURES_DIR ,
88- componentName ,
89- 'component.wasm'
90- ) ;
79+ /*
80+ * TODO: enable support of sync lowering an async export that does NOT
81+ * perform any calls to async imports (YIELD = no-op, WAIT / POLL = trap).
82+ *
83+ * In those cases, we must perform the waiting and checking synchronously,
84+ * and not force the function to be a promise.
85+ *
86+ * The check of whether functions require porcelain is the ONLY indicator that should
87+ * be used (rather than whether the function itself is async) as that's how we currently
88+ * express the choice of how we lower an import.
89+ */
90+ test . skip ( 'context.get/set (async export, sync porcelain)' , async ( ) => {
91+ const name = 'context-async' ;
9192 const { instance, cleanup } = await setupAsyncTest ( {
9293 component : {
93- name : componentName ,
94- path : componentPath ,
94+ name,
95+ path : join (
96+ P3_COMPONENT_FIXTURES_DIR ,
97+ name ,
98+ 'component.wasm'
99+ ) ,
95100 } ,
96101 } ) ;
97102
98- // TODO: we need to support sync porcelain on async exports...
99- // This means doing stuff like yieldSync etc
100-
101103 expect ( instance . pushContext ) . toBeTruthy ( ) ;
102104 assert . strictEqual (
103105 instance . pushContext instanceof AsyncFunction ,
104- false
106+ false , // see TODO for test
107+ "despite sync lower, async lift forces this function to be async" ,
105108 ) ;
106109
107110 expect ( instance . pullContext ) . toBeTruthy ( ) ;
108111 assert . strictEqual (
109112 instance . pullContext instanceof AsyncFunction ,
110- false
113+ false , // see TODO for test
114+ 'pullContext should not be an async function' ,
115+
111116 ) ;
112117
113118 instance . pushContext ( 42 ) ;
0 commit comments