From e9a9ce6a11aa8a2003373cac8006d2fae254c739 Mon Sep 17 00:00:00 2001 From: Greg Littlefield Date: Tue, 10 Jul 2018 11:23:01 -0700 Subject: [PATCH] Automatically extend the Dartium expiration date for test/coverage tasks --- lib/src/task_process.dart | 5 +++-- lib/src/tasks/coverage/api.dart | 6 ++++-- lib/src/tasks/test/api.dart | 4 +++- lib/src/util.dart | 10 ++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/src/task_process.dart b/lib/src/task_process.dart index 20930e3e..2ec1d2b7 100644 --- a/lib/src/task_process.dart +++ b/lib/src/task_process.dart @@ -31,9 +31,10 @@ class TaskProcess { StreamController _stderr = new StreamController(); TaskProcess(String executable, List arguments, - {String workingDirectory}) { + {String workingDirectory, Map environment}) { Process - .start(executable, arguments, workingDirectory: workingDirectory) + .start(executable, arguments, + workingDirectory: workingDirectory, environment: environment) .then((process) { _process = process; process.stdout diff --git a/lib/src/tasks/coverage/api.dart b/lib/src/tasks/coverage/api.dart index 57cc4250..2b4a2256 100644 --- a/lib/src/tasks/coverage/api.dart +++ b/lib/src/tasks/coverage/api.dart @@ -18,6 +18,7 @@ import 'dart:async'; import 'dart:io'; import 'package:dart2_constant/convert.dart' as convert; +import 'package:dart_dev/src/util.dart'; import 'package:dart_dev/util.dart' show TaskProcess, getOpenPort; import 'package:path/path.dart' as path; @@ -552,8 +553,9 @@ class CoverageTask extends Task { _coverageOutput.add(''); _coverageOutput.add('Running test suite ${testPath}'); _coverageOutput.add('$executable ${args.join(' ')}\n'); - TaskProcess process = - _lastTestProcess = new TaskProcess('content_shell', args); + TaskProcess process = _lastTestProcess = new TaskProcess( + 'content_shell', args, + environment: dartiumExpirationOverrideEnv); // Content-shell dumps render tree to stderr, which is where the test // results will be. The observatory port should be output to stderr as diff --git a/lib/src/tasks/test/api.dart b/lib/src/tasks/test/api.dart index e796887d..2e1421b3 100644 --- a/lib/src/tasks/test/api.dart +++ b/lib/src/tasks/test/api.dart @@ -20,6 +20,7 @@ import 'package:dart_dev/util.dart' show TaskProcess; import 'package:dart_dev/src/tasks/task.dart'; import 'package:dart_dev/src/tools/selenium.dart' show SeleniumHelper; +import 'package:dart_dev/src/util.dart'; TestTask test( {int concurrency, @@ -38,7 +39,8 @@ TestTask test( args.addAll(additionalArgs); args.addAll(tests); - TaskProcess process = new TaskProcess(executable, args); + TaskProcess process = new TaskProcess(executable, args, + environment: dartiumExpirationOverrideEnv); Completer outputProcessed = new Completer(); TestTask task = new TestTask('$executable ${args.join(' ')}', Future.wait([process.done, outputProcessed.future])); diff --git a/lib/src/util.dart b/lib/src/util.dart index fc98bbfa..167deebb 100644 --- a/lib/src/util.dart +++ b/lib/src/util.dart @@ -110,3 +110,13 @@ Future runAll(List tasks) async { } } } + +final _newExpirationDate = new DateTime.now().add(const Duration(days: 1000)); + +/// A map of environment variables that will set the Dartium expiration +/// to 1000 days after the current date. +final Map dartiumExpirationOverrideEnv = new Map.unmodifiable({ + // This is given in seconds since epoch + 'DARTIUM_EXPIRATION_TIME': + (_newExpirationDate.millisecondsSinceEpoch / 1000).toStringAsFixed(0), +});