diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index d4c2c24c773641e3c10144f80c801c66b8951a6d..0977acde60956462a043077e9b5501f3b1e3f82f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -108251,19 +108251,19 @@ a b c d e [1] 42 ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels1.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels1.R") } [1] 7 42 ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels10.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels10.R") } [1] 7 42 ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels11.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels11.R") } [1] 7 42 ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels2.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels2.R") } [[1]] [1] 7 @@ -108272,11 +108272,11 @@ a b c d e ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels3.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels3.R") } [1] 49 ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels4.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels4.R") } [[1]] [1] 7 @@ -108285,7 +108285,7 @@ a b c d e ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels5.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels5.R") } [[1]] [1] 7 @@ -108294,7 +108294,7 @@ a b c d e ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels6.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels6.R") } [[1]] [1] 7 @@ -108303,15 +108303,15 @@ a b c d e ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels7.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels7.R") } [1] TRUE ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels8.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels8.R") } [1] TRUE ##com.oracle.truffle.r.test.library.fastr.TestChannels.runRSourceTests -#{ source("com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/channels/R/channels9.R") } +#{ source("mxbuild/com.oracle.truffle.r.test/bin/com/oracle/truffle/r/test/channels/R/channels9.R") } [1] TRUE FALSE ##com.oracle.truffle.r.test.library.fastr.TestInterop.testInteropEval diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java index 1cc044397728b53188c158207371bff04fcf7dbd..2e8731a6fe90135457deb11703feb1edbc133939 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java @@ -129,6 +129,7 @@ public class TestBase { private static final String GEN_FASTR = "gen-fastr="; private static final String GEN_DIFFS = "gen-diff="; private static final String KEEP_TRAILING_WHITESPACE = "keep-trailing-whitespace"; + private static final String TRACE_TESTS = "trace-tests"; private static final String TEST_METHODS = "test-methods="; /** * The dir where 'mx' puts the output from building this project. @@ -169,6 +170,8 @@ public class TestBase { checkExpected = true; } else if (directive.equals(KEEP_TRAILING_WHITESPACE)) { keepTrailingWhiteSpace = true; + } else if (directive.equals(TRACE_TESTS)) { + traceTests = true; } else if (directive.startsWith(TEST_PROJECT_OUTPUT_DIR)) { testProjectOutputDir = Paths.get(directive.replace(TEST_PROJECT_OUTPUT_DIR, "")); } else if (directive.equals(TEST_METHODS)) { @@ -218,6 +221,9 @@ public class TestBase { @Override public void testStarted(Description description) { testElementName = description.getClassName() + "." + description.getMethodName(); + if (traceTests) { + System.out.println(testElementName); + } failedMicroTests = new ArrayList<>(); } } @@ -225,8 +231,11 @@ public class TestBase { @Before public void beforeTest() { if (expectedOutputManager == null) { - // assume we are running a unit test in an IDE and the RunListener was not invoked. - // In this case we can expect the test output file to exist and open it as a resource + /* + * Assume we are running a unit test in an IDE/non-JUnit setup and therefore the + * RunListener was not invoked. In this case we can expect the test output file to exist + * and open it as a resource. + */ URL expectedTestOutputURL = ResourceHandlerFactory.getHandler().getResource(TestBase.class, TestOutputManager.TEST_EXPECTED_OUTPUT_FILE); if (expectedTestOutputURL == null) { Assert.fail("cannot find " + TestOutputManager.TEST_EXPECTED_OUTPUT_FILE + " resource"); @@ -242,15 +251,25 @@ public class TestBase { } } - @SuppressWarnings("unchecked") /** - * A connvenience builder-pattern style method for a non-JUnit implementation. - * - * @return + * Method for non-JUnit implementation to set test tracing. + */ + public static void setTraceTests() { + traceTests = true; + } + + /** + * Set the test context explicitly (for non-JUnit implementation). N.B. The {@code lineno} is + * not the micro-test line, but that of the method declaration. */ - public <T> T doBeforeTest() { + public void doBeforeTest(String className, int lineno, String methodName) { + testElementName = className + "." + methodName; + failedMicroTests = new ArrayList<>(); + explicitTestContext = String.format("%s:%d (%s)", className, lineno, methodName); + if (traceTests) { + System.out.println(testElementName); + } beforeTest(); - return (T) this; } private static class ExpectedTestOutputManager extends TestOutputManager { @@ -361,6 +380,11 @@ public class TestBase { */ private static boolean keepTrailingWhiteSpace; + /** + * Trace the test methods as they are executed (debugging). + */ + private static boolean traceTests; + private static Path testProjectOutputDir; protected static final String ERROR = "Error"; @@ -518,7 +542,7 @@ public class TestBase { String context = String.format("%s:%d (%s)", culprit.getClassName(), culprit.getLineNumber(), culprit.getMethodName()); return context; } catch (NullPointerException npe) { - return "no context available"; + return "no test context available"; } } diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index 0c3e53cacfa9e11d63b8445f20929070d11a28c7..e988670b4ac635033917a10b5aaf23654f1f6e89 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -305,6 +305,10 @@ def _junit_r_harness(args, vmArgs, jdk, junitArgs): runlistener_arg = add_arg_separator() runlistener_arg += 'gen-diff=' + args.gen_diff_output + if args.trace_tests: + runlistener_arg = add_arg_separator() + runlistener_arg += 'trace-tests' + # if args.test_methods: # runlistener_arg = add_arg_separator() # runlistener_arg = 'test-methods=' + args.test_methods @@ -339,6 +343,7 @@ def junit(args): parser.add_argument('--check-expected-output', action='store_true', help='check but do not update expected test output file') parser.add_argument('--gen-fastr-output', action='store', metavar='<path>', help='generate FastR test output file') parser.add_argument('--gen-diff-output', action='store', metavar='<path>', help='generate difference test output file ') + parser.add_argument('--trace-tests', action='store_true', help='trace the actual @Test methods as they are executed') # parser.add_argument('--test-methods', action='store', help='pattern to match test methods in test classes') if os.environ.has_key('R_PROFILE_USER'):