-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from launchableinc/ST-657
[ST-657] shippable generic test runner support
- Loading branch information
Showing
3 changed files
with
56 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# The most bare-bone versions of the test runner support | ||
# | ||
import click | ||
import sys | ||
from . import launchable | ||
from junitparser import TestCase, TestSuite | ||
from ..testpath import TestPath | ||
|
||
|
||
@launchable.subset | ||
def subset(client): | ||
# read lines as test file names | ||
for t in sys.stdin: | ||
client.test_path(t) | ||
client.run() | ||
|
||
|
||
@click.argument('reports', required=True, nargs=-1) | ||
@launchable.record.tests | ||
def record_tests(client, reports): | ||
def path_builder(case: TestCase, suite: TestSuite, report_file: str) -> TestPath: | ||
"""path builder that puts the file name first, which is consistent with the subset command""" | ||
def find_filename(): | ||
"""look for what looks like file names from test reports""" | ||
for e in [case, suite]: | ||
for a in ["file","filepath"]: | ||
filepath = e._elem.attrib.get(a) | ||
if filepath: | ||
return filepath | ||
return None # failing to find a test name | ||
|
||
|
||
filepath = find_filename() | ||
if not filepath: | ||
raise click.ClickException("No file name found in %s" % report_file) | ||
|
||
# default test path in `subset` expects to have this file name | ||
test_path = [client.make_file_path_component(filepath)] | ||
if suite.name: | ||
test_path.append({"type": "testsuite", "name": suite.name}) | ||
if case.name: | ||
test_path.append({"type": "testcase", "name": case.name}) | ||
return test_path | ||
client.path_builder = path_builder | ||
|
||
for r in reports: | ||
client.report(r) | ||
client.run() |
This file was deleted.
Oops, something went wrong.