forked from fp2021-helper/fp2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint_filesystem.py
executable file
·49 lines (41 loc) · 1.26 KB
/
lint_filesystem.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import sys
import os.path
import subprocess
LASTDIR=sys.argv[1]
#print("Current working directory: {0}\n".format(os.getcwd()))
print("Going to run tests in $PWD...")
PKG_OPAM=f"./{LASTDIR}.opam"
if not os.path.isfile(f"{PKG_OPAM}"):
print(f"File {PKG_OPAM} does not exist. Exit\n")
exit(1)
errors_found=False
# A few warnings were disabled
# 21: Field 'opam-version' doesn't match the current version
subpr = subprocess.Popen(["opam", "lint", "-s", "--warnings=-21-23", f"{PKG_OPAM}"], stdout=subprocess.PIPE)
if subpr.wait() != 0:
print("Linting failed")
subpr_rez = subpr.stdout.read().decode('utf-8')
print(subpr_rez)
exit(1)
def check_spec(field):
pr = subprocess.Popen(["opam", "show", PKG_OPAM, "--field", field], stdout=subprocess.PIPE)
if pr.wait() != 0:
sys.stderr.write(f"Can't read field {field}\n")
errors_found = True
else:
rez = pr.stdout.read().decode('utf-8').rstrip()
if rez.find("FIXME") != -1:
sys.stderr.write(f"Wrong value of the field '{field}': {rez}\n")
if LASTDIR != "Lambda":
errors_found = True
else:
print(f"decent value {rez}")
check_spec("synopsis")
check_spec("description")
check_spec("authors")
check_spec("maintainer")
if errors_found:
exit(1)
else:
exit(0)