Skip to content

Commit

Permalink
Release v2.0.2
Browse files Browse the repository at this point in the history
* Fix #7

The problem was indeed caused by setup.py

* Implement #6
  • Loading branch information
Nhqml committed Apr 24, 2020
1 parent 116aab2 commit 5aa05e2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
15 changes: 10 additions & 5 deletions izitest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __repr__(self):
return f"{self.name}{f' {self.args}' if self.args else ''}" + \
f"{self.testcases if len(self.testcases) > 0 else ''}"

def run(self, ref: List[str], exec: List[str]):
def run(self, ref: List[str], exec: List[str]) -> int:
"""Run the Test.
It will run both tested and reference executable before performing
Expand All @@ -64,14 +64,17 @@ def run(self, ref: List[str], exec: List[str]):
Args:
exec (List[str]): tested executable.
ref (List[str]): reference executable.
Returns:
int: the return code of the Test (0 if "Passed" or "Skipped", 1 otherwise)
"""
printinfo("Test", indent=2, end=' ')
prettyprint(self.name, Color.CYAN, bold=True)

if self.skip:
self.status = "Skipped"
printstatus(self.status, indent=3)
return
return 0

ref_proc: CompletedProcess
test_proc: CompletedProcess
Expand All @@ -81,27 +84,29 @@ def run(self, ref: List[str], exec: List[str]):
elif ref is None:
self.status = "Skipped"
printwarning("No ref exec", bold=True, indent=3)
return
return 0
else:
try:
ref_proc = run_exec(ref + self.args, self.stdin, self.timeout)
except TimeoutExpired:
self.status = "Timed out"
printerror("Ref executable timed out", indent=3)
return
return 1

try:
test_proc = run_exec(exec + self.args, self.stdin, self.timeout)
except TimeoutExpired:
self.status = "Timed out"
printerror("Tested executable timed out", indent=3)
return
return 1

for tc in self.testcases:
tc.check(ref_proc, test_proc)

self.status = "Failed" if any(tc.status == "Failed" for tc in self.testcases) else "Passed"

return 0 if self.status == "Passed" else 1


def run_exec(exec: List[str], stdin: str, timeout: int) -> CompletedProcess:
"""Run an executable.
Expand Down
11 changes: 9 additions & 2 deletions izitest/testfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,25 @@ def __str__(self):
def __repr__(self):
return f"{self.path} {self.tests}"

def run(self, ref: List[str], exec: List[str]):
def run(self, ref: List[str], exec: List[str]) -> int:
"""Run all tests in the Testfile
Args:
exec (List[str]): tested executable.
ref (List[str]): reference executable.
Returns:
int: the return code of the Testfile (0 if "Passed" or "Skipped", 1 otherwise)
"""
printinfo("Running tests in", indent=1, end=' ')
prettyprint(str(self.path), Color.BLUE, bold=True)

if len(self.tests) == 0:
printwarning("No test to run", indent=2)

status: int = 0
for t in self.tests:
t.run(ref, exec)
if t.run(ref, exec) == 1:
status = 1

return status
12 changes: 10 additions & 2 deletions izitest/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ def __repr__(self):
f"Testfiles: {list(str(f) for f in self.testfiles)}\n" + \
f"Status: {self.status}"

def run(self):
def run(self) -> int:
"""Run the Testsuite.
Returns:
int: the return code of the Testsuite (0 if "Passed" or "Skipped", 1 otherwise)
"""
printinfo("Running Testsuite")

status: int = 0
for tf in self.testfiles:
tf.run(self.ref, self.exec)
if tf.run(self.ref, self.exec) == 1:
status = 1

if self.report is not None:
self.retrieve_status()
Expand All @@ -106,6 +112,8 @@ def run(self):
with open(self.report, 'w') as f:
f.write(report)

return status

def retrieve_status(self):
"""Retrieve Testsuite status.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="izitest",
version="2.0.1",
version="2.0.2",
author="Kenji 'Nhqml' Gaillac",
author_email="kenji.gaillac@epita.fr",
license="GNU GPLv3",
Expand All @@ -20,7 +20,7 @@
"Source": "https://github.com/nhqml/izitest",
"Documentation": "https://izitest.rtfd.io"
},
packages=find_packages("izitest"),
packages=find_packages(),
include_package_data=True,
package_data={
"izitest": [
Expand Down

0 comments on commit 5aa05e2

Please sign in to comment.