-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patchtest2: decorator and module refactor
- Make core.py exclusive to "core" (i.e. mbox) tests - Use new patchtest_result decorator in core.py - Move PatchtestResults class to patchtest.py, rename to "Patchtest" - Use inspect module to dynamically get test function handles and names from core.py Signed-off-by: Trevor Gamblin <[email protected]>
- Loading branch information
Showing
2 changed files
with
47 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,44 @@ | ||
import inspect | ||
import patchtest2.tests.core as core | ||
from patchtest2.parser import PatchtestParser | ||
from patchtest2.mbox import PatchSeries, TargetRepo | ||
from patchtest2.tests.core import PatchtestResults | ||
|
||
class Patchtest: | ||
def __init__(self, target_repo, series): | ||
self.target_repo = target_repo | ||
self.series = series | ||
self.core_results = {k: self._results(v) for (k, v) in inspect.getmembers(core, inspect.isfunction) if k != "patchtest_result"} | ||
|
||
self.results = dict( | ||
[ | ||
( | ||
"core", | ||
self.core_results, | ||
), | ||
] | ||
) | ||
|
||
def _results(self, testname): | ||
return [testname(patch) for patch in self.series.patchdata] | ||
|
||
def _print_result(self, category, tag): | ||
for value in self.results[category][tag]: | ||
print(value) | ||
|
||
def _print_results(self, category): | ||
for tag in self.results[category].keys(): | ||
self._print_result(category, tag) | ||
|
||
def print_results(self): | ||
for category in self.results.keys(): | ||
self._print_results(category) | ||
|
||
|
||
def run(): | ||
parser = PatchtestParser.get_parser() | ||
args = parser.parse_args() | ||
target_repo = TargetRepo(args.repodir) | ||
series = PatchSeries(args.patch_path) | ||
results = PatchtestResults(target_repo, series) | ||
results = Patchtest(target_repo, series) | ||
|
||
results.print_results() |