diff --git a/dev/tools/bin/engine_hash.sh b/dev/tools/bin/engine_hash.sh deleted file mode 100755 index 348ad39c673..00000000000 --- a/dev/tools/bin/engine_hash.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2014 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# ---------------------------------- NOTE ---------------------------------- # -# -# This file will appear unused within the monorepo. It is used internally -# (in google3) as part of the roll process, and care should be put before -# making changes. -# -# See cl/688973229. -# -# -------------------------------------------------------------------------- # - -# Needed because if it is set, cd may print the path it changed to. -unset CDPATH - -# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one -# link at a time, and then cds into the link destination and find out where it -# ends up. -# -# The returned filesystem path must be a format usable by Dart's URI parser, -# since the Dart command line tool treats its argument as a file URI, not a -# filename. For instance, multiple consecutive slashes should be reduced to a -# single slash, since double-slashes indicate a URI "authority", and these are -# supposed to be filenames. There is an edge case where this will return -# multiple slashes: when the input resolves to the root directory. However, if -# that were the case, we wouldn't be running this shell, so we don't do anything -# about it. -# -# The function is enclosed in a subshell to avoid changing the working directory -# of the caller. -function follow_links() ( - cd -P "$(dirname -- "$1")" - file="$PWD/$(basename -- "$1")" - while [[ -h "$file" ]]; do - cd -P "$(dirname -- "$file")" - file="$(readlink -- "$file")" - cd -P "$(dirname -- "$file")" - file="$PWD/$(basename -- "$file")" - done - echo "$file" -) - -PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")" -BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" -FLUTTER_ROOT="$(cd "${BIN_DIR}/../../.." ; pwd -P)" - -# Allow using a mock git for testing. -if [ -z "$GIT" ]; then - # By default, use git on PATH. - GIT_BIN="git" -else - # Use the provide GIT executable. - GIT_BIN="$GIT" -fi - -# Test for fusion repository -if [ -f "$FLUTTER_ROOT/DEPS" ]; then - ENGINE_VERSION=$($GIT_BIN -C "$FLUTTER_ROOT" merge-base HEAD origin/master) -elif [ -f "$FLUTTER_ROOT/bin/internal/engine.version" ]; then - ENGINE_VERSION=$(cat "$FLUTTER_ROOT/bin/internal/engine.version") -else - >&2 echo "Not a valid FLUTTER_ROOT: $FLUTTER_ROOT" - exit 1 -fi - -echo $ENGINE_VERSION diff --git a/dev/tools/test/engine_hash_test.dart b/dev/tools/test/engine_hash_test.dart deleted file mode 100644 index aa48f4d6c89..00000000000 --- a/dev/tools/test/engine_hash_test.dart +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -@TestOn('posix') -library; - -import 'dart:io' as io; - -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; - -/// Tests that `/dev/tools/bin/engine_hash.sh` _appears_ to work. -void main() { - late final io.File engineHashSh; - - setUpAll(() { - engineHashSh = io.File(p.join(p.current, 'bin', 'engine_hash.sh')); - if (!engineHashSh.existsSync()) { - fail('No engine_hash.sh at "${p.absolute(engineHashSh.path)}".'); - } - }); - - late io.Directory tmpFlutterRoot; - - setUp(() { - tmpFlutterRoot = io.Directory.systemTemp.createTempSync('engine_hash_test.'); - - // Create engine_hash.sh at the same component it would be in the real root. - io.Directory(p.join(tmpFlutterRoot.path, 'dev', 'tools', 'bin')).createSync(recursive: true); - engineHashSh.copySync(p.join(tmpFlutterRoot.path, 'dev', 'tools', 'bin', 'engine_hash.sh')); - - // Create FLUTTER_ROOT/DEPS. - io.File(p.join(tmpFlutterRoot.path, 'DEPS')).createSync(); - }); - - tearDown(() { - tmpFlutterRoot.deleteSync(recursive: true); - }); - - test('omission of FLUTTER_ROOT/DEPS falls back to engine.version', () { - io.File(p.join(tmpFlutterRoot.path, 'bin', 'internal', 'engine.version')) - ..createSync(recursive: true) - ..writeAsStringSync('12345'); - io.File(p.join(tmpFlutterRoot.path, 'DEPS')).deleteSync(); - - final io.ProcessResult result = io.Process.runSync( - p.join(tmpFlutterRoot.path, 'dev', 'tools', 'bin', 'engine_hash.sh'), - [], - ); - expect(result.exitCode, 0, reason: result.stderr.toString()); - expect(result.stdout, '12345\n'); - }); - - test('uses git -C merge-base HEAD origin/master', () { - final io.ProcessResult result = io.Process.runSync( - p.join(tmpFlutterRoot.path, 'dev', 'tools', 'bin', 'engine_hash.sh'), - [], - environment: {'GIT': p.join(p.current, 'test', 'mock_git.sh')}, - ); - expect(result.exitCode, 0, reason: result.stderr.toString()); - expect( - result.stdout, - stringContainsInOrder([ - 'Mock Git: -C', - 'engine_hash_test', - // This needs to be origin/master if the google3 script is running from a fresh checkout. - 'merge-base HEAD origin/master', - ]), - ); - }); -}