Skip to content

Commit 4f49f39

Browse files
author
Pavel Kosov
committed
[LNT] Fixed incomplete feature for submit JSON to a local instance
LNT parses the test suite from the specified url for the submit command. But the suite is always default (nts) in case of using a local path to the instance instead of the url. This patch allows to specify the test suite in the submit command. Reviewed By: thopre Differential Revision: https://reviews.llvm.org/D109578
1 parent 953e0f2 commit 4f49f39

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

lnt/lnttool/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .viewcomparison import action_view_comparison
1111
from .admin import group_admin
1212
from lnt.util import logger
13+
from lnt.server.db.rules_manager import register_hooks
1314
import click
1415
import logging
1516
import sys
@@ -183,14 +184,20 @@ def action_showtests():
183184
@submit_options
184185
@click.option("--verbose", "-v", is_flag=True,
185186
help="show verbose test results")
186-
def action_submit(url, files, select_machine, merge, verbose):
187+
@click.option("--testsuite", "-s", default='nts', show_default=True,
188+
help="testsuite to use in case the url is a file path")
189+
def action_submit(url, files, select_machine, merge, verbose, testsuite):
187190
"""submit a test report to the server"""
188191
from lnt.util import ServerUtil
189192
import lnt.util.ImportData
190193

194+
if '://' not in url:
195+
init_logger(logging.DEBUG)
196+
register_hooks()
197+
191198
results = ServerUtil.submitFiles(url, files, verbose,
192199
select_machine=select_machine,
193-
merge_run=merge)
200+
merge_run=merge, testsuite=testsuite)
194201
for submitted_file in results:
195202
if verbose:
196203
lnt.util.ImportData.print_report_result(

lnt/util/ServerUtil.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def submitFileToServer(url, file, select_machine=None, merge_run=None):
7171
return
7272

7373

74-
def submitFileToInstance(path, file, select_machine=None, merge_run=None):
74+
def submitFileToInstance(path, file, select_machine=None, merge_run=None,
75+
testsuite=None):
7576
# Otherwise, assume it is a local url and submit to the default database
7677
# in the instance.
7778
instance = lnt.server.instance.Instance.frompath(path)
@@ -82,24 +83,28 @@ def submitFileToInstance(path, file, select_machine=None, merge_run=None):
8283
raise ValueError("no default database in instance: %r" % (path,))
8384
session = db.make_session()
8485
return lnt.util.ImportData.import_and_report(
85-
config, db_name, db, session, file, format='<auto>', ts_name='nts',
86-
select_machine=select_machine, merge_run=merge_run)
86+
config, db_name, db, session, file, format='<auto>',
87+
ts_name=testsuite or 'nts', select_machine=select_machine,
88+
merge_run=merge_run)
8789

8890

89-
def submitFile(url, file, verbose, select_machine=None, merge_run=None):
91+
def submitFile(url, file, verbose, select_machine=None, merge_run=None,
92+
testsuite=None):
9093
# If this is a real url, submit it using urllib.
9194
if '://' in url:
9295
result = submitFileToServer(url, file, select_machine, merge_run)
9396
else:
94-
result = submitFileToInstance(url, file, select_machine, merge_run)
97+
result = submitFileToInstance(url, file, select_machine, merge_run,
98+
testsuite)
9599
return result
96100

97101

98-
def submitFiles(url, files, verbose, select_machine=None, merge_run=None):
102+
def submitFiles(url, files, verbose, select_machine=None, merge_run=None,
103+
testsuite=None):
99104
results = []
100105
for file in files:
101106
result = submitFile(url, file, verbose, select_machine=select_machine,
102-
merge_run=merge_run)
107+
merge_run=merge_run, testsuite=testsuite)
103108
if result:
104109
results.append(result)
105110
return results

0 commit comments

Comments
 (0)