From 851d9f953a065b031a64d54b064501a1c96907c0 Mon Sep 17 00:00:00 2001 From: "rnystrom@google.com" <rnystrom@google.com> Date: Tue, 23 Sep 2014 23:45:42 +0000 Subject: [PATCH] Ensure dart and pub are on PATH when spawning binstub processes in test. BUG= R=nweiz@google.com Review URL: https://codereview.chromium.org//595103002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@40617 260f80e4-7a28-3924-810f-c04153c831b5 --- .../binstub_runs_executable_test.dart | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/global/binstubs/binstub_runs_executable_test.dart b/test/global/binstubs/binstub_runs_executable_test.dart index 9abed5ae..cc3fbdb9 100644 --- a/test/global/binstubs/binstub_runs_executable_test.dart +++ b/test/global/binstubs/binstub_runs_executable_test.dart @@ -2,8 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:io'; + import 'package:path/path.dart' as p; import 'package:scheduled_test/scheduled_process.dart'; +import 'package:scheduled_test/scheduled_test.dart'; import '../../descriptor.dart' as d; import '../../test_pub.dart'; @@ -26,7 +29,8 @@ main() { schedulePub(args: ["global", "activate", "foo"]); var process = new ScheduledProcess.start( - p.join(sandboxDir, cachePath, "bin/foo-script"), ["arg1", "arg2"]); + p.join(sandboxDir, cachePath, "bin/foo-script"), ["arg1", "arg2"], + environment: getEnvironment()); process.stdout.expect("ok [arg1, arg2]"); process.shouldExit(); @@ -49,9 +53,22 @@ main() { var process = new ScheduledProcess.start( p.join(sandboxDir, cachePath, "bin/foo-script"), ["arg1", "arg2"], - environment: getPubTestEnvironment()); + environment: getEnvironment()); process.stdout.expect("ok [arg1, arg2]"); process.shouldExit(); }); } + +/// The buildbots do not have the Dart SDK (containing "dart" and "pub") on +/// their PATH, so we need to spawn the binstub process with a PATH that +/// explicitly includes it. +getEnvironment() { + var binDir = p.dirname(Platform.executable); + var separator = Platform.operatingSystem == "windows" ? ";" : ":"; + var path = "${Platform.environment["PATH"]}$separator$binDir"; + + var environment = getPubTestEnvironment(); + environment["PATH"] = path; + return environment; +} -- GitLab