From 050e86927f4fd1323dc057412144af7ce9f8da20 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Fri, 3 Aug 2018 17:26:19 +0200 Subject: [PATCH] Allow test traits to be anywhere in R code file header --- .../com/oracle/truffle/r/test/TestRBase.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java index c8ba3eabbf..6f7ef11e3f 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestRBase.java @@ -66,28 +66,7 @@ public class TestRBase extends TestBase { String entryValue = entry.getValue(); explicitTestContext = entryName; String[] lines = entryValue.split("\n"); - String l = lines[0].trim(); - TestTrait testTrait = null; - if (l.startsWith("#")) { - // check the first line for configuration options - if (l.contains("IgnoreErrorContext")) { - testTrait = Output.IgnoreErrorContext; - } else if (l.contains("IgnoreWarningContext")) { - testTrait = Output.IgnoreWarningContext; - } else if (l.contains("IgnoreWarningMessage")) { - testTrait = Output.IgnoreWarningMessage; - } else if (l.contains("Ignored")) { - for (Ignored ignoredType : Ignored.values()) { - if (l.contains("Ignored." + ignoredType.name())) { - testTrait = ignoredType; - break; - } - } - if (testTrait == null) { - testTrait = Ignored.Unknown; // Retain old way for compatibility - } - } - } + TestTrait testTrait = getTestTrait(lines); try { Path dir = TestBase.createTestDir(getTestDir()); Path p = dir.resolve(Paths.get(entryName).getFileName()); @@ -103,4 +82,29 @@ public class TestRBase extends TestBase { explicitTestContext = null; } } + + private static TestTrait getTestTrait(String[] lines) { + for (int i = 0; i < lines.length; i++) { + String l = lines[i].trim(); + if (!l.startsWith("#")) { + return null; + } + // check the first line for configuration options + if (l.contains("IgnoreErrorContext")) { + return Output.IgnoreErrorContext; + } else if (l.contains("IgnoreWarningContext")) { + return Output.IgnoreWarningContext; + } else if (l.contains("IgnoreWarningMessage")) { + return Output.IgnoreWarningMessage; + } else if (l.contains("Ignored")) { + for (Ignored ignoredType : Ignored.values()) { + if (l.contains("Ignored." + ignoredType.name())) { + return ignoredType; + } + } + return Ignored.Unknown; // Retain old way for compatibility + } + } + return null; + } } -- GitLab