[flutter_tools] do not try to build tool from dart.sh (#129186)
Fixes https://github.com/flutter/flutter/issues/121894
This commit is contained in:
parent
1c8c53360d
commit
b0bc023f24
@ -130,6 +130,7 @@ GOTO :after_subroutine
|
|||||||
IF EXIST "%FLUTTER_ROOT%\version" DEL "%FLUTTER_ROOT%\version"
|
IF EXIST "%FLUTTER_ROOT%\version" DEL "%FLUTTER_ROOT%\version"
|
||||||
IF EXIST "%FLUTTER_ROOT%\bin\cache\flutter.version.json" DEL "%FLUTTER_ROOT%\bin\cache\flutter.version.json"
|
IF EXIST "%FLUTTER_ROOT%\bin\cache\flutter.version.json" DEL "%FLUTTER_ROOT%\bin\cache\flutter.version.json"
|
||||||
ECHO: > "%cache_dir%\.dartignore"
|
ECHO: > "%cache_dir%\.dartignore"
|
||||||
|
|
||||||
ECHO Building flutter tool... 1>&2
|
ECHO Building flutter tool... 1>&2
|
||||||
PUSHD "%flutter_tools_dir%"
|
PUSHD "%flutter_tools_dir%"
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------- NOTE ---------------------------------- #
|
# ---------------------------------- NOTE ---------------------------------- #
|
||||||
#
|
#
|
||||||
# Please keep the logic in this file consistent with the logic in the
|
# Please keep the logic in this file consistent with the logic in the
|
||||||
@ -144,6 +143,11 @@ function upgrade_flutter () (
|
|||||||
touch "$FLUTTER_ROOT/bin/cache/.dartignore"
|
touch "$FLUTTER_ROOT/bin/cache/.dartignore"
|
||||||
"$FLUTTER_ROOT/bin/internal/update_dart_sdk.sh"
|
"$FLUTTER_ROOT/bin/internal/update_dart_sdk.sh"
|
||||||
|
|
||||||
|
if [[ "$BIN_NAME" == 'dart' ]]; then
|
||||||
|
# Don't try to build tool
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
>&2 echo Building flutter tool...
|
>&2 echo Building flutter tool...
|
||||||
|
|
||||||
# Prepare packages...
|
# Prepare packages...
|
||||||
@ -229,6 +233,8 @@ function shared::execute() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BIN_NAME="$(basename "$PROG_NAME")"
|
||||||
|
|
||||||
# File descriptor 7 is prepared here so that we can use it with
|
# File descriptor 7 is prepared here so that we can use it with
|
||||||
# flock(1) in _lock() (see above).
|
# flock(1) in _lock() (see above).
|
||||||
#
|
#
|
||||||
@ -247,7 +253,6 @@ function shared::execute() {
|
|||||||
# SHARED_NAME itself is prepared by the caller script.
|
# SHARED_NAME itself is prepared by the caller script.
|
||||||
upgrade_flutter 7< "$SHARED_NAME"
|
upgrade_flutter 7< "$SHARED_NAME"
|
||||||
|
|
||||||
BIN_NAME="$(basename "$PROG_NAME")"
|
|
||||||
case "$BIN_NAME" in
|
case "$BIN_NAME" in
|
||||||
flutter*)
|
flutter*)
|
||||||
# FLUTTER_TOOL_ARGS aren't quoted below, because it is meant to be
|
# FLUTTER_TOOL_ARGS aren't quoted below, because it is meant to be
|
||||||
|
@ -48,6 +48,64 @@ Future<void> main() async {
|
|||||||
expect(stdout, contains('Successfully received SIGTERM!'));
|
expect(stdout, contains('Successfully received SIGTERM!'));
|
||||||
},
|
},
|
||||||
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
|
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
|
||||||
|
|
||||||
|
test('shared.sh does not compile flutter tool if PROG_NAME=dart', () async {
|
||||||
|
final Directory tempDir = fileSystem.systemTempDirectory.createTempSync('bash_entrypoint_test');
|
||||||
|
try {
|
||||||
|
// bash script checks it is in a git repo
|
||||||
|
ProcessResult result = await processManager.run(<String>['git', 'init'], workingDirectory: tempDir.path);
|
||||||
|
expect(result, const ProcessResultMatcher());
|
||||||
|
result = await processManager.run(<String>['git', 'commit', '--allow-empty', '-m', 'init commit'], workingDirectory: tempDir.path);
|
||||||
|
expect(result, const ProcessResultMatcher());
|
||||||
|
|
||||||
|
// copy dart and shared.sh to temp dir
|
||||||
|
final File trueSharedSh = flutterRoot.childDirectory('bin').childDirectory('internal').childFile('shared.sh');
|
||||||
|
final File fakeSharedSh = (tempDir.childDirectory('bin').childDirectory('internal')
|
||||||
|
..createSync(recursive: true))
|
||||||
|
.childFile('shared.sh');
|
||||||
|
trueSharedSh.copySync(fakeSharedSh.path);
|
||||||
|
final File fakeDartBash = tempDir.childDirectory('bin').childFile('dart');
|
||||||
|
dartBash.copySync(fakeDartBash.path);
|
||||||
|
// mark dart executable
|
||||||
|
makeExecutable(fakeDartBash);
|
||||||
|
|
||||||
|
// create no-op fake update_dart_sdk.sh script
|
||||||
|
final File updateDartSdk = tempDir.childDirectory('bin').childDirectory('internal').childFile('update_dart_sdk.sh')..writeAsStringSync('''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo downloaded dart sdk
|
||||||
|
''');
|
||||||
|
makeExecutable(updateDartSdk);
|
||||||
|
|
||||||
|
// create a fake dart runtime
|
||||||
|
final File dartBin = (tempDir.childDirectory('bin')
|
||||||
|
.childDirectory('cache')
|
||||||
|
.childDirectory('dart-sdk')
|
||||||
|
.childDirectory('bin')
|
||||||
|
..createSync(recursive: true))
|
||||||
|
.childFile('dart');
|
||||||
|
dartBin.writeAsStringSync('''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo executed dart binary
|
||||||
|
''');
|
||||||
|
makeExecutable(dartBin);
|
||||||
|
|
||||||
|
result = await processManager.run(<String>[fakeDartBash.path]);
|
||||||
|
expect(result, const ProcessResultMatcher());
|
||||||
|
expect(
|
||||||
|
(result.stdout as String).split('\n'),
|
||||||
|
// verify we ran updateDartSdk and dartBin
|
||||||
|
containsAll(<String>['downloaded dart sdk', 'executed dart binary']),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify we did not try to compile the flutter_tool
|
||||||
|
expect(result.stderr, isNot(contains('Building flutter tool...')));
|
||||||
|
} finally {
|
||||||
|
tryToDelete(tempDir);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
skip: platform.isWindows); // [intended] Windows does not use the bash entrypoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// A test Dart app that will run until it receives SIGTERM
|
// A test Dart app that will run until it receives SIGTERM
|
||||||
@ -69,3 +127,8 @@ File get dartBash {
|
|||||||
.childFile('dart')
|
.childFile('dart')
|
||||||
.absolute;
|
.absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeExecutable(File file) {
|
||||||
|
final ProcessResult result = processManager.runSync(<String>['chmod', '+x', file.path]);
|
||||||
|
expect(result, const ProcessResultMatcher());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user