OLD | NEW |
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 #include "base/test/launcher/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 SplitString(filter, ':', &positive_test_filter_); | 822 SplitString(filter, ':', &positive_test_filter_); |
823 } else { | 823 } else { |
824 // Everything up to the dash. | 824 // Everything up to the dash. |
825 SplitString(filter.substr(0, dash_pos), ':', &positive_test_filter_); | 825 SplitString(filter.substr(0, dash_pos), ':', &positive_test_filter_); |
826 | 826 |
827 // Everything after the dash. | 827 // Everything after the dash. |
828 SplitString(filter.substr(dash_pos + 1), ':', &negative_test_filter_); | 828 SplitString(filter.substr(dash_pos + 1), ':', &negative_test_filter_); |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
| 832 if (!launcher_delegate_->GetTests(&tests_)) { |
| 833 LOG(ERROR) << "Failed to get list of tests."; |
| 834 return false; |
| 835 } |
| 836 |
832 if (!results_tracker_.Init(*command_line)) { | 837 if (!results_tracker_.Init(*command_line)) { |
833 LOG(ERROR) << "Failed to initialize test results tracker."; | 838 LOG(ERROR) << "Failed to initialize test results tracker."; |
834 return 1; | 839 return 1; |
835 } | 840 } |
836 | 841 |
837 #if defined(NDEBUG) | 842 #if defined(NDEBUG) |
838 results_tracker_.AddGlobalTag("MODE_RELEASE"); | 843 results_tracker_.AddGlobalTag("MODE_RELEASE"); |
839 #else | 844 #else |
840 results_tracker_.AddGlobalTag("MODE_DEBUG"); | 845 results_tracker_.AddGlobalTag("MODE_DEBUG"); |
841 #endif | 846 #endif |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 #endif | 898 #endif |
894 | 899 |
895 #if defined(ARCH_CPU_64_BITS) | 900 #if defined(ARCH_CPU_64_BITS) |
896 results_tracker_.AddGlobalTag("CPU_64_BITS"); | 901 results_tracker_.AddGlobalTag("CPU_64_BITS"); |
897 #endif | 902 #endif |
898 | 903 |
899 return true; | 904 return true; |
900 } | 905 } |
901 | 906 |
902 void TestLauncher::RunTests() { | 907 void TestLauncher::RunTests() { |
903 std::vector<SplitTestName> tests(GetCompiledInTests()); | |
904 | |
905 std::vector<std::string> test_names; | 908 std::vector<std::string> test_names; |
906 | 909 for (size_t i = 0; i < tests_.size(); i++) { |
907 for (size_t i = 0; i < tests.size(); i++) { | 910 std::string test_name = FormatFullTestName( |
908 std::string test_name = FormatFullTestName(tests[i].first, tests[i].second); | 911 tests_[i].first, tests_[i].second); |
909 | 912 |
910 results_tracker_.AddTest(test_name); | 913 results_tracker_.AddTest(test_name); |
911 | 914 |
912 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 915 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
913 if (test_name.find("DISABLED") != std::string::npos) { | 916 if (test_name.find("DISABLED") != std::string::npos) { |
914 results_tracker_.AddDisabledTest(test_name); | 917 results_tracker_.AddDisabledTest(test_name); |
915 | 918 |
916 // Skip disabled tests unless explicitly requested. | 919 // Skip disabled tests unless explicitly requested. |
917 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag)) | 920 if (!command_line->HasSwitch(kGTestRunDisabledTestsFlag)) |
918 continue; | 921 continue; |
919 } | 922 } |
920 | 923 |
921 if (!launcher_delegate_->ShouldRunTest(tests[i].first, tests[i].second)) | 924 if (!launcher_delegate_->ShouldRunTest(tests_[i].first, tests_[i].second)) |
922 continue; | 925 continue; |
923 | 926 |
924 // Skip the test that doesn't match the filter (if given). | 927 // Skip the test that doesn't match the filter (if given). |
925 if (!positive_test_filter_.empty()) { | 928 if (!positive_test_filter_.empty()) { |
926 bool found = false; | 929 bool found = false; |
927 for (size_t k = 0; k < positive_test_filter_.size(); ++k) { | 930 for (size_t k = 0; k < positive_test_filter_.size(); ++k) { |
928 if (MatchPattern(test_name, positive_test_filter_[k])) { | 931 if (MatchPattern(test_name, positive_test_filter_[k])) { |
929 found = true; | 932 found = true; |
930 break; | 933 break; |
931 } | 934 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 } | 1084 } |
1082 | 1085 |
1083 std::string snippet(full_output.substr(run_pos)); | 1086 std::string snippet(full_output.substr(run_pos)); |
1084 if (end_pos != std::string::npos) | 1087 if (end_pos != std::string::npos) |
1085 snippet = full_output.substr(run_pos, end_pos - run_pos); | 1088 snippet = full_output.substr(run_pos, end_pos - run_pos); |
1086 | 1089 |
1087 return snippet; | 1090 return snippet; |
1088 } | 1091 } |
1089 | 1092 |
1090 } // namespace base | 1093 } // namespace base |
OLD | NEW |