From d4210398492bf512d71c94a897a7cc001d730f7e Mon Sep 17 00:00:00 2001 From: Alekseeva Yana Date: Tue, 26 Dec 2023 22:47:00 +0300 Subject: [PATCH] feat(#2674): fix tests for windows test --- .../java/org/eolang/maven/VerifyMojoTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java index 063a9825b1..58a8793d42 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/VerifyMojoTest.java @@ -76,7 +76,7 @@ void detectsErrorsSuccessfully( ); final String parse = this.parserMessage(out, "Errors identified:"); Assertions.assertTrue( - parse.matches(temp.resolve("foo/x/main.eo").toString().concat(", \\d+")), + parse.matches(this.createRegEx(temp)), "Errors message should have program name and error line number" ); } @@ -99,7 +99,7 @@ void detectsCriticalErrorsSuccessfully( ); final String parse = this.parserMessage(out, "Critical error identified:"); Assertions.assertTrue( - parse.matches(temp.resolve("foo/x/main.eo").toString().concat(", \\d+")), + parse.matches(this.createRegEx(temp)), "Critical error message should have program name and error line number" ); } @@ -124,7 +124,7 @@ void detectsWarningWithCorrespondingFlag( ); final String parse = this.parserMessage(out, "Warnings identified:"); Assertions.assertTrue( - parse.matches(temp.resolve("foo/x/main.eo").toString().concat(", \\d+")), + parse.matches(this.createRegEx(temp)), "Warnings message should have program name and error line number" ); } @@ -256,4 +256,14 @@ private String parserMessage(final Logs logs, final String error) { final String result = message.substring(message.indexOf(str) + str.length()); return result.substring(0, result.indexOf(": ")); } + + /** + * Create regular expression for testing. + * @param path Path program + */ + private String createRegEx(final Path path) { + return path.resolve("foo/x/main.eo") + .toString().replace("\\", "\\\\") + .concat(", \\d+"); + } }