-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_all.py
74 lines (63 loc) · 1.87 KB
/
test_all.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from path import Path
from lsc.logged_shell_command import LoggedShellCommand as lsc
import filecmp
import os
def test_testall():
with (Path(__file__).realpath().dirname()/'example-ece264-hw04.dir') as d:
import sys; sys.path.insert(0,''); import importlib; import LUCKFILE; importlib.reload(LUCKFILE); from LUCKFILE import ns
ns['testall'].build()
def test_ece264_example():
# assert 0,(os.getcwd())
with (Path(__file__).realpath().dirname()/'example-ece264-hw04.dir') as d:
# with Path('example-ece264-hw04.dir').realpath() as d:
fn = (d/ 'main.o').touch()
lsc(['pyluckmake clean'])
# print('[cwd]',os.getcwd()
assert not fn.isfile()
lsc(['pyluckmake testall'])
for idx in ['16','17','18','19']:
out = 'output%s'%idx
exp = 'expected/expected%s'%idx
assert filecmp.cmp(out, exp),(out,exp)
lsc(['pyluckmake clean'])
from pprint import pprint
import sys
# sys.stderr.write(repr(d.listdir()))
out = sorted(Path('').glob('*'))
with open('/tmp/list','w') as f:
pprint(out, f)
exp = \
[Path('LICENSE'),
Path('LUCKFILE.py'),
Path('Makefile'),
Path('README-example.py'),
Path('README.md'),
Path('__pycache__'),
Path('_luck'),
Path('expected'),
Path('filechar.c'),
Path('inputs'),
Path('luck'),
Path('main.c'),
Path('out.txt'),
Path('output2049'),
Path('v1.LUCKFILE.py'),
Path('LUCKFILE_syntax_A.py'),
Path('LUCKFILE_syntax_M.py'),
# Path('new.LUCKFILE.py'),
# Path('v1E.LUCKFILE.py')
]
exp = sorted(exp)
out = sorted(out)
assert out==exp,pprint([out,exp])
def test_defer_rulenamespace_setitem():
from luck.shorts import RNS, TRNS
from luck.types import NoCacheRule
ns = TRNS()
# ns = RNS.subclass(module_file="__test__")()
ns['clean'] = (None,
lambda c: LSC('''
rm -f hw04 *.o *.ident_yaml output??
'''), NoCacheRule)
assert isinstance(ns['clean'],NoCacheRule)
# lsc(['bash ./example-ece264-hw04.sh'])