@@ -435,7 +435,10 @@ void runCommonTests(
435
435
436
436
test ('throwsIfAlreadyExistsAsFile' , () {
437
437
fs.file (ns ('/foo' )).createSync ();
438
- expectFileSystemException ('File exists' , () {
438
+ // TODO(tvolkert): Change this to just be 'Not a directory'
439
+ // once Dart 1.22 is stable.
440
+ RegExp pattern = new RegExp ('(File exists|Not a directory)' );
441
+ expectFileSystemException (pattern, () {
439
442
fs.directory (ns ('/foo' )).createSync ();
440
443
});
441
444
});
@@ -449,7 +452,10 @@ void runCommonTests(
449
452
test ('throwsIfAlreadyExistsAsLinkToFile' , () {
450
453
fs.file (ns ('/foo' )).createSync ();
451
454
fs.link (ns ('/bar' )).createSync (ns ('/foo' ));
452
- expectFileSystemException ('File exists' , () {
455
+ // TODO(tvolkert): Change this to just be 'Not a directory'
456
+ // once Dart 1.22 is stable.
457
+ RegExp pattern = new RegExp ('(File exists|Not a directory)' );
458
+ expectFileSystemException (pattern, () {
453
459
fs.directory (ns ('/bar' )).createSync ();
454
460
});
455
461
});
@@ -2655,7 +2661,10 @@ void runCommonTests(
2655
2661
2656
2662
test ('throwsIfPathReferencesDirectoryAndRecursiveFalse' , () {
2657
2663
fs.directory (ns ('/foo' )).createSync ();
2658
- expectFileSystemException ('Invalid argument' , () {
2664
+ // TODO(tvolkert): Change this to just be 'Is a directory'
2665
+ // once Dart 1.22 is stable.
2666
+ RegExp pattern = new RegExp ('(Invalid argument|Is a directory)' );
2667
+ expectFileSystemException (pattern, () {
2659
2668
fs.link (ns ('/foo' )).deleteSync ();
2660
2669
});
2661
2670
});
@@ -2817,7 +2826,10 @@ void runCommonTests(
2817
2826
2818
2827
test ('throwsIfPathReferencesDirectory' , () {
2819
2828
fs.directory (ns ('/foo' )).createSync ();
2820
- expectFileSystemException ('Invalid argument' , () {
2829
+ // TODO(tvolkert): Change this to just be 'Is a directory'
2830
+ // once Dart 1.22 is stable.
2831
+ RegExp pattern = new RegExp ('(Invalid argument|Is a directory)' );
2832
+ expectFileSystemException (pattern, () {
2821
2833
fs.link (ns ('/foo' )).updateSync (ns ('/bar' ));
2822
2834
});
2823
2835
});
@@ -3063,16 +3075,16 @@ const Matcher isFileSystemEntity = const _IsFileSystemEntity();
3063
3075
3064
3076
Matcher hasPath (String path) => new _HasPath (equals (path));
3065
3077
3066
- Matcher isFileSystemException ([String msg]) => new _FileSystemException (msg);
3067
- Matcher throwsFileSystemException ([String msg]) =>
3078
+ Matcher isFileSystemException ([Pattern msg]) => new _FileSystemException (msg);
3079
+ Matcher throwsFileSystemException ([Pattern msg]) =>
3068
3080
new Throws (isFileSystemException (msg));
3069
3081
3070
- void expectFileSystemException (String msg, void callback ()) {
3082
+ void expectFileSystemException (Pattern msg, void callback ()) {
3071
3083
expect (callback, throwsFileSystemException (msg));
3072
3084
}
3073
3085
3074
3086
class _FileSystemException extends Matcher {
3075
- final String msg;
3087
+ final Pattern msg;
3076
3088
const _FileSystemException (this .msg);
3077
3089
3078
3090
Description describe (Description description) =>
0 commit comments