• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tradefed.retry;
17 
18 import com.android.tradefed.config.IConfiguration;
19 import com.android.tradefed.result.ILogSaver;
20 import com.android.tradefed.result.ITestInvocationListener;
21 import com.android.tradefed.result.LogSaverResultForwarder;
22 
23 import java.util.List;
24 
25 /** Forwarder that also handles passing the current attempt we are at. */
26 public class RetryLogSaverResultForwarder extends LogSaverResultForwarder {
27 
28     private int mAttemptNumber = 0;
29     private IConfiguration mConfig;
30 
RetryLogSaverResultForwarder( ILogSaver logSaver, List<ITestInvocationListener> listeners, IConfiguration config)31     public RetryLogSaverResultForwarder(
32             ILogSaver logSaver, List<ITestInvocationListener> listeners, IConfiguration config) {
33         super(logSaver, listeners, config);
34     }
35 
36     @Override
testRunStarted(String runName, int testCount)37     public void testRunStarted(String runName, int testCount) {
38         super.testRunStarted(runName, testCount, mAttemptNumber);
39     }
40 
41     @Override
testRunStarted(String runName, int testCount, int attemptNumber)42     public void testRunStarted(String runName, int testCount, int attemptNumber) {
43         // We enforce our attempt number
44         super.testRunStarted(runName, testCount, mAttemptNumber);
45     }
46 
47     @Override
testRunStarted(String runName, int testCount, int attemptNumber, long startTime)48     public void testRunStarted(String runName, int testCount, int attemptNumber, long startTime) {
49         // We enforce our attempt number
50         super.testRunStarted(runName, testCount, mAttemptNumber, startTime);
51     }
52 
53     /** Increment the attempt number. */
incrementAttempt()54     public void incrementAttempt() {
55         mAttemptNumber++;
56     }
57 }
58