From 21b28c232777404d1ebda2dca33f739247b45739 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Mon, 4 Sep 2017 18:17:00 +0200 Subject: [PATCH 1/6] feat: ability to dump graph as a dot file --- .../SurefireForksConfigurationTest.java | 10 ++++++++- strategies/affected/pom.xml | 5 +++++ .../affected/ClassDependenciesGraph.java | 18 +++++++++------- .../strategies/affected/GraphExporter.java | 21 +++++++++++++++++++ .../affected/ast/JavaAssistClassParser.java | 3 +-- 5 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/GraphExporter.java diff --git a/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java b/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java index f60307b35..a4d8a7557 100644 --- a/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java +++ b/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java @@ -8,6 +8,7 @@ import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; import java.util.Collection; import java.util.List; @@ -25,6 +26,9 @@ public class SurefireForksConfigurationTest { @Rule public TestBed testBed = new TestBed(GIT_CLONE); + @Rule + public TestName name= new TestName(); + @Test public void test_with_reuse_forks_false() { verifyTestSuiteExecution("reuseForks", "false"); @@ -71,9 +75,13 @@ private void verifyTestSuiteExecution(String... systemPropertiesPairs){ // when final List actualTestResults = project - .build("config/impl-base") + .build() .options() + //.withRemoteDebugging() + //.withRemoteSurefireDebugging() .withSystemProperties(systemPropertiesPairs) + .withSystemProperties("graph.name", name.getMethodName()) + .withSystemProperties("smart.testing.debug", "true") // This will only be propagated to surefire for "not_reusing_forks" option .configure() .run(); diff --git a/strategies/affected/pom.xml b/strategies/affected/pom.xml index 40eec5f8d..962cf64d8 100644 --- a/strategies/affected/pom.xml +++ b/strategies/affected/pom.xml @@ -31,6 +31,11 @@ org.jgrapht jgrapht-core + + org.jgrapht + jgrapht-ext + 1.0.1 + junit junit diff --git a/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ClassDependenciesGraph.java b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ClassDependenciesGraph.java index f528934b9..39143d86e 100644 --- a/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ClassDependenciesGraph.java +++ b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ClassDependenciesGraph.java @@ -27,19 +27,19 @@ */ package org.arquillian.smart.testing.strategies.affected; -import org.arquillian.smart.testing.filter.TestVerifier; -import org.arquillian.smart.testing.strategies.affected.ast.JavaClass; -import org.arquillian.smart.testing.strategies.affected.ast.JavaClassBuilder; -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.DefaultDirectedGraph; -import org.jgrapht.graph.DefaultEdge; - import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.UUID; import java.util.stream.Collectors; +import org.arquillian.smart.testing.filter.TestVerifier; +import org.arquillian.smart.testing.strategies.affected.ast.JavaClass; +import org.arquillian.smart.testing.strategies.affected.ast.JavaClassBuilder; +import org.jgrapht.DirectedGraph; +import org.jgrapht.graph.DefaultDirectedGraph; +import org.jgrapht.graph.DefaultEdge; import static org.jgrapht.Graphs.predecessorListOf; @@ -76,6 +76,10 @@ void buildTestDependencyGraph(Collection testJavaFiles) { addToIndex(new JavaElement(javaClass), javaClass.getImports()); } } + + if (Boolean.valueOf(System.getProperty("smart.testing.debug", "false"))) { + new GraphExporter().dumpGraph(this.graph, System.getProperty("graph.name", UUID.randomUUID().toString())); + } } private void addToIndex(JavaElement javaElement, String[] imports) { diff --git a/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/GraphExporter.java b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/GraphExporter.java new file mode 100644 index 000000000..0c4a6bd1d --- /dev/null +++ b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/GraphExporter.java @@ -0,0 +1,21 @@ +package org.arquillian.smart.testing.strategies.affected; + +import org.jgrapht.DirectedGraph; +import org.jgrapht.ext.DOTExporter; +import org.jgrapht.ext.ExportException; +import org.jgrapht.graph.DefaultEdge; + +import java.io.File; + +class GraphExporter +{ + public void dumpGraph(DirectedGraph graph, String graphName) { + try { + new DOTExporter(component -> "\"" + component.getClassName() + "\"", + null, null) + .exportGraph(graph, new File(System.getProperty("java.io.tmpdir") + "/graph-" + graphName + ".dot")); + } catch (ExportException e) { + throw new RuntimeException(e); + } + } +} diff --git a/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ast/JavaAssistClassParser.java b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ast/JavaAssistClassParser.java index 650c5204e..3ec79d499 100644 --- a/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ast/JavaAssistClassParser.java +++ b/strategies/affected/src/main/java/org/arquillian/smart/testing/strategies/affected/ast/JavaAssistClassParser.java @@ -78,8 +78,7 @@ private ClassPool getClassPool() { return classPool; } - private URL[] getLoadedClasses() - { + private URL[] getLoadedClasses() { return ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs(); } From bc76fe4d2931d124e1a70bc24fe55a932d59b3b8 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Thu, 7 Sep 2017 11:33:40 +0200 Subject: [PATCH 2/6] chore: removes commented out build options --- .../ftest/configuration/SurefireForksConfigurationTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java b/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java index a4d8a7557..948cb35f1 100644 --- a/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java +++ b/functional-tests/test-bed/src/test/java/org/arquillian/smart/testing/ftest/configuration/SurefireForksConfigurationTest.java @@ -77,8 +77,6 @@ private void verifyTestSuiteExecution(String... systemPropertiesPairs){ project .build() .options() - //.withRemoteDebugging() - //.withRemoteSurefireDebugging() .withSystemProperties(systemPropertiesPairs) .withSystemProperties("graph.name", name.getMethodName()) .withSystemProperties("smart.testing.debug", "true") // This will only be propagated to surefire for "not_reusing_forks" option From 7248f3e13d184cd181e56acf70fe8696898fa992 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Wed, 13 Sep 2017 20:42:52 +0200 Subject: [PATCH 3/6] [maven-release-plugin] prepare release 0.0.1 --- core/pom.xml | 6 ++---- functional-tests/git-rules/pom.xml | 6 ++---- functional-tests/test-bed/pom.xml | 6 ++---- junit-test-result-parser/pom.xml | 6 ++---- mvn-extension/pom.xml | 6 ++---- pom.xml | 10 ++++------ strategies/affected/pom.xml | 6 ++---- strategies/changed/pom.xml | 6 ++---- strategies/failed/pom.xml | 6 ++---- surefire-provider/pom.xml | 6 ++---- 10 files changed, 22 insertions(+), 42 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 12633c7fa..835a46527 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 diff --git a/functional-tests/git-rules/pom.xml b/functional-tests/git-rules/pom.xml index 43b708d7b..36d9ac5ed 100644 --- a/functional-tests/git-rules/pom.xml +++ b/functional-tests/git-rules/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 ../../pom.xml 4.0.0 diff --git a/functional-tests/test-bed/pom.xml b/functional-tests/test-bed/pom.xml index cade29c9b..0bc9385cd 100644 --- a/functional-tests/test-bed/pom.xml +++ b/functional-tests/test-bed/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 ../../pom.xml 4.0.0 diff --git a/junit-test-result-parser/pom.xml b/junit-test-result-parser/pom.xml index 0bc39285e..4558dcd0d 100644 --- a/junit-test-result-parser/pom.xml +++ b/junit-test-result-parser/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 diff --git a/mvn-extension/pom.xml b/mvn-extension/pom.xml index 8914cea96..f7ed90b58 100644 --- a/mvn-extension/pom.xml +++ b/mvn-extension/pom.xml @@ -1,11 +1,9 @@ - + org.arquillian.smart.testing smart-testing-parent - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 diff --git a/pom.xml b/pom.xml index 53bfa769f..7fde0bab3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,19 +1,17 @@ - + 4.0.0 org.jboss jboss-parent 24 - + org.arquillian.smart.testing smart-testing-parent - 0.0.1-SNAPSHOT + 0.0.1 pom Smart testing @@ -30,7 +28,7 @@ scm:git:git://git@github.com:arquillian/smart-testing.git scm:git:ssh://github.com/arquillian/smart-testing.git git://github.com/arquillian/smart-testing.git - HEAD + 0.0.1 diff --git a/strategies/affected/pom.xml b/strategies/affected/pom.xml index 40eec5f8d..97ea36257 100644 --- a/strategies/affected/pom.xml +++ b/strategies/affected/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 ../../pom.xml 4.0.0 diff --git a/strategies/changed/pom.xml b/strategies/changed/pom.xml index 6b5c9297a..88520b2c0 100644 --- a/strategies/changed/pom.xml +++ b/strategies/changed/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 ../../pom.xml 4.0.0 diff --git a/strategies/failed/pom.xml b/strategies/failed/pom.xml index fad65b00b..3d086a520 100644 --- a/strategies/failed/pom.xml +++ b/strategies/failed/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 ../../pom.xml 4.0.0 diff --git a/surefire-provider/pom.xml b/surefire-provider/pom.xml index 20376033a..59086bf85 100644 --- a/surefire-provider/pom.xml +++ b/surefire-provider/pom.xml @@ -1,11 +1,9 @@ - + smart-testing-parent org.arquillian.smart.testing - 0.0.1-SNAPSHOT + 0.0.1 4.0.0 From 88f573e2ee2e0ac10a18ae87c11a09e4d05ee311 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Wed, 13 Sep 2017 20:42:52 +0200 Subject: [PATCH 4/6] [maven-release-plugin] prepare for next development iteration --- core/pom.xml | 2 +- functional-tests/git-rules/pom.xml | 2 +- functional-tests/test-bed/pom.xml | 2 +- junit-test-result-parser/pom.xml | 2 +- mvn-extension/pom.xml | 2 +- pom.xml | 4 ++-- strategies/affected/pom.xml | 2 +- strategies/changed/pom.xml | 2 +- strategies/failed/pom.xml | 2 +- surefire-provider/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 835a46527..51d8248ba 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT 4.0.0 diff --git a/functional-tests/git-rules/pom.xml b/functional-tests/git-rules/pom.xml index 36d9ac5ed..e353e6e30 100644 --- a/functional-tests/git-rules/pom.xml +++ b/functional-tests/git-rules/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/functional-tests/test-bed/pom.xml b/functional-tests/test-bed/pom.xml index 0bc9385cd..71138593d 100644 --- a/functional-tests/test-bed/pom.xml +++ b/functional-tests/test-bed/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/junit-test-result-parser/pom.xml b/junit-test-result-parser/pom.xml index 4558dcd0d..d94dc9570 100644 --- a/junit-test-result-parser/pom.xml +++ b/junit-test-result-parser/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT 4.0.0 diff --git a/mvn-extension/pom.xml b/mvn-extension/pom.xml index f7ed90b58..70091fab8 100644 --- a/mvn-extension/pom.xml +++ b/mvn-extension/pom.xml @@ -3,7 +3,7 @@ org.arquillian.smart.testing smart-testing-parent - 0.0.1 + 0.0.2-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index 7fde0bab3..9c1eec3b0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.arquillian.smart.testing smart-testing-parent - 0.0.1 + 0.0.2-SNAPSHOT pom Smart testing @@ -28,7 +28,7 @@ scm:git:git://git@github.com:arquillian/smart-testing.git scm:git:ssh://github.com/arquillian/smart-testing.git git://github.com/arquillian/smart-testing.git - 0.0.1 + HEAD diff --git a/strategies/affected/pom.xml b/strategies/affected/pom.xml index 97ea36257..7b0bd5add 100644 --- a/strategies/affected/pom.xml +++ b/strategies/affected/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/strategies/changed/pom.xml b/strategies/changed/pom.xml index 88520b2c0..ee032fc01 100644 --- a/strategies/changed/pom.xml +++ b/strategies/changed/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/strategies/failed/pom.xml b/strategies/failed/pom.xml index 3d086a520..b46bd7d58 100644 --- a/strategies/failed/pom.xml +++ b/strategies/failed/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/surefire-provider/pom.xml b/surefire-provider/pom.xml index 59086bf85..58a4757d6 100644 --- a/surefire-provider/pom.xml +++ b/surefire-provider/pom.xml @@ -3,7 +3,7 @@ smart-testing-parent org.arquillian.smart.testing - 0.0.1 + 0.0.2-SNAPSHOT 4.0.0 From 37eab82d4eb5f3002f2b8d37adbb5bb60cd0b301 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Wed, 13 Sep 2017 22:17:20 +0200 Subject: [PATCH 5/6] fix(docs): fixed layout in the docs --- docs/refcard.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/refcard.adoc b/docs/refcard.adoc index 5b7c422c6..1f92575a0 100644 --- a/docs/refcard.adoc +++ b/docs/refcard.adoc @@ -92,3 +92,4 @@ a|`smart.testing.report.name` |the file name of the generated report a|`smart-testing-report.xml` +|=== From ae2c215dc308eed59ba8a384708f2d0f93c7e1b8 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Wed, 13 Sep 2017 22:57:44 +0200 Subject: [PATCH 6/6] chore(deps): uses version property for jgraph-ext --- strategies/affected/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strategies/affected/pom.xml b/strategies/affected/pom.xml index 09fc96571..8fa3c2109 100644 --- a/strategies/affected/pom.xml +++ b/strategies/affected/pom.xml @@ -32,7 +32,7 @@ org.jgrapht jgrapht-ext - 1.0.1 + ${version.jgrapht} junit