Skip to content
Newer
Older
100644 95 lines (87 sloc) 2.88 KB
08a19a2 @jckarter test-installation.py script to smoke-test install
authored
1 from subprocess import check_call, CalledProcessError
2 import fnmatch
3 import sys
4 import os
5 import shutil
488da41 @jckarter touch up test-installation.py on windows
authored
6 import stat
08a19a2 @jckarter test-installation.py script to smoke-test install
authored
7
8 def call_or_false(argv, expectedcode=0):
9 try:
10 check_call(argv)
11 return True
12 except OSError as ex:
13 print "--- No!", ex
14 return False
15 except CalledProcessError as ex:
16 if (ex.returncode != expectedcode):
17 print "--- No! Error code", ex.returncode
18 sys.exit(1)
19 else:
20 return True
21
22 def call_or_die(argv, expectedcode=0):
23 if not call_or_false(argv, expectedcode):
24 sys.exit(1)
25
26 def cleanup(f):
27 try:
28 os.remove(f)
29 except OSError:
30 pass
31
32 print "--- Is the compiler on the path and runnable?"
33 call_or_die(["clay"], 2)
34 print "--- Does it respond to `--help`?"
35 call_or_die(["clay", "--help"], 2)
36 print "--- Does it respond to `/?`?"
37 call_or_die(["clay", "/?"], 2)
38 print "--- Can it compile `examples/hello.clay`?"
39 call_or_die(["clay", "examples/hello.clay"])
40 try:
41 print "--- Is the result executable?"
42 call_or_die(["./hello"])
43 finally:
44 cleanup("hello")
45 cleanup("hello.exe")
46
47 print "--- Is clay-fix on the path and runnable?"
48 if call_or_false(["clay-fix"], 2):
49 print "--- Does it respond to `--help`?"
50 call_or_die(["clay-fix", "--help"], 2)
51 print "--- Does it respond to `/?`?"
52 call_or_die(["clay-fix", "--help"], 2)
53 print "--- Creating a temporary v0.0 clone..."
488da41 @jckarter touch up test-installation.py on windows
authored
54 git = "git"
55 if sys.platform == "win32":
56 git = "git.cmd"
57 call_or_die([git, "clone", ".", "tempv0.0", "-b", "v0.0"])
08a19a2 @jckarter test-installation.py script to smoke-test install
authored
58 try:
59 print "--- How much clay can clay-fix fix?"
60 libfiles = []
61 for root, dirnames, filenames in os.walk('tempv0.0/lib-clay'):
62 for filename in fnmatch.filter(filenames, '*.clay'):
63 libfiles.append(os.path.join(root, filename))
64 call_or_die(["clay-fix", "-v", "0.0"] + libfiles)
65 finally:
66 print "--- Cleaning up temporary v0.0 clone..."
488da41 @jckarter touch up test-installation.py on windows
authored
67
68 def onerror(f, p, x):
69 if not os.access(p, os.W_OK):
70 os.chmod(p, stat.S_IWUSR)
71 f(p)
72 else:
73 raise
74 shutil.rmtree("tempv0.0", onerror=onerror)
08a19a2 @jckarter test-installation.py script to smoke-test install
authored
75 else:
76 print "--- clay-fix not found; I'll assume it wasn't installed"
77
78 print "--- Is clay-bindgen on the path and runnable?"
79 if call_or_false(["clay-bindgen"], 2):
80 print "--- Does it respond to `--help`?"
81 call_or_die(["clay-bindgen", "--help"], 2)
82 print "--- Does it respond to `/?`?"
83 call_or_die(["clay-bindgen", "--help"], 2)
84 print "--- Making a test C header file..."
85 temph = open("temp-stdio.h", "w")
86 try:
87 temph.write("#include <stdio.h>\n")
88 temph.close()
89 print "--- Can clay-bindgen generate bindings for `stdio.h`?"
90 call_or_die(["clay-bindgen", "temp-stdio.h"])
91 finally:
92 cleanup("temp-stdio.h")
93 else:
94 print "--- clay-bindgen not found; I'll assume it wasn't installed"
Something went wrong with that request. Please try again.