Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disables extension when test execution is skipped #102

Merged
merged 4 commits into from Aug 21, 2017

Conversation

hemanik
Copy link
Contributor

@hemanik hemanik commented Aug 8, 2017

Changes proposed in this pull request:

  • Check for maven.test.skip, skipTests and skipITs property honored by Surefire and Failsafe plugins.
  • Ignore smart-testing-extension registration/configuration.
  • Tests to verify the change depending on the logger message.

Fixes #73

@@ -45,6 +45,10 @@ public boolean isModeSet() {
return this.mode != null;
}

public boolean isSkipTests() {
return Boolean.valueOf(System.getProperty("maven.test.skip", "false"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also you can set it by using skipTestsproperty. If it is set then using -DskipTests then tests are also skipped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing to check here would be if -DskipTests does not imply maven.test.skip set implictly.

@bartoszmajsak
Copy link
Member

bartoszmajsak commented Aug 8, 2017

Pending tasks:

  • Handle failsafe in the same way

final List<TestResult> actualTestResults = project
.build()
.options()
//.withSystemProperties("maven.test.skip", "true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we testing here?

@@ -33,7 +33,7 @@ public void afterProjectsRead(MavenSession session) throws MavenExecutionExcepti

configuration = Configuration.load();

if (configuration.isDisabled()) {
if (configuration.isDisabled() && configuration.isSkipTests()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSkipTestsSet reflects better what is the use case here. It doesn't have to follow the artificial javabean spec.

@hemanik hemanik force-pushed the disable-extension branch 3 times, most recently from 764040a to 0b4dc9d Compare August 10, 2017 07:19
@@ -28,17 +28,21 @@

private Configuration configuration;

private MavenProjectConfigurator mavenProjectConfigurator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is slightly confusing - storing the MavenProjectConfigurator as a global variable just because of reading system properties. If you retrieve the information from system properties, then it can be used as a public static method from separated class. The other case would be storing a boolean flag as a information that the ST tool has been initialized (based on information that it has (not) been disabled or the test has (not) been skipped)

@hemanik hemanik force-pushed the disable-extension branch 5 times, most recently from f4516e1 to a83c3dc Compare August 14, 2017 18:13
logCapturingStream = new ByteArrayOutputStream();
PrintStream newPrintStream = new PrintStream(logCapturingStream);
oldPrintStream = System.out;
System.setOut(newPrintStream);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BuiltProject from Embedded Maven we are using under the hood in ProjectBuilder exposes getMavenLog(). So I was thinking - maybe instead of replacing the output stream to ours for capturing how about making this log available through DSL? This would also let us run those tests not sequentially.

@hemanik hemanik force-pushed the disable-extension branch 2 times, most recently from adde2c0 to f827ef2 Compare August 16, 2017 17:37
@bartoszmajsak
Copy link
Member

Can you check why the build is failing?

@hemanik
Copy link
Contributor Author

hemanik commented Aug 17, 2017

When using the build with projects, the related project dependencies are not resolved.
In order to test for instance config/impl-base project, we also need to include dependent projects - config/api, core/api, core/spi, core/impl-base.
So for the current scenario then we should either include these 5 projects for the test or the complete build.

@bartoszmajsak
Copy link
Member

When using the build with projects, the related project dependencies are not resolved.
In order to test for instance config/impl-base project, we also need to include dependent projects - config/api, core/api, core/spi, core/impl-base.
So for the current scenario then we should either include these 5 projects for the test or the complete build.

This is how Maven works unfortunately.

Other option would be to take one of the most upper projects, like -api which does not have any dependency on the other modules from the project.

@@ -34,6 +34,8 @@
private boolean mvnDebugOutput;
private boolean enableSurefireRemoteDebugging = false;
private boolean ignoreBuildFailure = false;
private boolean skipTests = false;
private String mavenLog = "false";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather fuzzy. I don't really see a reason to have it as a string / container for the log content and a "boolean flag".

return this;
}

public BuildConfigurator withMavenLog() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really needed. Maven log is always kept in the case of how we use embedded maven, so simple method for retrieving it from the build is enough. This is making it overcomplicated considering how it's done underneath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

}

private boolean isSkip() {
return Boolean.valueOf(System.getProperty("maven.test.skip", "false"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, move these methods outside of this class. The logic retrieves static information - so, they can be static methods.
See this comment: #102 (comment)

@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {

configuration = Configuration.load();

if (configuration.isDisabled()) {
final MavenProjectConfigurator mavenProjectConfigurator = new MavenProjectConfigurator(configuration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I have written above - it is not necessary to create an instance of the class just because of retrieving system properties...

@bartoszmajsak bartoszmajsak merged commit b26a69a into arquillian:master Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants