@@ -58,7 +58,7 @@ public void passesIfNoException() throws Exception {
5858 " } // format" ,
5959 "} // spotless" );
6060 setFile ("README.md" ).toContent ("This code is fun." );
61- runWithSuccess (":spotlessMisc" );
61+ runWithSuccess ("> Task :spotlessMisc" );
6262 }
6363
6464 @ Test
@@ -68,9 +68,9 @@ public void anyExceptionShouldFail() throws Exception {
6868 "} // spotless" );
6969 setFile ("README.md" ).toContent ("This code is fubar." );
7070 runWithFailure (
71- ":spotlessMiscStep 'no swearing' found problem in 'README.md': " ,
72- "No swearing! " ,
73- "java.lang.RuntimeException: No swearing!" );
71+ "> Task :spotlessMisc FAILED " ,
72+ "Step 'no swearing' found problem in 'README.md': " ,
73+ "No swearing!" );
7474 }
7575
7676 @ Test
@@ -80,7 +80,7 @@ public void unlessEnforceCheckIsFalse() throws Exception {
8080 " enforceCheck false" ,
8181 "} // spotless" );
8282 setFile ("README.md" ).toContent ("This code is fubar." );
83- runWithSuccess (":compileJava UP-TO-DATE " );
83+ runWithSuccess ("> Task :compileJava NO-SOURCE " );
8484 }
8585
8686 @ Test
@@ -90,7 +90,7 @@ public void unlessExemptedByStep() throws Exception {
9090 " } // format" ,
9191 "} // spotless" );
9292 setFile ("README.md" ).toContent ("This code is fubar." );
93- runWithSuccess (":spotlessMisc" ,
93+ runWithSuccess ("> Task :spotlessMisc" ,
9494 "Unable to apply step 'no swearing' to 'README.md'" );
9595 }
9696
@@ -101,7 +101,7 @@ public void unlessExemptedByPath() throws Exception {
101101 " } // format" ,
102102 "} // spotless" );
103103 setFile ("README.md" ).toContent ("This code is fubar." );
104- runWithSuccess (":spotlessMisc" ,
104+ runWithSuccess ("> Task :spotlessMisc" ,
105105 "Unable to apply step 'no swearing' to 'README.md'" );
106106 }
107107
@@ -114,34 +114,37 @@ public void failsIfNeitherStepNorFileExempted() throws Exception {
114114 "} // spotless" );
115115 setFile ("README.md" ).toContent ("This code is fubar." );
116116 runWithFailure (
117- ":spotlessMiscStep 'no swearing' found problem in 'README.md': " ,
118- "No swearing! " ,
119- "java.lang.RuntimeException: No swearing!" );
117+ "> Task :spotlessMisc FAILED " ,
118+ "Step 'no swearing' found problem in 'README.md': " ,
119+ "No swearing!" );
120120 }
121121
122122 private void runWithSuccess (String ... messages ) throws Exception {
123123 if (JreVersion .thisVm () != JreVersion ._8 ) {
124124 return ;
125125 }
126- BuildResult result = gradleRunner ().withArguments ("check" ).build ();
126+ BuildResult result = gradleRunner ().withGradleVersion ( SpotlessPluginModern . MINIMUM_GRADLE ). withArguments ("check" ).build ();
127127 assertResultAndMessages (result , TaskOutcome .SUCCESS , messages );
128128 }
129129
130130 private void runWithFailure (String ... messages ) throws Exception {
131131 if (JreVersion .thisVm () != JreVersion ._8 ) {
132132 return ;
133133 }
134- BuildResult result = gradleRunner ().withArguments ("check" ).buildAndFail ();
134+ BuildResult result = gradleRunner ().withGradleVersion ( SpotlessPluginModern . MINIMUM_GRADLE ). withArguments ("check" ).buildAndFail ();
135135 assertResultAndMessages (result , TaskOutcome .FAILED , messages );
136136 }
137137
138138 private void assertResultAndMessages (BuildResult result , TaskOutcome outcome , String ... messages ) {
139139 String expectedToStartWith = StringPrinter .buildStringFromLines (messages ).trim ();
140140 int numNewlines = CharMatcher .is ('\n' ).countIn (expectedToStartWith );
141- List <String > actualLines = Splitter .on ('\n' ).splitToList (LineEnding .toUnix (result .getOutput ()));
141+ List <String > actualLines = Splitter .on ('\n' ).splitToList (LineEnding .toUnix (result .getOutput (). trim () ));
142142 String actualStart = String .join ("\n " , actualLines .subList (0 , numNewlines + 1 ));
143143 Assertions .assertThat (actualStart ).isEqualTo (expectedToStartWith );
144- Assertions .assertThat (result .tasks (outcome ).size () + result .tasks (TaskOutcome .UP_TO_DATE ).size ())
144+ // result.getTasks()
145+ // .stream()
146+ // .forEach(task -> System.out.println("task " + task.getPath() + " " + task.getOutcome()));
147+ Assertions .assertThat (result .tasks (outcome ).size () + result .tasks (TaskOutcome .UP_TO_DATE ).size () + result .tasks (TaskOutcome .NO_SOURCE ).size ())
145148 .isEqualTo (result .getTasks ().size ());
146149 }
147150}
0 commit comments