22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5- #include < iostream>
6- #include < optional>
7- #include < string>
8-
95#include " flutter/fml/build_config.h"
10- #include " flutter/fml/command_line.h"
11- #include " flutter/testing/debugger_detection.h"
126#include " flutter/testing/test_timeout_listener.h"
137#include " gtest/gtest.h"
148
159#ifdef OS_IOS
1610#include < asl.h>
1711#endif // OS_IOS
1812
19- std::optional<fml::TimeDelta> GetTestTimeoutFromArgs (int argc, char ** argv) {
20- const auto command_line = fml::CommandLineFromArgcArgv (argc, argv);
21-
22- std::string timeout_seconds;
23- if (!command_line.GetOptionValue (" timeout" , &timeout_seconds)) {
24- // No timeout specified. Default to 30s.
25- return fml::TimeDelta::FromSeconds (30u );
26- }
27-
28- const auto seconds = std::stoi (timeout_seconds);
29-
30- if (seconds < 1 ) {
31- return std::nullopt ;
32- }
33-
34- return fml::TimeDelta::FromSeconds (seconds);
35- }
36-
3713int main (int argc, char ** argv) {
3814#ifdef OS_IOS
3915 asl_log_descriptor (NULL , NULL , ASL_LEVEL_NOTICE, STDOUT_FILENO,
@@ -43,23 +19,7 @@ int main(int argc, char** argv) {
4319#endif // OS_IOS
4420
4521 ::testing::InitGoogleTest (&argc, argv);
46-
47- // Check if the user has specified a timeout.
48- const auto timeout = GetTestTimeoutFromArgs (argc, argv);
49- if (!timeout.has_value ()) {
50- FML_LOG (INFO) << " Timeouts disabled via a command line flag." ;
51- return RUN_ALL_TESTS ();
52- }
53-
54- // Check if the user is debugging the process.
55- if (flutter::testing::GetDebuggerStatus () ==
56- flutter::testing::DebuggerStatus::kAttached ) {
57- FML_LOG (INFO) << " Debugger is attached. Suspending test timeouts." ;
58- return RUN_ALL_TESTS ();
59- }
60-
61- auto timeout_listener =
62- new flutter::testing::TestTimeoutListener (timeout.value ());
22+ auto timeout_listener = new flutter::testing::TestTimeoutListener ();
6323 auto & listeners = ::testing::UnitTest::GetInstance ()->listeners ();
6424 listeners.Append (timeout_listener);
6525 auto result = RUN_ALL_TESTS ();
0 commit comments