Skip to content

Commit

Permalink
[tests] Clear adb logcat after we collect the logcat output (#2495)
Browse files Browse the repository at this point in the history
Clearing `adb logcat` output after running an on-device test makes it
easier to find problems within the logcat output, as it will only
contain the information relevant to that particular test run.

As we clear it after the run, the first test logcat on a freshly
started emulator will also contain the startup info in case it is
needed.
  • Loading branch information
radekdoulik authored and jonpryor committed Dec 7, 2018
1 parent 3221282 commit 423c81a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class RunInstrumentationTests : Adb
const string TestResultsPathResult = "INSTRUMENTATION_RESULT: nunit2-results-path=";
const int StateRunInstrumentation = 0;
const int StateGetLogcat = 1;
const int StatePullFiles = 2;
const int StateClearLogcat = 2;
const int StatePullFiles = 3;
const int MaxState = StatePullFiles;

public string TestFixture { get; set; }
Expand Down Expand Up @@ -81,6 +82,10 @@ public override bool Execute ()
StdoutAppend = true,
},

new CommandInfo {
ArgumentsString = $"{AdbTarget} {AdbOptions} logcat -c",
},

new CommandInfo {
ArgumentsGenerator = () => $"{AdbTarget} {AdbOptions} pull \"{targetTestResultsPath}\" \"{NUnit2TestResultsFile}\"",
ShouldRun = () => !String.IsNullOrEmpty (targetTestResultsPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class RunUITests : Adb
{
const int StateRunTests = 0;
const int StateGetLogcat = 1;
const int StateClearLogcat = 2;

[Required]
public string Activity { get; set; }
Expand Down Expand Up @@ -37,6 +38,11 @@ protected virtual void AfterCommand (int commandIndex, CommandInfo info)
StdoutFilePath = LogcatFilename,
StdoutAppend = true,
},

new CommandInfo {
ArgumentsString = $"{AdbTarget} {AdbOptions} logcat -c",
},

};
}
}
Expand Down

0 comments on commit 423c81a

Please sign in to comment.