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

Unified Diff: lib/src/frontend/timeout.dart

Issue 1256833003: Add Timeout.none. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Fix invoker_test. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/runner/parse_metadata.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/frontend/timeout.dart
diff --git a/lib/src/frontend/timeout.dart b/lib/src/frontend/timeout.dart
index d96407efd03256a3f89db9efbff3d8a25a27f17d..78fea385fe775b667fdd6fb1a3571c51fa5c76d4 100644
--- a/lib/src/frontend/timeout.dart
+++ b/lib/src/frontend/timeout.dart
@@ -10,10 +10,13 @@ library test.frontend.timeout;
/// can be overridden entirely; with [new Timeout.factor], it can be scaled
/// relative to the default.
class Timeout {
+ /// A constant indicating that a test should never time out.
+ static const none = const Timeout._none();
+
/// The timeout duration.
///
- /// If set, this overrides the default duration entirely. It will be
- /// non-`null` only when [scaleFactor] is `null`.
+ /// If set, this overrides the default duration entirely. It's `null` for
+ /// timeouts with a non-null [scaleFactor] and for [Timeout.none].
final Duration duration;
/// The timeout factor.
@@ -21,6 +24,9 @@ class Timeout {
/// The default timeout will be multiplied by this to get the new timeout.
/// Thus a factor of 2 means that the test will take twice as long to time
/// out, and a factor of 0.5 means that it will time out twice as quickly.
+ ///
+ /// This is `null` for timeouts with a non-null [duration] and for
+ /// [Timeout.none].
final num scaleFactor;
/// Declares an absolute timeout that overrides the default.
@@ -31,17 +37,26 @@ class Timeout {
const Timeout.factor(this.scaleFactor)
: duration = null;
+ const Timeout._none()
+ : scaleFactor = null,
+ duration = null;
+
/// Returns a new [Timeout] that merges [this] with [other].
///
/// If [other] declares a [duration], that takes precedence. Otherwise, this
/// timeout's [duration] or [factor] are multiplied by [other]'s [factor].
Timeout merge(Timeout other) {
+ if (this == none || other == none) return none;
if (other.duration != null) return new Timeout(other.duration);
if (duration != null) return new Timeout(duration * other.scaleFactor);
return new Timeout.factor(scaleFactor * other.scaleFactor);
}
/// Returns a new [Duration] from applying [this] to [base].
- Duration apply(Duration base) =>
- duration == null ? base * scaleFactor : duration;
+ ///
+ /// If this is [none], returns `null`.
+ Duration apply(Duration base) {
+ if (this == none) return null;
+ return duration == null ? base * scaleFactor : duration;
+ }
}
« no previous file with comments | « lib/src/backend/metadata.dart ('k') | lib/src/runner/parse_metadata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698