blob: 8988b83fa9d2d33b765c3b6bd5a61be70eac3936 [file] [log] [blame]
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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';
/// Helper method to locate the root of the SDK repository.
/// The `modular_test` package is only intended to be used within the SDK at
/// this time. We need the ability to find the sdk root in order to locate the
/// default set of packages that are available to all modular tests.
Future<Uri> findRoot() async {
Uri current = Platform.script;
while (true) {
var segments = current.pathSegments;
var index = segments.lastIndexOf('sdk');
if (index == -1) {
exitCode = 1;
throw "error: cannot find the root of the Dart SDK";
current = current.resolve("../" * (segments.length - index - 1));
if (await File.fromUri(current.resolve("sdk/DEPS")).exists()) {
return current.resolve("sdk/");