dart-sdk/tests/standalone/io/windows_environment_test.dart
Alexander Markov fc317794dd [test] Fix standalone/io/windows_environment_test for NNBD
This test launches Dart sub-process and should pass VM options like
--enable-experiment=non-nullable and --sound-null-safety, otherwise
sub-process will try to run migrated Dart code without appropriate
flags.

Also, fix NNBD compile-time error in
tests/standalone/io/windows_environment_script.dart

Change-Id: I5bc0bf4ba32a3933c236c1a2f04cea3d7a1fa31a
Fixed: 1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167722
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-10-15 18:32:40 +00:00

34 lines
1.2 KiB
Dart

// Copyright (c) 2012, 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.
// OtherResources=windows_environment_script.dart
import 'package:path/path.dart';
import 'package:expect/expect.dart';
import "dart:io";
main() {
if (Platform.operatingSystem != 'windows') return;
var tempDir = Directory.systemTemp.createTempSync('dart_windows_environment');
var funkyDir = new Directory(join(tempDir.path, 'å'));
funkyDir.createSync();
var funkyFile = new File(join(funkyDir.path, 'funky.bat'));
final vmOptions = Platform.executableArguments.join(' ');
funkyFile.writeAsStringSync("""
@echo off
set SCRIPTDIR=%~dp0
echo %1 $vmOptions %2
%1 $vmOptions %2
""");
var dart = Platform.executable;
var script =
Platform.script.resolve('windows_environment_script.dart').toFilePath();
Process.run('cmd', ['/c', funkyFile.path, dart, script]).then((p) {
print('stdout: ${p.stdout}');
print('stderr: ${p.stderr}');
if (0 != p.exitCode) throw "Exit code not 0";
tempDir.deleteSync(recursive: true);
});
}