Files
sdk/tests/standalone_2/io/directory_chdir_test.dart
T
Alexander Markov a211134136 [Tests] Update _2 tests for Dart 2.0 fixed-size integers
Also, --limit-ints-to-64-bits is enabled when running tests in _2 test
suites.

This is the re-landing of 92ebd8aefa with
fixes:

* Revert changes in pkg/dev_compiler/test/browser/language_tests.js
  and tests/language/language_dart2js.status as they describe
  'language' test suite, not 'language_2'

* Correct tests/standalone_2/io/fuzz_support.dart as file_fuzz test was
  timing out on Windows and failing on android/arm.

Closes https://github.com/dart-lang/sdk/issues/31396

Change-Id: If9ca77fca300ddc605f17a7be39d1707e9724e25
Reviewed-on: https://dart-review.googlesource.com/21700
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2017-11-17 20:28:06 +00:00

53 lines
1.8 KiB
Dart

// Copyright (c) 2013, 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.
//
// Directory listing test.
import "dart:io";
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
testChangeDirectory() {
asyncStart();
Directory.systemTemp.createTemp('dart_directory_chdir').then((temp) {
var initialCurrent = Directory.current;
Directory.current = temp;
var newCurrent = Directory.current;
new File("111").createSync();
var dir = new Directory(newCurrent.path + Platform.pathSeparator + "222");
dir.createSync();
Directory.current = dir;
new File("333").createSync();
Expect.isTrue(new File("333").existsSync());
Expect.isTrue(new File("../111").existsSync());
Directory.current = "..";
Expect.isTrue(new File("111").existsSync());
Expect.isTrue(new File("222/333").existsSync());
// Deleting the current working directory causes an error.
// On Windows, the deletion fails, and on non-Windows, the getter fails.
Expect.throws(() {
temp.deleteSync(recursive: true);
Directory.current;
}, (e) => e is FileSystemException);
Directory.current = initialCurrent;
Directory.current;
if (temp.existsSync()) temp.deleteSync(recursive: true);
asyncEnd();
});
}
testChangeDirectoryIllegalArguments() {
Expect.throwsArgumentError(() => Directory.current = 1);
Expect.throwsArgumentError(() => Directory.current = 9223372036854775807);
Expect.throwsArgumentError(() => Directory.current = true);
Expect.throwsArgumentError(() => Directory.current = []);
Expect.throwsArgumentError(() => Directory.current = new File("xxx"));
}
main() {
testChangeDirectory();
testChangeDirectoryIllegalArguments();
}