Skip to content

Commit 5d4b4e2

Browse files
authored
Revert "Control test timeouts based on debugger status or command line flags. (flutter#16375)"
This reverts commit e449472.
1 parent 554e332 commit 5d4b4e2

6 files changed

Lines changed: 4 additions & 142 deletions

File tree

testing/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ source_set("testing") {
2727
testonly = true
2828

2929
sources = [
30-
"debugger_detection.cc",
31-
"debugger_detection.h",
3230
"run_all_unittests.cc",
3331
"test_timeout_listener.cc",
3432
"test_timeout_listener.h",

testing/debugger_detection.cc

Lines changed: 0 additions & 71 deletions
This file was deleted.

testing/debugger_detection.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

testing/run_all_unittests.cc

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,14 @@
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-
3713
int 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();

testing/test_timeout_listener.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ TestTimeoutListener::TestTimeoutListener(fml::TimeDelta timeout)
7272
: timeout_(timeout),
7373
listener_thread_("test_timeout_listener"),
7474
listener_thread_runner_(listener_thread_.GetTaskRunner()),
75-
pending_tests_(PendingTests::Create(listener_thread_runner_, timeout_)) {
76-
FML_LOG(INFO) << "Test timeout of " << timeout_.ToSeconds()
77-
<< " seconds per test case will be enforced.";
78-
}
75+
pending_tests_(PendingTests::Create(listener_thread_runner_, timeout_)) {}
7976

8077
TestTimeoutListener::~TestTimeoutListener() {
8178
listener_thread_runner_->PostTask(

testing/test_timeout_listener.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class PendingTests;
1919

2020
class TestTimeoutListener : public ::testing::EmptyTestEventListener {
2121
public:
22-
TestTimeoutListener(fml::TimeDelta timeout);
22+
TestTimeoutListener(
23+
fml::TimeDelta timeout = fml::TimeDelta::FromSeconds(30u));
2324

2425
~TestTimeoutListener();
2526

0 commit comments

Comments
 (0)