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

Side by Side Diff: base/test/test_launcher.h

Issue 17551010: GTTF: TestLauncher: asynchronous and out-of-order execution of tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/test/test_launcher.cc » ('j') | base/test/test_launcher.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TEST_TEST_LAUNCHER_H_ 5 #ifndef BASE_TEST_TEST_LAUNCHER_H_
6 #define BASE_TEST_TEST_LAUNCHER_H_ 6 #define BASE_TEST_TEST_LAUNCHER_H_
7 7
8 #include <string>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
9 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/time.h"
10 14
11 namespace testing { 15 namespace testing {
12 class TestCase; 16 class TestCase;
13 class TestInfo; 17 class TestInfo;
14 } 18 }
15 19
16 namespace base { 20 namespace base {
17 21
18 // Constants for GTest command-line flags. 22 // Constants for GTest command-line flags.
19 extern const char kGTestFilterFlag[]; 23 extern const char kGTestFilterFlag[];
20 extern const char kGTestListTestsFlag[]; 24 extern const char kGTestListTestsFlag[];
21 extern const char kGTestRepeatFlag[]; 25 extern const char kGTestRepeatFlag[];
22 extern const char kGTestRunDisabledTestsFlag[]; 26 extern const char kGTestRunDisabledTestsFlag[];
23 extern const char kGTestOutputFlag[]; 27 extern const char kGTestOutputFlag[];
24 28
29 // Structure containing result of a single test.
30 struct TestResult {
31 // Name of the test case (before the dot, e.g. "A" for test "A.B").
32 std::string test_case_name;
33
34 // Name of the test (after the dot, e.g. "B" for test "A.B").
35 std::string test_name;
36
37 // True if the test passed.
38 bool success;
39
40 // Time it took to run the test.
41 base::TimeDelta elapsed_time;
42 };
43
25 // Interface for use with LaunchTests that abstracts away exact details 44 // Interface for use with LaunchTests that abstracts away exact details
26 // which tests and how are run. 45 // which tests and how are run.
27 class TestLauncherDelegate { 46 class TestLauncherDelegate {
28 public: 47 public:
29 // Called before a test is considered for running. If it returns false, 48 // Called before a test is considered for running. If it returns false,
30 // the test is not run. If it returns true, the test will be run provided 49 // the test is not run. If it returns true, the test will be run provided
31 // it is part of the current shard. 50 // it is part of the current shard.
32 virtual bool ShouldRunTest(const testing::TestCase* test_case, 51 virtual bool ShouldRunTest(const testing::TestCase* test_case,
33 const testing::TestInfo* test_info) = 0; 52 const testing::TestInfo* test_info) = 0;
34 53
35 // Called to make the delegate run specified test. Should return true 54 // Called to make the delegate run specified test. After the delegate
36 // on success. 55 // finishes running the test (can do so asynchronously and out-of-order)
37 virtual bool RunTest(const testing::TestCase* test_case, 56 // it must call |callback| regardless of test success.
38 const testing::TestInfo* test_info) = 0; 57 typedef base::Callback<void(const TestResult& result)> TestResultCallback;
58 virtual void RunTest(const testing::TestCase* test_case,
59 const testing::TestInfo* test_info,
60 const TestResultCallback& callback) = 0;
61
62 // If the delegate is running tests asynchronously, it must finish
63 // running all pending tests and call their callbacks before returning
64 // from this method.
65 virtual void RunRemainingTests() = 0;
39 66
40 protected: 67 protected:
41 virtual ~TestLauncherDelegate(); 68 virtual ~TestLauncherDelegate();
42 }; 69 };
43 70
44 // Launches GTest-based tests from the current executable 71 // Launches GTest-based tests from the current executable
45 // using |launcher_delegate|. 72 // using |launcher_delegate|.
46 int LaunchTests(TestLauncherDelegate* launcher_delegate, 73 int LaunchTests(TestLauncherDelegate* launcher_delegate,
47 int argc, 74 int argc,
48 char** argv) WARN_UNUSED_RESULT; 75 char** argv) WARN_UNUSED_RESULT;
49 76
50 } // namespace base 77 } // namespace base
51 78
52 #endif // BASE_TEST_TEST_LAUNCHER_H_ 79 #endif // BASE_TEST_TEST_LAUNCHER_H_
OLDNEW
« no previous file with comments | « no previous file | base/test/test_launcher.cc » ('j') | base/test/test_launcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698