<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>In an effort refactor the code to make way for run resampling, move the run submission code into the test suites. With resampling the submission logic will change in NT.</div><div><br></div><div><div>diff --git a/lnt/lnttool/main.py b/lnt/lnttool/main.py</div><div>index 2b667bfb97a67d9316f82908f91773073240cf5c..bc521d4baeec3cfadf72ff94cab114889dbf929d 100644</div><div>--- a/lnt/lnttool/main.py</div><div>+++ b/lnt/lnttool/main.py</div><div>@@ -139,11 +139,11 @@ def action_runtest(name, args):</div><div>                       help="show verbose test results",</div><div>                       action="store_true", default=False)</div><div> </div><div>-    (opts, args) = parser.parse_args(args)</div><div>+    (global_opts, args) = parser.parse_args(args)</div><div>     if len(args) < 1:</div><div>         parser.error("incorrect number of argments")</div><div> </div><div>-    test_name,args = args[0],args[1:]</div><div>+    test_name, args = args[0], args[1:]</div><div> </div><div>     import lnt.tests</div><div>     try:</div><div>@@ -151,50 +151,7 @@ def action_runtest(name, args):</div><div>     except KeyError:</div><div>         parser.error('invalid test name %r' % test_name)</div><div> </div><div>-    report = test_instance.run_test('%s %s' % (name, test_name), args)</div><div>-</div><div>-    if opts.output is not None:</div><div>-        if opts.output == '-':</div><div>-            output_stream = sys.stdout</div><div>-        else:</div><div>-            output_stream = open(opts.output, 'w')</div><div>-        print >>output_stream, report.render()</div><div>-        if output_stream is not sys.stdout:</div><div>-            output_stream.close()</div><div>-</div><div>-    # Save the report to a temporary file.</div><div>-    #</div><div>-    # FIXME: This is silly, the underlying test probably wrote the report to a</div><div>-    # file itself. We need to clean this up and make it standard across all</div><div>-    # tests. That also has the nice side effect that writing into a local</div><div>-    # database records the correct imported_from path.</div><div>-    tmp = tempfile.NamedTemporaryFile(suffix='.json')</div><div>-    print >>tmp, report.render()</div><div>-    tmp.flush()</div><div>-</div><div>-    if opts.submit_url is not None:</div><div>-        if report is None:</div><div>-            raise SystemExit,"error: report generation failed"</div><div>-</div><div>-        from lnt.util import ServerUtil</div><div>-        test_instance.log("submitting result to %r" % (opts.submit_url,))</div><div>-        ServerUtil.submitFile(opts.submit_url, tmp.name, True, opts.verbose)</div><div>-    else:</div><div>-        # Simulate a submission to retrieve the results report.</div><div>-</div><div>-        # Construct a temporary database and import the result.</div><div>-        test_instance.log("submitting result to dummy instance")</div><div>-        </div><div>-        import lnt.server.db.v4db</div><div>-        import lnt.server.config</div><div>-        db = lnt.server.db.v4db.V4DB("<a href="sqlite:///:memory:">sqlite:///:memory:</a>",</div><div>-                                     lnt.server.config.Config.dummyInstance())</div><div>-        result = lnt.util.ImportData.import_and_report(</div><div>-            None, None, db, tmp.name, 'json', commit = True)</div><div>-        lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,</div><div>-                                                opts.verbose)</div><div>-</div><div>-    tmp.close()</div><div>+    test_instance.run_test('%s %s' % (name, test_name), args, global_opts)</div><div> </div><div> def action_showtests(name, args):</div><div>     """show the available built-in tests"""</div><div>diff --git a/lnt/tests/builtintest.py b/lnt/tests/builtintest.py</div><div>index f937a87ede6ebeb86e92ddc888ba875fe5060b20..85a970f67070b3f4e03ee968b80f92264e797747 100644</div><div>--- a/lnt/tests/builtintest.py</div><div>+++ b/lnt/tests/builtintest.py</div><div>@@ -26,3 +26,14 @@ class BuiltinTest(object):</div><div> </div><div>     def log(self, message, ts=timestamp()):</div><div>         print >>sys.stderr, '%s: %s' % (ts, message)</div><div>+</div><div>+    @staticmethod</div><div>+    def print_report(report, output):</div><div>+        """Print the report object to the output path."""</div><div>+        if output == '-':</div><div>+            output_stream = sys.stdout</div><div>+        else:</div><div>+            output_stream = open(output, 'w')</div><div>+        print >> output_stream, report.render()</div><div>+        if output_stream is not sys.stdout:</div><div>+            output_stream.close()</div><div>diff --git a/lnt/tests/compile.py b/lnt/tests/compile.py</div><div>index fabf8ed64bd3a66ea7c710ddfcb25e5c696e18ff..77a235da7fcfb55b558ef246ef71acf5d1531d94 100644</div><div>--- a/lnt/tests/compile.py</div><div>+++ b/lnt/tests/compile.py</div><div>@@ -654,7 +654,7 @@ class CompileTest(builtintest.BuiltinTest):</div><div>     def describe(self):</div><div>         return 'Single file compile-time performance testing'</div><div> </div><div>-    def run_test(self, name, args):</div><div>+    def run_test(self, name, args, global_opts):</div><div>         global opts</div><div>         parser = OptionParser(</div><div>             ("%(name)s [options] [<output file>]\n" +</div><div>@@ -999,12 +999,46 @@ class CompileTest(builtintest.BuiltinTest):</div><div>         # Write out the report.</div><div>         lnt_report_path = os.path.join(g_output_dir, 'report.json')</div><div>         report = lnt.testing.Report(machine, run, testsamples)</div><div>-        lnt_report_file = open(lnt_report_path, 'w')</div><div>-        print >>lnt_report_file, report.render()</div><div>-        lnt_report_file.close()</div><div>+</div><div>+        # save report</div><div>+        self.print_report(report, lnt_report_path)</div><div>+</div><div>+        # and print to screen if requested</div><div>+        if global_opts.output is not None:</div><div>+            self.print_report(report, global_opts.output)</div><div>+</div><div>+        self.submit(lnt_report_path, global_opts)</div><div> </div><div>         return report</div><div> </div><div>+    def submit(self, report_path, config):</div><div>+        """Submit the results file to the server.  If no server</div><div>+        was specified, use a local mock server.</div><div>+</div><div>+        """</div><div>+        assert os.path.exists(report_path), "Failed report should have never gotten here!"</div><div>+</div><div>+        if config.submit_url is not None:</div><div>+</div><div>+            from lnt.util import ServerUtil</div><div>+            self.log("submitting result to %r" % (config.submit_url,))</div><div>+            ServerUtil.submitFile(config.submit_url, report_path, True, config.verbose)</div><div>+        else:</div><div>+            # Simulate a submission to retrieve the results report.</div><div>+</div><div>+            # Construct a temporary database and import the result.</div><div>+            self.log("submitting result to dummy instance")</div><div>+</div><div>+            import lnt.server.db.v4db</div><div>+            import lnt.server.config</div><div>+            db = lnt.server.db.v4db.V4DB("<a href="sqlite:///:memory:">sqlite:///:memory:</a>",</div><div>+                                         lnt.server.config.Config.dummyInstance())</div><div>+            result = lnt.util.ImportData.import_and_report(</div><div>+                None, None, db, report_path, 'json', commit = True)</div><div>+            lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,</div><div>+                                                    config.verbose)</div><div>+</div><div>+</div><div> def create_instance():</div><div>     return CompileTest()</div><div> </div><div>diff --git a/lnt/tests/nt.py b/lnt/tests/nt.py</div><div>index 963a99e056782bec5dbf006946813b7c1c4f69e4..cefb38c42c7c05cc24df76bc263e93cb50b7b09b 100644</div><div>--- a/lnt/tests/nt.py</div><div>+++ b/lnt/tests/nt.py</div><div>@@ -7,6 +7,7 @@ import subprocess</div><div> import sys</div><div> import time</div><div> import traceback</div><div>+import tempfile</div><div> </div><div> from datetime import datetime</div><div> </div><div>@@ -1070,7 +1071,7 @@ class NTTest(builtintest.BuiltinTest):</div><div>     def describe(self):</div><div>         return 'LLVM test-suite compile and execution tests'</div><div> </div><div>-    def run_test(self, name, args):</div><div>+    def run_test(self, name, args, global_opts):</div><div>         parser = OptionParser(</div><div>             ("%(name)s [options] tester-name\n" + usage_info) % locals())</div><div> </div><div>@@ -1432,10 +1433,10 @@ class NTTest(builtintest.BuiltinTest):</div><div>                 warning('expected --isysroot when executing with '</div><div>                         '--ios-simulator-sdk')</div><div> </div><div>+        options = dict(vars(opts).items() + vars(global_opts).items())</div><div>+        config = TestConfiguration(options, timestamp())</div><div>         # FIXME: We need to validate that there is no configured output in the</div><div>         # test-suite directory, that borks things. <<a href="rdar://problem/7876418">rdar://problem/7876418</a>></div><div>-        options = dict(vars(opts).items())</div><div>-        config = TestConfiguration(options, timestamp())</div><div>         prepare_report_dir(config)</div><div> </div><div>         # Multisample, if requested.</div><div>@@ -1461,17 +1462,51 @@ class NTTest(builtintest.BuiltinTest):</div><div>                                 for r in reports], [])</div><div> </div><div>             # Write out the merged report.</div><div>-            lnt_report_path = os.path.join(config.report_dir, 'report.json')</div><div>+            lnt_report_path = config.report_path(None)</div><div>             report = lnt.testing.Report(machine, run, test_samples)</div><div>             lnt_report_file = open(lnt_report_path, 'w')</div><div>             print >>lnt_report_file,report.render()</div><div>             lnt_report_file.close()</div><div> </div><div>-            return report</div><div>+        else:</div><div>+            report = run_test(nick, None, config)</div><div>+</div><div>+        if config.output is not None:</div><div>+            self.print_report(report, config.output)</div><div>+</div><div>+        self.submit(config)</div><div> </div><div>-        report = run_test(nick, None, config)</div><div>         return report</div><div> </div><div>+</div><div>+    def submit(self, config):</div><div>+        """Submit the report to the server.  If no server</div><div>+        was specified, use a local mock server.</div><div>+</div><div>+        """</div><div>+        report_path = config.report_path(None)</div><div>+        assert os.path.exists(report_path), "Failed report should have never gotten here!"</div><div>+</div><div>+        if config.submit_url is not None:</div><div>+            from lnt.util import ServerUtil</div><div>+            self.log("submitting result to %r" % (config.submit_url,))</div><div>+            ServerUtil.submitFile(config.submit_url, report_path, True, config.verbose)</div><div>+        else:</div><div>+            # Simulate a submission to retrieve the results report.</div><div>+</div><div>+            # Construct a temporary database and import the result.</div><div>+            self.log("submitting result to dummy instance")</div><div>+</div><div>+            import lnt.server.db.v4db</div><div>+            import lnt.server.config</div><div>+            db = lnt.server.db.v4db.V4DB("<a href="sqlite:///:memory:">sqlite:///:memory:</a>",</div><div>+                                         lnt.server.config.Config.dummyInstance())</div><div>+            result = lnt.util.ImportData.import_and_report(</div><div>+                None, None, db, report_path, 'json', commit = True)</div><div>+            lnt.util.ImportData.print_report_result(result, sys.stdout, sys.stderr,</div><div>+                                                    config.verbose)</div><div>+</div><div>+</div><div> def create_instance():</div><div>     return NTTest()</div><div> </div></div><div><br></div><div><br></div><div></div></body></html>