File: test

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (31 lines) | stat: -rwxr-xr-x 890 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
import glob, os, sys

fail = 0
for t in sorted(glob.glob('*.ngc')):
    sys.stderr.write("# {}".format(t))
    error = open(t).readline()
    if error.startswith(';'): expected = error[1:-1]
    elif error.startswith('('): expected = error[1:-2]
    else: expected = "%s: Test does not specify expected error" % t
    p = os.popen("rs274 -g %s 2>&1 > /dev/null" % t)
    output = p.readlines()
    r = p.close()
    print("# -> {}".format(r))
    if not r:
        print("%s: Interpreter accepted bad gcode" % t)
        fail += 1
        continue

    if len(output) < 2:
        print("%s: Unexpected interpreter output: %r" % output)
        fail += 1
        continue

    err = output[-2].strip()
    if err != expected:
        print("%s: Expected %r, got %r instead" % (t, expected, err))
        fail += 1

if fail:
    raise SystemExit("%d failures" % fail)