[LNT] r308670 - Fix lnt checkformat and add a test for it
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 13:44:20 PDT 2017
Author: matze
Date: Thu Jul 20 13:44:20 2017
New Revision: 308670
URL: http://llvm.org/viewvc/llvm-project?rev=308670&view=rev
Log:
Fix lnt checkformat and add a test for it
This broke when switching to click, and there was no test catching it...
Added:
lnt/trunk/tests/lnttool/checkformat.shtest
Modified:
lnt/trunk/lnt/lnttool/main.py
lnt/trunk/lnt/util/ImportData.py
Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=308670&r1=308669&r2=308670&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Thu Jul 20 13:44:20 2017
@@ -81,19 +81,20 @@ view the results.
@click.command("checkformat")
- at click.argument("file", "input_file", nargs=-1, type=click.Path(exists=True))
+ at click.argument("files", nargs=-1, type=click.Path(exists=True))
@click.option("--testsuite", "-s", default='nts')
-def action_checkformat(input_file, testsuite):
- """check the format of an LNT test report file"""
+def action_checkformat(files, testsuite):
+ """check the format of LNT test report files"""
import lnt.server.config
import lnt.server.db.v4db
import lnt.util.ImportData
db = lnt.server.db.v4db.V4DB('sqlite:///:memory:',
lnt.server.config.Config.dummy_instance())
- result = lnt.util.ImportData.import_and_report(
- None, None, db, input_file, 'json', testsuite, commit=True)
- lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,
- verbose=True)
+ for file in files:
+ result = lnt.util.ImportData.import_and_report(
+ None, None, db, file, '<auto>', testsuite, commit=True)
+ lnt.util.ImportData.print_report_result(result, sys.stdout,
+ sys.stderr, verbose=True)
def _print_result_url(results, verbose):
Modified: lnt/trunk/lnt/util/ImportData.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/util/ImportData.py?rev=308670&r1=308669&r2=308670&view=diff
==============================================================================
--- lnt/trunk/lnt/util/ImportData.py (original)
+++ lnt/trunk/lnt/util/ImportData.py Thu Jul 20 13:44:20 2017
@@ -181,9 +181,10 @@ def print_report_result(result, out, err
else:
out.flush()
print >>err, "Import Failed:"
- print >>err, "--\n%s--\n" % result['error']
+ print >>err, "%s\n" % result['error']
if result['message']:
print >>err, "%s\n" % result['message']
+ print >>err, "--------------"
err.flush()
return
Added: lnt/trunk/tests/lnttool/checkformat.shtest
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/checkformat.shtest?rev=308670&view=auto
==============================================================================
--- lnt/trunk/tests/lnttool/checkformat.shtest (added)
+++ lnt/trunk/tests/lnttool/checkformat.shtest Thu Jul 20 13:44:20 2017
@@ -0,0 +1,50 @@
+# Check an old plist format
+# RUN: lnt checkformat %{shared_inputs}/sample-a-small.plist 2>&1 | FileCheck %s --check-prefix=CHECK0
+#
+# CHECK0: Import succeeded.
+# CHECK0: Imported Data
+# CHECK0: -------------
+# CHECK0: Added Machines: 1
+# CHECK0: Added Runs : 1
+# CHECK0: Added Tests : 1
+#
+# CHECK0: Results
+# CHECK0: ----------------
+# CHECK0: PASS : 5
+#
+#
+# Check an old json format
+# RUN: lnt checkformat %{shared_inputs}/sample-report.json 2>&1 | FileCheck %s --check-prefix=CHECK1
+#
+# CHECK1: Import succeeded.
+# CHECK1: Imported Data
+# CHECK1: -------------
+# CHECK1: Added Machines: 1
+# CHECK1: Added Runs : 1
+# CHECK1: Added Tests : 2
+#
+# CHECK1: Results
+# CHECK1: ----------------
+# CHECK1: PASS : 10
+#
+#
+# Check new-style json format
+# RUN: lnt checkformat %{src_root}/docs/report-example.json 2>&1 | FileCheck %s --check-prefix=CHECK2
+#
+# CHECK2: Import succeeded.
+# CHECK2: Imported Data
+# CHECK2: -------------
+# CHECK2: Added Machines: 1
+# CHECK2: Added Runs : 1
+# CHECK2: Added Tests : 2
+#
+# CHECK2: Results
+# CHECK2: ----------------
+# CHECK2: PASS : 10
+#
+#
+# Check invalid format
+# RUN: lnt checkformat %S/Inputs/invalid_submission0.json 2>&1 | FileCheck %s --check-prefix=CHECKFAIL0
+#
+# CHECKFAIL0: Import Failed:
+# CHECKFAIL0: could not parse input format
More information about the llvm-commits
mailing list