diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-12-10 13:28:37 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2023-12-11 03:38:37 +0100 |
commit | 920e9f5f15dc8e4e2962357f351bf74c7d9b666e (patch) | |
tree | f85af93f181e4d42158dd33e8ed39db2ec723b35 /testing | |
parent | 3ae6e989a4ee2c808452d0984811cfd963286fdd (diff) | |
download | aspectj-920e9f5f15dc8e4e2962357f351bf74c7d9b666e.tar.gz aspectj-920e9f5f15dc8e4e2962357f351bf74c7d9b666e.zip |
Make OutputSpec::getTrimmedLines work for empty lines on Windows
Improve the regex splitting lines to actually remove CR characters on
Windows.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'testing')
-rw-r--r-- | testing/src/test/java/org/aspectj/testing/OutputSpec.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index 14fc3bb62..def3990ec 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -127,8 +127,11 @@ public class OutputSpec { } private String[] getTrimmedLines(String text) { - // Remove leading/trailing empty lines and leading/trailing whitespace from each line - String[] trimmedLines = text.trim().split("\\s*\n\\s*"); + // Remove leading/trailing empty lines and leading/trailing horizontal whitespace from each line. + // Regex character class '\h' is horizonal whitespace. We assume that lines are always separated by something + // containing a '\n' LF character, e.g. LF (UNIX), CRLF (Windows). For legacy Mac platforms with their CR-only line + // separators, this would not work, and it is not supposed to either. + String[] trimmedLines = text.trim().split("\\h*\r?\n\\h*"); return trimmedLines.length == 1 && trimmedLines[0].equals("") ? new String[0] : trimmedLines; } } |