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

Side by Side Diff: base/test/launcher/test_result.h

Issue 2606153003: Report failed expect/assert to test launcher summary output. (Closed)
Patch Set: Fix msvc warning. Created 3 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 unified diff | Download patch
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_LAUNCHER_TEST_RESULT_H_ 5 #ifndef BASE_TEST_LAUNCHER_TEST_RESULT_H_
6 #define BASE_TEST_LAUNCHER_TEST_RESULT_H_ 6 #define BASE_TEST_LAUNCHER_TEST_RESULT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 12
12 namespace base { 13 namespace base {
13 14
15 // Structure contains result of a single EXPECT/ASSERT/SUCCESS.
16 struct TestResultPart {
17 enum Type {
18 kSuccess, // SUCCESS
19 kNonFatalFailure, // EXPECT
20 kFatalFailure, // ASSERT
21 };
22 Type type;
23
24 TestResultPart();
25 ~TestResultPart();
26
27 TestResultPart(const TestResultPart& other);
Paweł Hajdan Jr. 2016/12/30 19:02:39 Why do we need these ctors/operators?
alex-ac 2016/12/30 22:10:20 chromium-style clang plugin makes a warning about
28 TestResultPart(TestResultPart&& other);
29 TestResultPart& operator=(const TestResultPart& other);
30 TestResultPart& operator=(TestResultPart&& other);
31
32 // Convert type to string and back.
33 static bool TypeFromString(const std::string& str, Type* type);
34 std::string TypeAsString() const;
35
36 // Filename and line of EXPECT/ASSERT.
37 std::string file_name;
38 int line_number;
39
40 // Message without stacktrace, etc.
41 std::string summary;
42
43 // Complete message.
44 std::string message;
45 };
46
14 // Structure containing result of a single test. 47 // Structure containing result of a single test.
15 struct TestResult { 48 struct TestResult {
16 enum Status { 49 enum Status {
17 TEST_UNKNOWN, // Status not set. 50 TEST_UNKNOWN, // Status not set.
18 TEST_SUCCESS, // Test passed. 51 TEST_SUCCESS, // Test passed.
19 TEST_FAILURE, // Assertion failure (e.g. EXPECT_TRUE, not DCHECK). 52 TEST_FAILURE, // Assertion failure (e.g. EXPECT_TRUE, not DCHECK).
20 TEST_FAILURE_ON_EXIT, // Passed but executable exit code was non-zero. 53 TEST_FAILURE_ON_EXIT, // Passed but executable exit code was non-zero.
21 TEST_TIMEOUT, // Test timed out and was killed. 54 TEST_TIMEOUT, // Test timed out and was killed.
22 TEST_CRASH, // Test crashed (includes CHECK/DCHECK failures). 55 TEST_CRASH, // Test crashed (includes CHECK/DCHECK failures).
23 TEST_SKIPPED, // Test skipped (not run at all). 56 TEST_SKIPPED, // Test skipped (not run at all).
24 TEST_EXCESSIVE_OUTPUT, // Test exceeded output limit. 57 TEST_EXCESSIVE_OUTPUT, // Test exceeded output limit.
25 }; 58 };
26 59
27 TestResult(); 60 TestResult();
28 ~TestResult(); 61 ~TestResult();
29 62
63 TestResult(const TestResult& other);
Paweł Hajdan Jr. 2016/12/30 19:02:39 Why do we need these ctors/operators?
alex-ac 2016/12/30 22:10:20 This is the same case (it seems that field of type
64 TestResult(TestResult&& other);
65 TestResult& operator=(const TestResult& other);
66 TestResult& operator=(TestResult&& other);
67
30 // Returns the test status as string (e.g. for display). 68 // Returns the test status as string (e.g. for display).
31 std::string StatusAsString() const; 69 std::string StatusAsString() const;
32 70
33 // Returns the test name (e.g. "B" for "A.B"). 71 // Returns the test name (e.g. "B" for "A.B").
34 std::string GetTestName() const; 72 std::string GetTestName() const;
35 73
36 // Returns the test case name (e.g. "A" for "A.B"). 74 // Returns the test case name (e.g. "A" for "A.B").
37 std::string GetTestCaseName() const; 75 std::string GetTestCaseName() const;
38 76
39 // Returns true if the test has completed (i.e. the test binary exited 77 // Returns true if the test has completed (i.e. the test binary exited
40 // normally, possibly with an exit code indicating failure, but didn't crash 78 // normally, possibly with an exit code indicating failure, but didn't crash
41 // or time out in the middle of the test). 79 // or time out in the middle of the test).
42 bool completed() const { 80 bool completed() const {
43 return status == TEST_SUCCESS || 81 return status == TEST_SUCCESS ||
44 status == TEST_FAILURE || 82 status == TEST_FAILURE ||
45 status == TEST_FAILURE_ON_EXIT || 83 status == TEST_FAILURE_ON_EXIT ||
46 status == TEST_EXCESSIVE_OUTPUT; 84 status == TEST_EXCESSIVE_OUTPUT;
47 } 85 }
48 86
49 // Full name of the test (e.g. "A.B"). 87 // Full name of the test (e.g. "A.B").
50 std::string full_name; 88 std::string full_name;
51 89
52 Status status; 90 Status status;
53 91
54 // Time it took to run the test. 92 // Time it took to run the test.
55 base::TimeDelta elapsed_time; 93 base::TimeDelta elapsed_time;
56 94
57 // Output of just this test (optional). 95 // Output of just this test (optional).
58 std::string output_snippet; 96 std::string output_snippet;
97
98 // Information about failed expectations.
99 std::vector<TestResultPart> test_result_parts;
59 }; 100 };
60 101
61 } // namespace base 102 } // namespace base
62 103
63 #endif // BASE_TEST_LAUNCHER_TEST_RESULT_H_ 104 #endif // BASE_TEST_LAUNCHER_TEST_RESULT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698