From 2263835c4a6262f70f6d8d9394d07a05890a13e7 Mon Sep 17 00:00:00 2001 From: Jean-Francois Denise Date: Mon, 4 Dec 2023 12:55:12 +0100 Subject: [PATCH] When skipTests, do not check expected Galleon layers --- .../glow/plugin/arquillian/ScanMojo.java | 91 ++++++++++--------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java b/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java index d39271b7..812b9faf 100644 --- a/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java +++ b/arquillian-plugin/src/main/java/org/wildfly/glow/plugin/arquillian/ScanMojo.java @@ -306,56 +306,61 @@ public void execute() throws MojoExecutionException, MojoFailureException { setOutput(OutputFormat.PROVISIONING_XML).build(); ScanResults results = GlowSession.scan(artifactResolver, arguments, writer); - if (expectedDiscovery != null) { - String compact = results.getCompactInformation(); - if (!expectedDiscovery.equals(compact)) { - throw new MojoExecutionException("Error in glow discovery.\n" - + "-Expected: " + expectedDiscovery + "\n" - + "-Found : " + compact); - } - } - if (results.getErrorSession().hasErrors()) { - if (expectedErrors.isEmpty()) { - results.outputInformation(writer); - throw new MojoExecutionException("An error has been reported and expected-errors has not been set."); - } - List errors = new ArrayList<>(); - for (IdentifiedError err : results.getErrorSession().getErrors()) { - if(!err.isFixed()) { - errors.add(err); + boolean skipTests = Boolean.getBoolean("maven.test.skip") || Boolean.getBoolean("skipTests"); + if (skipTests) { + getLog().warn("Tests are disabled, not checking for expected discovered layers."); + } else { + if (expectedDiscovery != null) { + String compact = results.getCompactInformation(); + if (!expectedDiscovery.equals(compact)) { + throw new MojoExecutionException("Error in glow discovery.\n" + + "-Expected: " + expectedDiscovery + "\n" + + "-Found : " + compact); } } - if (expectedErrors.size() != errors.size()) { - List descriptions = new ArrayList<>(); - for(IdentifiedError err : errors) { - descriptions.add(err.getDescription()); + if (results.getErrorSession().hasErrors()) { + if (expectedErrors.isEmpty()) { + results.outputInformation(writer); + throw new MojoExecutionException("An error has been reported and expected-errors has not been set."); } - throw new MojoExecutionException("Number of expected errors mismatch. Expected " - + expectedErrors.size() + " reported " + errors.size() + ".\n" + - "Reported Errors " + descriptions + "\n" + - "Expected Errors " + expectedErrors); - } - Iterator it = errors.iterator(); - while (it.hasNext()) { - IdentifiedError err = it.next(); - if (expectedErrors.contains(err.getDescription())) { - it.remove(); + List errors = new ArrayList<>(); + for (IdentifiedError err : results.getErrorSession().getErrors()) { + if (!err.isFixed()) { + errors.add(err); + } } - } - it = errors.iterator(); - if (it.hasNext()) { - StringBuilder builder = new StringBuilder(); + if (expectedErrors.size() != errors.size()) { + List descriptions = new ArrayList<>(); + for (IdentifiedError err : errors) { + descriptions.add(err.getDescription()); + } + throw new MojoExecutionException("Number of expected errors mismatch. Expected " + + expectedErrors.size() + " reported " + errors.size() + ".\n" + + "Reported Errors " + descriptions + "\n" + + "Expected Errors " + expectedErrors); + } + Iterator it = errors.iterator(); while (it.hasNext()) { IdentifiedError err = it.next(); - builder.append(err.getDescription()).append("\n"); + if (expectedErrors.contains(err.getDescription())) { + it.remove(); + } + } + it = errors.iterator(); + if (it.hasNext()) { + StringBuilder builder = new StringBuilder(); + while (it.hasNext()) { + IdentifiedError err = it.next(); + builder.append(err.getDescription()).append("\n"); + } + throw new MojoExecutionException("The following errors are unexpected:\n" + builder.toString()); + } + getLog().info("Expected errors found in glow scanning results. " + + " The test execution should fix them (eg: add missing datasources)"); + } else { + if (!expectedErrors.isEmpty()) { + throw new MojoExecutionException("expected-errors contains errors but no error reported."); } - throw new MojoExecutionException("The following errors are unexpected:\n" + builder.toString()); - } - getLog().info("Expected errors found in glow scanning results. " - + " The test execution should fix them (eg: add missing datasources)"); - } else { - if (!expectedErrors.isEmpty()) { - throw new MojoExecutionException("expected-errors contains errors but no error reported."); } } if (enableVerboseOutput || getLog().isDebugEnabled()) {