18
18
import static org .hamcrest .CoreMatchers .containsString ;
19
19
import static org .hamcrest .CoreMatchers .not ;
20
20
import static org .hamcrest .MatcherAssert .assertThat ;
21
+ import static org .mockito .ArgumentMatchers .eq ;
21
22
import static org .mockito .Mockito .mock ;
23
+ import static org .mockito .Mockito .never ;
24
+ import static org .mockito .Mockito .verify ;
22
25
import static org .mockito .Mockito .when ;
23
26
24
27
import com .google .common .collect .ImmutableList ;
54
57
import com .google .devtools .build .lib .buildtool .buildevent .TestFilteringCompleteEvent ;
55
58
import com .google .devtools .build .lib .cmdline .Label ;
56
59
import com .google .devtools .build .lib .cmdline .LabelSyntaxException ;
60
+ import com .google .devtools .build .lib .cmdline .RepositoryMapping ;
61
+ import com .google .devtools .build .lib .cmdline .RepositoryName ;
57
62
import com .google .devtools .build .lib .events .ExtendedEventHandler .FetchProgress ;
58
63
import com .google .devtools .build .lib .pkgcache .LoadingPhaseCompleteEvent ;
59
64
import com .google .devtools .build .lib .runtime .SkymeldUiStateTracker .BuildStatus ;
83
88
import net .starlark .java .syntax .Location ;
84
89
import org .junit .Test ;
85
90
import org .junit .runner .RunWith ;
91
+ import org .mockito .AdditionalMatchers ;
86
92
87
93
/** Tests {@link UiStateTracker}. */
88
94
@ RunWith (TestParameterInjector .class )
89
95
public class UiStateTrackerTest extends FoundationTestCase {
90
96
91
97
@ TestParameter boolean isSkymeld ;
98
+ static final RepositoryMapping MOCK_REPO_MAPPING =
99
+ RepositoryMapping .createAllowingFallback (ImmutableMap .of ("main" , RepositoryName .MAIN ));
92
100
93
101
private UiStateTracker getUiStateTracker (ManualClock clock ) {
94
102
if (isSkymeld ) {
@@ -186,8 +194,11 @@ private Action mockAction(String progressMessage, String primaryOutput) {
186
194
ActionsTestUtil .createArtifact (ArtifactRoot .asSourceRoot (Root .fromPath (outputBase )), path );
187
195
188
196
Action action = mock (Action .class );
189
- when (action .getProgressMessage ()).thenReturn (progressMessage );
197
+ when (action .getProgressMessage (eq ( MOCK_REPO_MAPPING ) )).thenReturn (progressMessage );
190
198
when (action .getPrimaryOutput ()).thenReturn (artifact );
199
+
200
+ verify (action , never ()).getProgressMessage (AdditionalMatchers .not (eq (MOCK_REPO_MAPPING )));
201
+ verify (action , never ()).getProgressMessage ();
191
202
return action ;
192
203
}
193
204
@@ -208,9 +219,13 @@ private ActionOwner dummyActionOwner() throws LabelSyntaxException {
208
219
}
209
220
210
221
private void simulateExecutionPhase (UiStateTracker uiStateTracker ) {
222
+ uiStateTracker .loadingComplete (
223
+ new LoadingPhaseCompleteEvent (ImmutableSet .of (), ImmutableSet .of (), MOCK_REPO_MAPPING ));
211
224
if (this .isSkymeld ) {
212
225
// SkymeldUiStateTracker needs to be in the configuration phase before the execution phase.
213
226
((SkymeldUiStateTracker ) uiStateTracker ).buildStatus = BuildStatus .ANALYSIS_COMPLETE ;
227
+ } else {
228
+ String unused = uiStateTracker .analysisComplete ();
214
229
}
215
230
uiStateTracker .progressReceiverAvailable (
216
231
new ExecutionProgressReceiverAvailableEvent (dummyExecutionProgressReceiver ()));
@@ -254,7 +269,7 @@ public void testLoadingActivity() throws IOException {
254
269
255
270
// When it is configuring targets.
256
271
stateTracker .loadingComplete (
257
- new LoadingPhaseCompleteEvent (ImmutableSet .of (), ImmutableSet .of ()));
272
+ new LoadingPhaseCompleteEvent (ImmutableSet .of (), ImmutableSet .of (), MOCK_REPO_MAPPING ));
258
273
String additionalMessage = "5 targets" ;
259
274
stateTracker .additionalMessage = additionalMessage ;
260
275
String configuredTargetProgressString = "5 targets configured" ;
0 commit comments