Merge branch 'pmd7-lang-registry-non-static' into pmd7-language-lifecycle

This commit is contained in:
Clément Fournier
2022-07-22 17:39:39 +02:00
3 changed files with 9 additions and 7 deletions

View File

@ -21,6 +21,8 @@ import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
* @author Romain Pelisse <belaran@gmail.com> * @author Romain Pelisse <belaran@gmail.com>
*/ */
public class CLITest extends BaseCLITest { public class CLITest extends BaseCLITest {
// note that the progress bar sometimes messes up the log so it is
// disabled here in most tests.
// restoring system properties: -debug might change logging properties // restoring system properties: -debug might change logging properties
// See Slf4jSimpleConfigurationForAnt and resetLogging // See Slf4jSimpleConfigurationForAnt and resetLogging
@ -63,7 +65,7 @@ public class CLITest extends BaseCLITest {
@Test @Test
public void changeJavaVersion() { public void changeJavaVersion() {
String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_NO_VIOLATION, "-version", "1.5", "-language", "java", "--debug" }; String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_NO_VIOLATION, "-version", "1.5", "-language", "java", "--debug", "--no-progress", };
String log = runTest(args); String log = runTest(args);
assertThat(log, containsPattern("Adding file .*\\.java \\(lang: java 1\\.5\\)")); assertThat(log, containsPattern("Adding file .*\\.java \\(lang: java 1\\.5\\)"));
} }
@ -75,21 +77,21 @@ public class CLITest extends BaseCLITest {
@Test @Test
public void exitStatusWithViolations() { public void exitStatusWithViolations() {
String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, }; String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, "--no-progress", };
String log = runTest(StatusCode.VIOLATIONS_FOUND, args); String log = runTest(StatusCode.VIOLATIONS_FOUND, args);
assertThat(log, containsString("Violation from test-rset-1.xml")); assertThat(log, containsString("Violation from test-rset-1.xml"));
} }
@Test @Test
public void exitStatusWithViolationsAndWithoutFailOnViolations() { public void exitStatusWithViolationsAndWithoutFailOnViolations() {
String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, "-failOnViolation", "false", }; String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, "-failOnViolation", "false", "--no-progress", };
String log = runTest(StatusCode.OK, args); String log = runTest(StatusCode.OK, args);
assertThat(log, containsString("Violation from test-rset-1.xml")); assertThat(log, containsString("Violation from test-rset-1.xml"));
} }
@Test @Test
public void exitStatusWithViolationsAndWithoutFailOnViolationsLongOption() { public void exitStatusWithViolationsAndWithoutFailOnViolationsLongOption() {
String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, "--fail-on-violation", "false", }; String[] args = { "-d", SOURCE_FOLDER, "-f", "text", "-R", RSET_WITH_VIOLATION, "--fail-on-violation", "false", "--no-progress", };
String log = runTest(StatusCode.OK, args); String log = runTest(StatusCode.OK, args);
assertThat(log, containsString("Violation from test-rset-1.xml")); assertThat(log, containsString("Violation from test-rset-1.xml"));
} }

View File

@ -24,8 +24,7 @@ public class CLITest extends BaseCLITest {
"xml", "xml",
"-R", "-R",
"rulesets/testing/js-rset1.xml", "rulesets/testing/js-rset1.xml",
"-l", "--no-progress",
"ecmascript",
"--debug"); "--debug");
assertThat(log, containsPattern("Adding file .*\\.js \\(lang: ecmascript\\)")); assertThat(log, containsPattern("Adding file .*\\.js \\(lang: ecmascript\\)"));
} }

View File

@ -25,7 +25,8 @@ public class XmlCliTest extends BaseCLITest {
List<String> arguments = new ArrayList<>(listOf( List<String> arguments = new ArrayList<>(listOf(
"-f", "-f",
"text", "text",
"-no-cache", "--no-cache",
"--no-progress",
"-R", "-R",
BASE_DIR + "/ruleset.xml", BASE_DIR + "/ruleset.xml",
"-d", "-d",