Skip to content

Commit

Permalink
Updated test output format
Browse files Browse the repository at this point in the history
  • Loading branch information
Checkmate50 committed Jun 11, 2019
1 parent 89c674b commit d3e10d5
Show file tree
Hide file tree
Showing 46 changed files with 172 additions and 376 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"devDependencies": {
"typescript": "^3.3.3"
},
"dependencies": {
"@types/gl-matrix": "^2.4.0",
"gl-matrix": "^2.8.1",
"express": "^4.16.4"
}
}
55 changes: 43 additions & 12 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import random
import argparse
import sys
import re

parser = argparse.ArgumentParser(description="Flip a switch by setting a flag")
# Flag for CircleCI build
parser.add_argument('-b', action='store_true')
# Flag for typescript
parser.add_argument('-t', action='store_true')

args = parser.parse_args()

Expand Down Expand Up @@ -66,6 +69,7 @@ def test_exception(outname, expectname):


def main():
use_typescript = args.t
success_symbols, fail_symbols = get_symbols()
any_fails = False # Trick to avoid printing excess successes
for path, _, files in os.walk("test/"):
Expand All @@ -77,27 +81,54 @@ def main():
basename = filename[:-4] # Remove the extension
outname = basename + ".out"
expectname = basename + ".expect"
ling_args = [] if path == "test/compiler" else ["-t"] if path == "test/compiler_ts" else ["-i"]
ling_args = [] if path == "test/compiler" else \
["-t"] if path == "test/compiler_ts" or use_typescript else ["-i"]
with open(outname, "w") as f:
subprocess.call(
["lingc"] + ling_args + [filename],
stdout=f,
stderr=f,
)
if use_typescript:
# https://stackoverflow.com/questions/19020557/redirecting-output-of-pipe-to-a-file-in-python
p1 = subprocess.Popen(
["lingc"] + ling_args + [filename],
stdout=subprocess.PIPE, stderr=f
)
p2 = subprocess.Popen(
["ts-node"],
stdin=subprocess.PIPE, stdout=f, stderr=f
)
p1_out = p1.communicate()[0]
if (len(p1_out) > 0): # Errors go straight to the file
p2.communicate(p1_out)
else:
subprocess.call(
["lingc"] + ling_args + [filename],
stdout=f, stderr=f,
)
# We write and then read to avoid memory shenanigans
# (this might be worse actually, but I don't think it matters)
try:
if not filecmp.cmp(outname, expectname) \
and not test_exception(outname, expectname):
failed = False
if use_typescript:
with open(outname) as outfile, open(expectname) as expectfile:
for outline, expectline in zip(outfile, expectfile):
# Replace floats with integers (eg 5. with 5)
expectline = re.sub("([0-9]+)\.([^0-9])", "\1\2", expectline)
#
expectline = re.sub("([0-9]+)\.([^0-9])", "\1\2", expectline)
# print(expectline)
failed = failed and not outline == expectline
else:
failed = not filecmp.cmp(outname, expectname) \
and not test_exception(outname, expectname)
# exit()
if failed:
any_fails = True
print("\t " + basename + " " +
random.choice(fail_symbols))
print("\t❌ " + basename + " " +
random.choice(fail_symbols))
except IOError:
any_fails = True
print("\t " + expectname + " not found " +
print("\t❌ " + expectname + " not found " +
random.choice(fail_symbols))
if not any_fails:
print("No 👏 Failures 👏")
print("No 👏 Failures 👏")
for _ in range(SUCCESS_COUNT):
print(random.choice(success_symbols) + " "),
print("") # newline
Expand Down
8 changes: 8 additions & 0 deletions test/basics/aasample.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[0.8, -1.]
[1.1, 4.]
[6., -8., 10.6]
[6., 8.4, -10.]
[5., 0.5]
7.
[0.7, 0.7]
[0.5, 0.9]
5 changes: 5 additions & 0 deletions test/basics/aasample.jsout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Float32Array [ 0.800000011920929, -1 ]
Float32Array [ 1.0999999046325684, 4 ]
Float32Array [ 6, -8, 10.600000381469727 ]
Float32Array [ 6, 8.399999618530273, -10 ]
Float32Array [ 5, 0.48000001907348633 ]
File renamed without changes.
10 changes: 5 additions & 5 deletions test/basics/datatypes.expect
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1
4.
0.3
vec1(1.)
vec3(1., 2., 3.)
((1., 2.), (3., 4.))
vec0()
((), ())
[1.]
[1., 2., 3.]
[[1., 2.], [3., 4.]]
[]
[[], []]
Empty file removed test/basics/empty.expect
Empty file.
3 changes: 0 additions & 3 deletions test/basics/empty.lgl

This file was deleted.

Empty file removed test/basics/int.expect
Empty file.
3 changes: 0 additions & 3 deletions test/basics/int.lgl

This file was deleted.

10 changes: 5 additions & 5 deletions test/basics/mat_ops.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
((-1.2), (-1.))
((6., 8.), (10., 1.2))
((1., -0.8, 10.))
((14.), (13.))
((5., 4., 9.), (7., 5., 12.))
[[-1.2], [-1.]]
[[6., 8.], [10., 1.2]]
[[1., -0.8, 10.]]
[[14.], [13.]]
[[5., 4., 9.], [7., 5., 12.]]
5 changes: 5 additions & 0 deletions test/basics/mat_ops.jsout
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Float32Array [ -1.2000000476837158, -1, 0, 0 ]
Float32Array [ 6, 10, 8, 1.2000000476837158 ]
Float32Array [ 1, 0, 0, -0.800000011920929, 0, 0, 10, 0, 0 ]
Float32Array [ 14, 13, 0, 0 ]
Float32Array [ 5, 7, 0, 4, 5, 0, 9, 12, 0 ]
4 changes: 2 additions & 2 deletions test/basics/op_order.expect
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
11
vec2(1., 2.)
((4., 4., 4.), (4., 4., 4.))
[1., 2.]
[[4., 4., 4.], [4., 4., 4.]]
true
true
false
Expand Down
8 changes: 0 additions & 8 deletions test/basics/vec_ops.expect

This file was deleted.

2 changes: 1 addition & 1 deletion test/casts/abstract.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vec3(2., 2., 2.)
[2., 2., 2.]
8 changes: 4 additions & 4 deletions test/casts/basics.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vec2(1., 2.)
vec3(5., 4., 2.)
vec3(6., 6., 3.)
vec3(19., 20., 11.)
[1., 2.]
[5., 4., 2.]
[6., 6., 3.]
[19., 20., 11.]
16 changes: 8 additions & 8 deletions test/casts/core.expect
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vec2(1., 1.)
vec2(0., 1.)
vec2(1., 2.)
vec2(0., 1.)
vec2(1.5, -1.2)
vec2(1., -3.)
vec2(5., -4.)
vec2(1., -3.)
[1., 1.]
[0., 1.]
[1., 2.]
[0., 1.]
[1.5, -1.2]
[1., -3.]
[5., -4.]
[1., -3.]
8 changes: 4 additions & 4 deletions test/casts/fn_basics.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vec2(2., 3.)
vec2(1., 2.)
vec2(5., 7.)
vec2(1., 2.)
[2., 3.]
[1., 2.]
[5., 7.]
[1., 2.]
10 changes: 5 additions & 5 deletions test/casts/functions.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vec2(3., 3.)
vec2(6., 9.)
vec3(1., 1., 1.)
vec2(1., 1.)
vec2(6., 9.)
[3., 3.]
[6., 9.]
[1., 1., 1.]
[1., 1.]
[6., 9.]
10 changes: 5 additions & 5 deletions test/casts/par_app.expect
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0.57735026919
vec4(1.5, 1., 2., 1.5)
vec3(1.5, 1., 2.)
0.6
[1.5, 1., 2., 1.5]
[1.5, 1., 2.]
0.
vec3(-1., 1., 1.)
((0., -1., 0.), (1., 0.5, 0.), (1., 0., 1.))
[-1., 1., 1.]
[[0., -1., 0.], [1., 0.5, 0.], [1., 0., 1.]]
8 changes: 4 additions & 4 deletions test/casts/par_basics.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vec3(1., 1., 1.)
vec3(1., 2., 0.)
vec2(1., 2.)
vec3(0., 2., 1.)
[1., 1., 1.]
[1., 2., 0.]
[1., 2.]
[0., 2., 1.]
4 changes: 2 additions & 2 deletions test/functions/basics.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
6
0.2
true
vec2(1., 2.)
((1., 0.), (0., 1.))
[1., 2.]
[[1., 0.], [0., 1.]]
2 changes: 1 addition & 1 deletion test/functions/canon.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vec4(1., 1., 1., 1.)
[1., 1., 1., 1.]
6 changes: 3 additions & 3 deletions test/functions/chains.expect
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
2.
vec2(0.75, 1.5)
[0.8, 1.5]
9.
vec2(1.33333333333, 2.66666666667)
[1.3, 2.7]
6.
vec2(20., 16.)
[20., 16.]
14 changes: 7 additions & 7 deletions test/functions/par_app.expect
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0.57735026919
vec4(1.5, 1., 2., 1.5)
vec3(1.5, 1., 2.)
vec3(0., 0., 1.)
0.6
[1.5, 1., 2., 1.5]
[1.5, 1., 2.]
[0., 0., 1.]
0.
vec3(-1., -1., 1.)
vec3(-1., 1., 1.)
((0., -1., 0.), (1., 0.5, 0.), (1., 0., 1.))
[-1., -1., 1.]
[-1., 1., 1.]
[[0., -1., 0.], [1., 0.5, 0.], [1., 0., 1.]]
2 changes: 1 addition & 1 deletion test/generics/add_tags.expect
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vec3(1., 1., 1.)
[1., 1., 1.]
10 changes: 0 additions & 10 deletions test/generics/basics.expect

This file was deleted.

30 changes: 0 additions & 30 deletions test/generics/basics.lgl

This file was deleted.

8 changes: 4 additions & 4 deletions test/generics/basics_infer.expect
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
5
5.
5
vec2(1., 2.)
((1., 2.), (2., 1.))
[1., 2.]
[[1., 2.], [2., 1.]]
5
((1., 2.), (2., 1.), (2., 1.))
[[1., 2.], [2., 1.], [2., 1.]]
1
1
((1., 0.), (0., 1.))
[[1., 0.], [0., 1.]]
10 changes: 5 additions & 5 deletions test/generics/bounds.expect
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vec2(3., 2.)
vec3(3., 2., 2.)
vec2(1., 2.)
vec3(1., 2., 3.)
[3., 2.]
[3., 2., 2.]
[1., 2.]
[1., 2., 3.]
1.
2
vec3(0., 1., 2.)
[0., 1., 2.]
7 changes: 0 additions & 7 deletions test/generics/bounds_infer.expect

This file was deleted.

28 changes: 0 additions & 28 deletions test/generics/bounds_infer.lgl

This file was deleted.

5 changes: 0 additions & 5 deletions test/generics/core.expect

This file was deleted.

Loading

0 comments on commit d3e10d5

Please sign in to comment.