| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library gcloud.test.common_e2e; | 5 library gcloud.test.common_e2e; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 envName = 'USERNAME'; | 44 envName = 'USERNAME'; |
| 45 } else { | 45 } else { |
| 46 envName = 'USER'; | 46 envName = 'USER'; |
| 47 } | 47 } |
| 48 return Platform.environment[envName] == 'chrome-bot'; | 48 return Platform.environment[envName] == 'chrome-bot'; |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Get the service key from the specified location. | 51 // Get the service key from the specified location. |
| 52 Future<String> serviceKeyJson(String serviceKeyLocation) { | 52 Future<String> serviceKeyJson(String serviceKeyLocation) { |
| 53 if (!serviceKeyLocation.startsWith('gs://')) { | 53 if (!serviceKeyLocation.startsWith('gs://')) { |
| 54 throw new Exception('Service key location must start with gs://'); | 54 return new File(serviceKeyLocation).readAsString(); |
| 55 } | 55 } |
| 56 var future; | 56 var future; |
| 57 if (onBot()) { | 57 if (onBot()) { |
| 58 future = Process.run( | 58 future = Process.run( |
| 59 'python', ['third_party/gsutil/gsutil', 'cat', serviceKeyLocation], | 59 'python', ['third_party/gsutil/gsutil', 'cat', serviceKeyLocation], |
| 60 runInShell: true); | 60 runInShell: true); |
| 61 } else { | 61 } else { |
| 62 var gsutil = Platform.isWindows ? 'gsutil.cmd' : 'gsutil'; | 62 var gsutil = Platform.isWindows ? 'gsutil.cmd' : 'gsutil'; |
| 63 future = Process.run(gsutil, ['cat', serviceKeyLocation]); | 63 future = Process.run(gsutil, ['cat', serviceKeyLocation]); |
| 64 } | 64 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 Future get done => _completer.future; | 112 Future get done => _completer.future; |
| 113 | 113 |
| 114 onDone(success) { | 114 onDone(success) { |
| 115 new Future.sync(() { | 115 new Future.sync(() { |
| 116 super.onDone(success); | 116 super.onDone(success); |
| 117 }).then((_) => _completer.complete(_)) | 117 }).then((_) => _completer.complete(_)) |
| 118 .catchError((error, stack) => _completer.completeError(error, stack)); | 118 .catchError((error, stack) => _completer.completeError(error, stack)); |
| 119 } | 119 } |
| 120 } | 120 } |
| OLD | NEW |