Skip to content

Commit bf37733

Browse files
authored
Fix auto_update_tests for printing/minifier tests (#1071)
It was using wasm-shell instead of wasm-opt to print. This was emitting an error and empty output. Also this means that the min.wast test input didn't get updated along with the spec, so I fixed that as well.
1 parent bc46556 commit bf37733

4 files changed

Lines changed: 121 additions & 3 deletions

File tree

auto_update_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@
7878
if t.endswith('.wast'):
7979
print '..', t
8080
wasm = os.path.basename(t).replace('.wast', '')
81-
cmd = WASM_SHELL + [os.path.join('test', 'print', t), '--print']
81+
cmd = WASM_OPT + [os.path.join('test', 'print', t), '--print']
8282
print ' ', ' '.join(cmd)
8383
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
84+
print cmd, actual, err
8485
with open(os.path.join('test', 'print', wasm + '.txt'), 'w') as o: o.write(actual)
85-
cmd = WASM_SHELL + [os.path.join('test', 'print', t), '--print-minified']
86+
cmd = WASM_OPT + [os.path.join('test', 'print', t), '--print-minified']
8687
print ' ', ' '.join(cmd)
8788
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
8889
with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w') as o: o.write(actual)

test/print/min.minified.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(module(type $0 (func(param f32)(result f32)))(type $1 (func(param i32 i32)(result f32)))(type $2 (func(param i32)(result i32)))(type $3 (func(param i32 i32 i32)(result i32)))(memory $0 256 256)
2+
(export "floats" (func $floats))(func $floats(type $0)(param $f f32)(result f32)(local $t f32)(f32.add(get_local $t)(get_local $f)))(func $neg(type $1)(param $k i32)(param $p i32)(result f32)(local $n f32)(tee_local $n(f32.neg(block $block0 (result f32)(i32.store(get_local $k)(get_local $p))(f32.load(get_local $k))))))(func $littleswitch(type $2)(param $x i32)(result i32)(block $topmost (result i32)(block $switch-case$2(block $switch-case$1(br_table $switch-case$1 $switch-case$2 $switch-case$1(i32.sub(get_local $x)(i32.const 1))))
3+
(br $topmost(i32.const 1)))
4+
(br $topmost(i32.const 2))(i32.const 0)))(func $f1(type $3)(param $i1 i32)(param $i2 i32)(param $i3 i32)(result i32)(block $topmost (result i32)(get_local $i3))))

test/print/min.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
(module
2+
(type $0 (func (param f32) (result f32)))
3+
(type $1 (func (param i32 i32) (result f32)))
4+
(type $2 (func (param i32) (result i32)))
5+
(type $3 (func (param i32 i32 i32) (result i32)))
6+
(memory $0 256 256)
7+
(export "floats" (func $floats))
8+
(func $floats (type $0) (param $f f32) (result f32)
9+
(local $t f32)
10+
(f32.add
11+
(get_local $t)
12+
(get_local $f)
13+
)
14+
)
15+
(func $neg (type $1) (param $k i32) (param $p i32) (result f32)
16+
(local $n f32)
17+
(tee_local $n
18+
(f32.neg
19+
(block $block0 (result f32)
20+
(i32.store
21+
(get_local $k)
22+
(get_local $p)
23+
)
24+
(f32.load
25+
(get_local $k)
26+
)
27+
)
28+
)
29+
)
30+
)
31+
(func $littleswitch (type $2) (param $x i32) (result i32)
32+
(block $topmost (result i32)
33+
(block $switch-case$2
34+
(block $switch-case$1
35+
(br_table $switch-case$1 $switch-case$2 $switch-case$1
36+
(i32.sub
37+
(get_local $x)
38+
(i32.const 1)
39+
)
40+
)
41+
)
42+
(br $topmost
43+
(i32.const 1)
44+
)
45+
)
46+
(br $topmost
47+
(i32.const 2)
48+
)
49+
(i32.const 0)
50+
)
51+
)
52+
(func $f1 (type $3) (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32)
53+
(block $topmost (result i32)
54+
(get_local $i3)
55+
)
56+
)
57+
)

test/print/min.wast

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
(module(memory 256 256)(export "floats" $floats)(func $floats(param $f f32)(result f32)(local $t f32)(f32.add(get_local $t)(get_local $f)))(func $neg(param $k i32)(param $p i32)(result f32)(local $n f32)(set_local $n(f32.neg(block $block0(i32.store(get_local $k)(get_local $p))(f32.load(get_local $k))))))(func $littleswitch(param $x i32)(result i32)(block $topmost(tableswitch $switch$0(i32.sub(get_local $x)(i32.const 1))(table(case $switch-case$1)(case $switch-case$2)) (case $switch-case$1)(case $switch-case$1(br $topmost(i32.const 1)))(case $switch-case$2(br $topmost(i32.const 2))))(i32.const 0)))(func $f1(param $i1 i32)(param $i2 i32)(param $i3 i32)(result i32)(block $topmost(get_local $i3))))
1+
(module
2+
(type $0 (func (param f32) (result f32)))
3+
(type $1 (func (param i32 i32) (result f32)))
4+
(type $2 (func (param i32) (result i32)))
5+
(type $3 (func (param i32 i32 i32) (result i32)))
6+
(memory $0 256 256)
7+
(export "floats" (func $floats))
8+
(func $floats (type $0) (param $f f32) (result f32)
9+
(local $t f32)
10+
(f32.add
11+
(get_local $t)
12+
(get_local $f)
13+
)
14+
)
15+
(func $neg (type $1) (param $k i32) (param $p i32) (result f32)
16+
(local $n f32)
17+
(tee_local $n
18+
(f32.neg
19+
(block $block0 (result f32)
20+
(i32.store
21+
(get_local $k)
22+
(get_local $p)
23+
)
24+
(f32.load
25+
(get_local $k)
26+
)
27+
)
28+
)
29+
)
30+
)
31+
(func $littleswitch (type $2) (param $x i32) (result i32)
32+
(block $topmost (result i32)
33+
(block $switch-case$2
34+
(block $switch-case$1
35+
(br_table $switch-case$1 $switch-case$2 $switch-case$1
36+
(i32.sub
37+
(get_local $x)
38+
(i32.const 1)
39+
)
40+
)
41+
)
42+
(br $topmost
43+
(i32.const 1)
44+
)
45+
)
46+
(br $topmost
47+
(i32.const 2)
48+
)
49+
(i32.const 0)
50+
)
51+
)
52+
(func $f1 (type $3) (param $i1 i32) (param $i2 i32) (param $i3 i32) (result i32)
53+
(block $topmost (result i32)
54+
(get_local $i3)
55+
)
56+
)
57+
)

0 commit comments

Comments
 (0)