Skip to content

Commit

Permalink
updated versions
Browse files Browse the repository at this point in the history
  • Loading branch information
smythi93 committed Jul 25, 2023
1 parent 189d6b8 commit 5b76063
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 28 deletions.
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sflkitlib>=0.0.1
astor>=0.8.1
numpy==1.25.1
matplotlib==3.7.2
numpy>=1.25.1
matplotlib>=3.7.2
sortedcollections>=2.1.0
parameterized>=0.8.1
future>=0.18.3
parameterized>=0.8.1
7 changes: 3 additions & 4 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
sflkitlib>=0.0.1
astor>=0.8.1
numpy==1.25.1
matplotlib==3.7.2
numpy>=1.25.1
matplotlib>=3.7.2
sortedcollections>=2.1.0
pytest>=7.2.2
pytest-cov>=4.1.0
pytest-html>=3.2.0
pytest-rerunfailures>=11.1.2
parameterized>=0.8.1
future>=0.18.3
parameterized>=0.8.1
8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ python_requires = >=3.10
install_requires =
sflkitlib>=0.0.1
astor>=0.8.1
numpy==1.25.1
matplotlib==3.7.2
numpy>=1.25.1
matplotlib>=3.7.2
sortedcollections>=2.1.0
parameterized>=0.8.1

Expand All @@ -38,8 +38,8 @@ where = src
test =
sflkitlib>=0.0.1
astor>=0.8.1
numpy==1.25.1
matplotlib==3.7.2
numpy>=1.25.1
matplotlib>=3.7.2
sortedcollections>=2.1.0
pytest>=7.2.2
pytest-cov>=4.1.0
Expand Down
10 changes: 8 additions & 2 deletions src/sflkit/language/python/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
)
if injection.error:
error_var = self.meta_visitor.tmp_generator.get_var_name()
raise_stmt = [
Raise(
exc=Name(id=error_var),
cause=None,
)
]
if body:
node.body = (
Try(
Expand All @@ -84,7 +90,7 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
id="BaseException",
),
name=error_var,
body=injection.error,
body=injection.error + raise_stmt,
)
],
orelse=[],
Expand All @@ -101,7 +107,7 @@ def __create_node(self, injection: Injection, node: AST, body=False, doc=None):
id="BaseException",
),
name=error_var,
body=injection.error,
body=injection.error + raise_stmt,
)
],
orelse=[],
Expand Down
39 changes: 25 additions & 14 deletions src/sflkit/runners/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
rb"= ((((?P<f>\d+) failed)|((?P<p>\d+) passed)|(\d+ warnings?))(, )?)+ in "
)

DEFAULT_TIMEOUT = 10


class PytestNode(abc.ABC):
def __init__(self, name: str, parent=None):
Expand Down Expand Up @@ -141,7 +143,8 @@ def get_dir(self):


class Runner(abc.ABC):
def __init__(self, re_filter: str = r".*"):
def __init__(self, re_filter: str = r".*", timeout=DEFAULT_TIMEOUT):
self.timeout = timeout
self.re_filter = re.compile(re_filter)

def get_tests(self, directory: Path, environ: Environment = None) -> List[str]:
Expand Down Expand Up @@ -218,12 +221,16 @@ def __get_pytest_result__(
def run_test(
self, directory: Path, test: str, environ: Environment = None
) -> TestResult:
output = subprocess.run(
["python", "-m", "pytest", test],
stdout=subprocess.PIPE,
env=environ,
cwd=directory,
).stdout
try:
output = subprocess.run(
["python", "-m", "pytest", test],
stdout=subprocess.PIPE,
env=environ,
cwd=directory,
timeout=self.timeout,
).stdout
except subprocess.TimeoutExpired:
return TestResult.UNDEFINED
successful, passing, failing = self.__get_pytest_result__(output)
if successful:
if passing > 0 and failing == 0:
Expand Down Expand Up @@ -272,13 +279,17 @@ def run_test(
else:
test = self.failing[test_name]
result = TestResult.FAILING
process = subprocess.run(
["python", self.access] + test,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=environ,
cwd=directory,
)
try:
process = subprocess.run(
["python", self.access] + test,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=environ,
cwd=directory,
timeout=self.timeout,
)
except subprocess.TimeoutExpired:
return TestResult.UNDEFINED
self.output[test_name] = (
process.stdout.decode("utf8"),
process.stderr.decode("utf8"),
Expand Down

0 comments on commit 5b76063

Please sign in to comment.