@@ -58,7 +58,7 @@ public void passesIfNoException() throws Exception {
58
58
" } // format" ,
59
59
"} // spotless" );
60
60
setFile ("README.md" ).toContent ("This code is fun." );
61
- runWithSuccess (":spotlessMisc" );
61
+ runWithSuccess ("> Task :spotlessMisc" );
62
62
}
63
63
64
64
@ Test
@@ -68,9 +68,9 @@ public void anyExceptionShouldFail() throws Exception {
68
68
"} // spotless" );
69
69
setFile ("README.md" ).toContent ("This code is fubar." );
70
70
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!" );
74
74
}
75
75
76
76
@ Test
@@ -80,7 +80,7 @@ public void unlessEnforceCheckIsFalse() throws Exception {
80
80
" enforceCheck false" ,
81
81
"} // spotless" );
82
82
setFile ("README.md" ).toContent ("This code is fubar." );
83
- runWithSuccess (":compileJava UP-TO-DATE " );
83
+ runWithSuccess ("> Task :compileJava NO-SOURCE " );
84
84
}
85
85
86
86
@ Test
@@ -90,7 +90,7 @@ public void unlessExemptedByStep() throws Exception {
90
90
" } // format" ,
91
91
"} // spotless" );
92
92
setFile ("README.md" ).toContent ("This code is fubar." );
93
- runWithSuccess (":spotlessMisc" ,
93
+ runWithSuccess ("> Task :spotlessMisc" ,
94
94
"Unable to apply step 'no swearing' to 'README.md'" );
95
95
}
96
96
@@ -101,7 +101,7 @@ public void unlessExemptedByPath() throws Exception {
101
101
" } // format" ,
102
102
"} // spotless" );
103
103
setFile ("README.md" ).toContent ("This code is fubar." );
104
- runWithSuccess (":spotlessMisc" ,
104
+ runWithSuccess ("> Task :spotlessMisc" ,
105
105
"Unable to apply step 'no swearing' to 'README.md'" );
106
106
}
107
107
@@ -114,34 +114,37 @@ public void failsIfNeitherStepNorFileExempted() throws Exception {
114
114
"} // spotless" );
115
115
setFile ("README.md" ).toContent ("This code is fubar." );
116
116
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!" );
120
120
}
121
121
122
122
private void runWithSuccess (String ... messages ) throws Exception {
123
123
if (JreVersion .thisVm () != JreVersion ._8 ) {
124
124
return ;
125
125
}
126
- BuildResult result = gradleRunner ().withArguments ("check" ).build ();
126
+ BuildResult result = gradleRunner ().withGradleVersion ( SpotlessPluginModern . MINIMUM_GRADLE ). withArguments ("check" ).build ();
127
127
assertResultAndMessages (result , TaskOutcome .SUCCESS , messages );
128
128
}
129
129
130
130
private void runWithFailure (String ... messages ) throws Exception {
131
131
if (JreVersion .thisVm () != JreVersion ._8 ) {
132
132
return ;
133
133
}
134
- BuildResult result = gradleRunner ().withArguments ("check" ).buildAndFail ();
134
+ BuildResult result = gradleRunner ().withGradleVersion ( SpotlessPluginModern . MINIMUM_GRADLE ). withArguments ("check" ).buildAndFail ();
135
135
assertResultAndMessages (result , TaskOutcome .FAILED , messages );
136
136
}
137
137
138
138
private void assertResultAndMessages (BuildResult result , TaskOutcome outcome , String ... messages ) {
139
139
String expectedToStartWith = StringPrinter .buildStringFromLines (messages ).trim ();
140
140
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 () ));
142
142
String actualStart = String .join ("\n " , actualLines .subList (0 , numNewlines + 1 ));
143
143
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 ())
145
148
.isEqualTo (result .getTasks ().size ());
146
149
}
147
150
}
0 commit comments