From 547c202e0187e5ea771eed91a9be18d659490320 Mon Sep 17 00:00:00 2001
From: Florian Angerer <florian.angerer@oracle.com>
Date: Thu, 8 Feb 2018 10:18:28 +0100
Subject: [PATCH] Make testthat recognition more robust.

---
 mx.fastr/mx_fastr_pkgs.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mx.fastr/mx_fastr_pkgs.py b/mx.fastr/mx_fastr_pkgs.py
index 19ae1e1896..5cf1192b8c 100644
--- a/mx.fastr/mx_fastr_pkgs.py
+++ b/mx.fastr/mx_fastr_pkgs.py
@@ -486,7 +486,7 @@ def _set_test_status(fastr_test_info):
                 fastr_content = f.readlines()
 
             # first, parse file and see if a known test framework has been used
-            ok, skipped, failed = handle_output_file(fastr_content)
+            ok, skipped, failed = handle_output_file(fastr_testfile_status.abspath, fastr_content)
             if ok is not None:
                 fastr_testfile_status.report = ok, skipped, failed
             else:
@@ -540,18 +540,21 @@ def _set_test_status(fastr_test_info):
         print 'END checking ' + pkg
 
 
-def handle_output_file(test_output_file_contents):
+def handle_output_file(file, test_output_file_contents):
     """
     R package tests are usually distributed over several files. Each file can be interpreted as a test suite.
     This function parses the output file of all test suites and tries to detect if it used the testthat or RUnit.
     In this case, it parses the summary (number of passed, skipped, failed tests) of these test frameworks.
     If none of the frameworks is used, it performs an output diff and tries to determine, how many statements
     produces different output, i.e., every statement is considered to be a unit test.
+    :param file Path to the file.
     :param test_output_file_contents: the lines of the output file
     :return: A 3-tuple with the number of passed, skipped, and failed tests.
     """
+    mx.log("Detecting output type of {!s}".format(file))
     for i in range(0, len(test_output_file_contents)):
-        if test_output_file_contents[i].startswith("testthat results"):
+        if "testthat results" in test_output_file_contents[i]:
+            mx.log("Detected testthat summary in {!s}".format(file))
             return _parse_testthat_result(test_output_file_contents, i)
 
         # TODO parse RUnit test protocol
-- 
GitLab