Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit 6978563

Browse files
author
Albert Allagulov
committed
add 'make calc_test'
1 parent 2a64d31 commit 6978563

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ clone:
5151
uncalc:
5252
rm -rf metrics
5353

54+
calc_test:
55+
python3 computation/calc_unit_test.py
56+
python3 computation/calc_integration_test.py
57+
5458
calc:
5559
mkdir -p metrics
5660
for r in $$(find clones/ -type d -maxdepth 2 ); do \

computation/calc_integration_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
except ImportError:
1111
from mock import patch
1212

13-
fileDir = os.path.dirname(os.path.realpath('__file__'))
13+
fileDir = os.path.dirname(os.path.realpath(__file__))
1414
testargs = ["", os.path.join(fileDir, 'java/cc/SwitchCaseStatement.java')]
1515
with patch.object(sys, 'argv', testargs):
1616
from calc import branches, compound
@@ -25,7 +25,7 @@ def names(ast):
2525
comment = next(ast.filter(javalang.tree.Documented))[1]
2626
return int(re.search(r'[\d]+', comment.documentation).group(0))
2727

28-
for java in glob('java/names/*.java'):
28+
for java in glob(os.path.join(fileDir, 'java/names/*.java')):
2929
with open(java, encoding='utf-8') as f:
3030
try:
3131
ast = javalang.parse.parse(f.read())
@@ -36,11 +36,11 @@ def names(ast):
3636
receivedNames += compound(node)
3737

3838
if (receivedNames != expectedNames):
39-
raise Exception('\nTest failed. Expected ' + str(expectedNames) + ', receivedNames ' + str(receivedNames))
39+
raise Exception('\nTest failed. Expected ' + str(expectedNames) + ', received ' + str(receivedNames))
4040
except Exception as e:
4141
sys.exit(str(e) + ': ' + java)
4242

43-
for java in glob('java/cc/*.java'):
43+
for java in glob(os.path.join(fileDir, 'java/cc/*.java')):
4444
with open(java, encoding='utf-8') as f:
4545
try:
4646
ast = javalang.parse.parse(f.read())
@@ -51,11 +51,11 @@ def names(ast):
5151
receivedCC += branches(node)
5252

5353
if (receivedCC != expectedCC):
54-
raise Exception('\nTest failed. Expected ' + str(expectedCC) + ', receivedCC ' + str(receivedCC))
54+
raise Exception('\nTest failed. Expected ' + str(expectedCC) + ', received ' + str(receivedCC))
5555

5656
print('.', end='', flush=True),
5757
except Exception as e:
5858
sys.exit(str(e) + ': ' + java)
5959

60-
print(' OK')
60+
print('\nOK')
6161

computation/calc_unit_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
except ImportError:
99
from mock import patch
1010

11-
fileDir = os.path.dirname(os.path.realpath('__file__'))
11+
fileDir = os.path.dirname(os.path.realpath(__file__))
1212
testargs = ["", os.path.join(fileDir, 'java/cc/SwitchCaseStatement.java')]
1313
with patch.object(sys, 'argv', testargs):
1414
from calc import branches, compound

0 commit comments

Comments
 (0)