public void submitTestRun(final String testBinaryPath, final Collection<String> testNames) { final String testFilterFlag = testNames.isEmpty() ? "" : "--gtest_filter=" + String.join(":", testNames); final String[] command = new String[] {testBinaryPath, testFilterFlag}; parser.clearState(); processRunner = new ProcessRunner(); executorService.submit(() -> runTests(command)); }
private void readBinary(final String[] command) { LOGGER.fine( () -> "Starting reading binary with command: " + String.join(" ", Arrays.asList(command))); final Collection<String> lines = new ArrayList<>(); boolean hasSucceed = false; Collection<String> testNames = Collections.emptyList(); try { final int exitCode = processRunner.start(command, lines::add); if (exitCode == 0) { testNames = parser.parseTestList(lines); hasSucceed = true; LOGGER.fine("Reading binary process exits with normal code"); } else { LOGGER.warning("Reading binary process exits with " + exitCode + " code"); } } catch (IOException | ParseException e) { LOGGER.warning("Reading binary process throws exception: " + e.getMessage()); } finally { for (TestRunnerHandler handler : testRunnerHandlers) { handler.onTestsLoadingFinished(hasSucceed, testNames); } } }
public void submitReadBinary(final String testBinaryPath) { final String[] command = new String[] {testBinaryPath, "--gtest_list_tests"}; parser.clearState(); processRunner = new ProcessRunner(); executorService.submit(() -> readBinary(command)); }