-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
37 lines (32 loc) · 949 Bytes
/
pre-commit
File metadata and controls
37 lines (32 loc) · 949 Bytes
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
32
33
34
35
36
#!/usr/bin/python
import sys
import subprocess
import glob
try:
p = subprocess.check_call([r"/usr/bin/g++", "-Wall", "-o", "test", "prog.cpp"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print("SUCCESS")
except subprocess.CalledProcessError as grepx:
print("Compilation error in file")
p.terminate()
for file in glob.glob("test*.cpp"):
s = file.split(".")
o = s[0]
try:
p = subprocess.Popen([r"/usr/bin/g++", "-Wall", "-o", o, file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print("SUCCESS")
except subprocess.CalledProcessError as grepx:
print("Compilation error in " + file)
raise SystemExit(1)
#for file in tests:
# try:
# s = file.split(".")
# ex = s[0]
# p = subprocess.Popen(["./" + ex], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# p.communicate()
# success += 1
# count += 1
# print("Test suceeded")
#
# except subprocess.CalledProcessError as grepx:
# print("Test failed")
# count += 1