diff --git a/bin/dart.bat b/bin/dart.bat index c4b71d2923..96f8599b93 100644 --- a/bin/dart.bat +++ b/bin/dart.bat @@ -11,6 +11,8 @@ REM work across all platforms! REM REM -------------------------------------------------------------------------- +SETLOCAL ENABLEDELAYEDEXPANSION + FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi REM Include shared scripts in shared.bat diff --git a/bin/flutter.bat b/bin/flutter.bat index f80321d9d5..7c3ba962d6 100644 --- a/bin/flutter.bat +++ b/bin/flutter.bat @@ -11,6 +11,8 @@ REM work across all platforms! REM REM -------------------------------------------------------------------------- +SETLOCAL ENABLEDELAYEDEXPANSION + FOR %%i IN ("%~dp0..") DO SET FLUTTER_ROOT=%%~fi REM If available, add location of bundled mingit to PATH diff --git a/packages/flutter_tools/test/integration.shard/exit_code_test.dart b/packages/flutter_tools/test/integration.shard/exit_code_test.dart new file mode 100644 index 0000000000..891326bbec --- /dev/null +++ b/packages/flutter_tools/test/integration.shard/exit_code_test.dart @@ -0,0 +1,62 @@ +// 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. + +// @dart = 2.8 + +import 'package:file/file.dart'; +import 'package:flutter_tools/src/base/io.dart'; + +import '../src/common.dart'; +import 'test_utils.dart'; + +void main() { + final String dartBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'dart'); + Directory tempDir; + + setUp(() { + tempDir = createResolvedTempDirectorySync('exit_code_test.'); + }); + + tearDown(() { + tryToDelete(tempDir); + }); + + testWithoutContext('dart.sh/bat can return a zero exit code', () async { + tempDir.childFile('main.dart') + .writeAsStringSync(''' +import 'dart:io'; +void main() { + exit(0); +} +'''); + + final ProcessResult result = await processManager.run([ + dartBin, + fileSystem.path.join(tempDir.path, 'main.dart'), + ]); + + print(result.stdout); + print(result.stderr); + expect(result.exitCode, 0); + }); + + testWithoutContext('dart.sh/bat can return a non-zero exit code', () async { + tempDir.childFile('main.dart') + .writeAsStringSync(''' +import 'dart:io'; +void main() { + exit(1); +} +'''); + + final ProcessResult result = await processManager.run([ + dartBin, + fileSystem.path.join(tempDir.path, 'main.dart'), + ]); + + print(result.stdout); + print(result.stderr); + expect(result.exitCode, 1); + }); +} diff --git a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart index 447eeab042..1dd18fe614 100644 --- a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart +++ b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart @@ -33,7 +33,7 @@ import 'package:pedantic/pedantic.dart'; import 'package:process/process.dart'; import '../src/common.dart'; -import 'test_utils.dart' show fileSystem; +import 'test_utils.dart' show fileSystem, platform; const ProcessManager processManager = LocalProcessManager(); final String flutterRoot = getFlutterRoot(); @@ -315,7 +315,7 @@ void main() { } finally { tryToDelete(fileSystem.directory(tempDirectory)); } - }); + }, skip: platform.isWindows); testWithoutContext('flutter run handle SIGUSR1/2', () async { final String tempDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_overall_experience_test.').resolveSymbolicLinksSync(); @@ -591,5 +591,5 @@ void main() { '', 'Application finished.', ]); - }); + }, skip: Platform.isWindows); // TODO(jonahwilliams): Re-enable when this test is reliable on device lab, https://github.com/flutter/flutter/issues/81556 } diff --git a/packages/flutter_tools/test/integration.shard/variable_expansion_windows_test.dart b/packages/flutter_tools/test/integration.shard/variable_expansion_windows_test.dart index 192a9adf37..cf5d90c405 100644 --- a/packages/flutter_tools/test/integration.shard/variable_expansion_windows_test.dart +++ b/packages/flutter_tools/test/integration.shard/variable_expansion_windows_test.dart @@ -17,5 +17,5 @@ void main() { '"^(?!Golden).+"', ]); expect(result.stdout, contains('args: ["(?!Golden).+"]')); - }, skip: !platform.isWindows); + }, skip: 'Reverted in https://github.com/flutter/flutter/pull/86000'); }