Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3473)

Unified Diff: base/test/launcher/unit_test_launcher.h

Issue 848903002: Extract UnitTestLauncherDelegate declaration to a header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disallow Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/launcher/unit_test_launcher.h
diff --git a/base/test/launcher/unit_test_launcher.h b/base/test/launcher/unit_test_launcher.h
index 5682ed967849b785eb52a2d7cb028eb9a482ebc2..7264e41ed65c8c418f8bee7d19420f12821c128b 100644
--- a/base/test/launcher/unit_test_launcher.h
+++ b/base/test/launcher/unit_test_launcher.h
@@ -6,6 +6,8 @@
#define BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_
#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/test/launcher/test_launcher.h"
namespace base {
@@ -31,6 +33,74 @@ int LaunchUnitTests(int argc,
const RunTestSuiteCallback& run_test_suite);
#endif // defined(OS_WIN)
+// Test launcher delegate for unit tests (mostly to support batching).
+class UnitTestLauncherDelegate : public TestLauncherDelegate {
+ public:
+ explicit UnitTestLauncherDelegate(size_t batch_limit, bool use_job_objects);
+ ~UnitTestLauncherDelegate() override;
+
+ private:
+ struct GTestCallbackState {
+ GTestCallbackState();
+ ~GTestCallbackState();
+
+ TestLauncher* test_launcher;
+ std::vector<std::string> test_names;
+ FilePath output_file;
+ };
+
+ // TestLauncherDelegate:
+ bool ShouldRunTest(const std::string& test_case_name,
+ const std::string& test_name) override;
+ size_t RunTests(TestLauncher* test_launcher,
+ const std::vector<std::string>& test_names) override;
+ size_t RetryTests(TestLauncher* test_launcher,
+ const std::vector<std::string>& test_names) override;
+
+ // Runs tests serially, each in its own process.
+ void RunSerially(TestLauncher* test_launcher,
+ const std::vector<std::string>& test_names);
+
+ // Runs tests in batches (each batch in its own process).
+ void RunBatch(TestLauncher* test_launcher,
+ const std::vector<std::string>& test_names);
+
+ // Callback for batched tests.
+ void GTestCallback(const GTestCallbackState& callback_state,
+ int exit_code,
+ const TimeDelta& elapsed_time,
+ bool was_timeout,
+ const std::string& output);
+
+ // Callback for serialized tests.
+ void SerialGTestCallback(const GTestCallbackState& callback_state,
+ const std::vector<std::string>& test_names,
+ int exit_code,
+ const TimeDelta& elapsed_time,
+ bool was_timeout,
+ const std::string& output);
+
+ // Interprets test results and reports to the test launcher. Returns true
+ // on success.
+ static bool ProcessTestResults(TestLauncher* test_launcher,
+ const std::vector<std::string>& test_names,
+ const base::FilePath& output_file,
+ const std::string& output,
+ int exit_code,
+ bool was_timeout,
+ std::vector<std::string>* tests_to_relaunch);
+
+ ThreadChecker thread_checker_;
+
+ // Maximum number of tests to run in a single batch.
+ size_t batch_limit_;
+
+ // Determines whether we use job objects on Windows.
+ bool use_job_objects_;
+
+ DISALLOW_COPY_AND_ASSIGN(UnitTestLauncherDelegate);
+};
+
} // namespace base
#endif // BASE_TEST_LAUNCHER_UNIT_TEST_LAUNCHER_H_
« no previous file with comments | « no previous file | base/test/launcher/unit_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698