Skip to content

Commit

Permalink
Fix tests in Dart dev channel (flutter#64)
Browse files Browse the repository at this point in the history
Fixes #60
  • Loading branch information
tvolkert authored Jan 12, 2017
1 parent 9609e08 commit 47f0655
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions test/common_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ void runCommonTests(

test('throwsIfAlreadyExistsAsFile', () {
fs.file(ns('/foo')).createSync();
expectFileSystemException('File exists', () {
// TODO(tvolkert): Change this to just be 'Not a directory'
// once Dart 1.22 is stable.
RegExp pattern = new RegExp('(File exists|Not a directory)');
expectFileSystemException(pattern, () {
fs.directory(ns('/foo')).createSync();
});
});
Expand All @@ -449,7 +452,10 @@ void runCommonTests(
test('throwsIfAlreadyExistsAsLinkToFile', () {
fs.file(ns('/foo')).createSync();
fs.link(ns('/bar')).createSync(ns('/foo'));
expectFileSystemException('File exists', () {
// TODO(tvolkert): Change this to just be 'Not a directory'
// once Dart 1.22 is stable.
RegExp pattern = new RegExp('(File exists|Not a directory)');
expectFileSystemException(pattern, () {
fs.directory(ns('/bar')).createSync();
});
});
Expand Down Expand Up @@ -2655,7 +2661,10 @@ void runCommonTests(

test('throwsIfPathReferencesDirectoryAndRecursiveFalse', () {
fs.directory(ns('/foo')).createSync();
expectFileSystemException('Invalid argument', () {
// TODO(tvolkert): Change this to just be 'Is a directory'
// once Dart 1.22 is stable.
RegExp pattern = new RegExp('(Invalid argument|Is a directory)');
expectFileSystemException(pattern, () {
fs.link(ns('/foo')).deleteSync();
});
});
Expand Down Expand Up @@ -2817,7 +2826,10 @@ void runCommonTests(

test('throwsIfPathReferencesDirectory', () {
fs.directory(ns('/foo')).createSync();
expectFileSystemException('Invalid argument', () {
// TODO(tvolkert): Change this to just be 'Is a directory'
// once Dart 1.22 is stable.
RegExp pattern = new RegExp('(Invalid argument|Is a directory)');
expectFileSystemException(pattern, () {
fs.link(ns('/foo')).updateSync(ns('/bar'));
});
});
Expand Down Expand Up @@ -3063,16 +3075,16 @@ const Matcher isFileSystemEntity = const _IsFileSystemEntity();

Matcher hasPath(String path) => new _HasPath(equals(path));

Matcher isFileSystemException([String msg]) => new _FileSystemException(msg);
Matcher throwsFileSystemException([String msg]) =>
Matcher isFileSystemException([Pattern msg]) => new _FileSystemException(msg);
Matcher throwsFileSystemException([Pattern msg]) =>
new Throws(isFileSystemException(msg));

void expectFileSystemException(String msg, void callback()) {
void expectFileSystemException(Pattern msg, void callback()) {
expect(callback, throwsFileSystemException(msg));
}

class _FileSystemException extends Matcher {
final String msg;
final Pattern msg;
const _FileSystemException(this.msg);

Description describe(Description description) =>
Expand Down

0 comments on commit 47f0655

Please sign in to comment.