mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 15:01:29 +00:00
b75f8aaaf5
Thrown by when an operation fails because a file is not found. TEST=updated unit tests Issue: https://github.com/dart-lang/sdk/issues/12461 Change-Id: I2e6e3986f92d5bf9f3922f4e2c6bbba67cc102bc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267280 Reviewed-by: Lasse Nielsen <lrn@google.com> Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Brian Quinlan <bquinlan@google.com>
54 lines
1.8 KiB
Dart
54 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 that tests listSync on a missing directory.
|
|
//
|
|
// TODO(7157): Merge this test into directory_test.dart testListNonExistent()
|
|
// when it no longer crashes on Windows, when issue 7157 is resolved.
|
|
|
|
import "dart:io";
|
|
|
|
import "package:async_helper/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
|
|
void testListNonExistent() {
|
|
asyncStart();
|
|
Directory.systemTemp.createTemp('dart_directory_list_nonexistent').then((d) {
|
|
d.delete().then((ignore) {
|
|
Expect.throws(() => d.listSync(), (e) => e is PathNotFoundException);
|
|
Expect.throws(
|
|
() => d.listSync(recursive: true), (e) => e is PathNotFoundException);
|
|
asyncEnd();
|
|
});
|
|
});
|
|
}
|
|
|
|
void testListTooLongName() {
|
|
asyncStart();
|
|
Directory.systemTemp.createTemp('dart_directory_list_nonexistent').then((d) {
|
|
var subDirName = 'subdir';
|
|
var subDir = new Directory("${d.path}/$subDirName");
|
|
subDir.create().then((ignore) {
|
|
// Construct a long string of the form
|
|
// 'tempdir/subdir/../subdir/../subdir'.
|
|
var buffer = new StringBuffer();
|
|
buffer.write(subDir.path);
|
|
for (var i = 0; i < 1000; i++) {
|
|
buffer.write("/../${subDirName}");
|
|
}
|
|
var long = new Directory("${buffer.toString()}");
|
|
Expect.throws(() => long.listSync(), (e) => e is FileSystemException);
|
|
Expect.throws(() => long.listSync(recursive: true),
|
|
(e) => e is FileSystemException);
|
|
d.deleteSync(recursive: true);
|
|
asyncEnd();
|
|
});
|
|
});
|
|
}
|
|
|
|
void main() {
|
|
testListNonExistent();
|
|
testListTooLongName();
|
|
}
|