Ignore errno values on Windows tests (#55)
This allows us to run some tests rather than skipping them, which
in turn allows us to focus on the more egregious test failures.
diff --git a/lib/src/testing/core_matchers.dart b/lib/src/testing/core_matchers.dart
index 502afd1..6ca3388 100644
--- a/lib/src/testing/core_matchers.dart
+++ b/lib/src/testing/core_matchers.dart
@@ -5,6 +5,8 @@
import 'package:file/file.dart';
import 'package:test/test.dart';
+import 'internal.dart';
+
/// Matcher that successfully matches against any instance of [Directory].
const Matcher isDirectory = const isInstanceOf<Directory>();
@@ -70,7 +72,14 @@
final Matcher _matcher;
_FileSystemException(dynamic osErrorCode)
- : _matcher = osErrorCode == null ? null : wrapMatcher(osErrorCode);
+ : _matcher = _wrapMatcher(osErrorCode);
+
+ static Matcher _wrapMatcher(dynamic osErrorCode) {
+ if (osErrorCode == null) {
+ return null;
+ }
+ return ignoreOsErrorCodes ? anything : wrapMatcher(osErrorCode);
+ }
@override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
diff --git a/lib/src/testing/internal.dart b/lib/src/testing/internal.dart
new file mode 100644
index 0000000..d0cf002
--- /dev/null
+++ b/lib/src/testing/internal.dart
@@ -0,0 +1,9 @@
+// Copyright (c) 2017, 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.
+
+import 'package:meta/meta.dart';
+
+/// True if we should ignore OS error codes in our matchers.
+@visibleForTesting
+bool ignoreOsErrorCodes = false;
diff --git a/test/local_test.dart b/test/local_test.dart
index 2b39b66..b8b854c 100644
--- a/test/local_test.dart
+++ b/test/local_test.dart
@@ -6,6 +6,7 @@
import 'dart:io' as io;
import 'package:file/local.dart';
+import 'package:file/src/testing/internal.dart';
import 'package:test/test.dart';
import 'common_tests.dart';
@@ -29,89 +30,50 @@
tmp.deleteSync(recursive: true);
});
+ setUpAll(() {
+ if (io.Platform.isWindows) {
+ // TODO(tvolkert): Remove once all more serious test failures are fixed
+ // https://github.com/google/file.dart/issues/56
+ ignoreOsErrorCodes = true;
+ }
+ });
+
+ tearDownAll(() {
+ ignoreOsErrorCodes = false;
+ });
+
Map<String, List<String>> skipOnPlatform = <String, List<String>>{
'windows': <String>[
'FileSystem > currentDirectory > throwsIfHasNonExistentPathInComplexChain',
'FileSystem > currentDirectory > staysAtRootIfSetToParentOfRoot',
- 'FileSystem > currentDirectory > throwsIfSetToFilePathSegmentAtTail',
- 'FileSystem > currentDirectory > throwsIfSetToFilePathSegmentViaTraversal',
'FileSystem > currentDirectory > resolvesLinksIfEncountered',
'FileSystem > currentDirectory > succeedsIfSetToDirectoryLinkAtTail',
- 'FileSystem > currentDirectory > throwsIfSetToLinkLoop',
'FileSystem > stat > isFileForLinkToFile',
'FileSystem > type > isFileForLinkToFileAndFollowLinksTrue',
'FileSystem > type > isNotFoundForLinkWithCircularReferenceAndFollowLinksTrue',
'Directory > uri',
'Directory > exists > falseIfExistsAsLinkToFile',
'Directory > exists > falseIfNotFoundSegmentExistsThenIsBackedOut',
- 'Directory > create > throwsIfAlreadyExistsAsFile',
'Directory > create > throwsIfAlreadyExistsAsLinkToFile',
- 'Directory > create > throwsIfAlreadyExistsAsLinkToNotFoundViaTraversal',
- 'Directory > create > throwsIfAncestorDoesntExistRecursiveFalse',
- 'Directory > rename > throwsIfDestinationIsFile',
- 'Directory > rename > throwsIfDestinationParentFolderDoesntExist',
'Directory > rename > throwsIfDestinationIsNonEmptyDirectory',
- 'Directory > rename > throwsIfSourceIsFile',
- 'Directory > rename > throwsIfDestinationIsLinkToNotFound',
'Directory > rename > throwsIfDestinationIsLinkToEmptyDirectory',
- 'Directory > delete > throwsIfNonEmptyDirectoryExistsAndRecursiveFalse',
- 'Directory > delete > throwsIfPathReferencesFileAndRecursiveFalse',
'Directory > delete > throwsIfPathReferencesLinkToFileAndRecursiveFalse',
- 'Directory > delete > throwsIfPathReferencesLinkToNotFoundAndRecursiveFalse',
- 'Directory > resolveSymbolicLinks > throwsIfLoopInLinkChain',
- 'Directory > resolveSymbolicLinks > throwsIfPathNotFoundInTraversal',
'Directory > resolveSymbolicLinks > throwsIfPathNotFoundInMiddleThenBackedOut',
- 'Directory > createTemp > throwsIfDirectoryDoesntExist',
'Directory > createTemp > succeedsWithNestedPathPrefixThatExists',
- 'Directory > createTemp > throwsWithNestedPathPrefixThatDoesntExist',
- 'Directory > list > throwsIfDirectoryDoesntExist',
'Directory > list > followsLinksIfFollowLinksTrue',
'Directory > list > returnsLinkObjectsForRecursiveLinkIfFollowLinksTrue',
'File > uri',
- 'File > create > throwsIfAncestorDoesntExistRecursiveFalse',
'File > create > succeedsIfAlreadyExistsAsLinkToFile',
'File > create > succeedsIfAlreadyExistsAsLinkToNotFoundAtTail',
- 'File > create > throwsIfAlreadyExistsAsLinkToNotFoundViaTraversal',
'File > create > succeedsIfAlreadyExistsAsLinkToNotFoundInDifferentDirectory',
- 'File > rename > throwsIfDestinationDoesntExistViaTraversal',
- 'File > rename > throwsIfDestinationExistsAsDirectory',
'File > rename > succeedsIfDestinationExistsAsLinkToFile',
'File > rename > succeedsIfDestinationExistsAsLinkToNotFound',
- 'File > rename > throwsIfSourceExistsAsDirectory',
'File > rename > succeedsIfSourceExistsAsLinkToFile',
- 'File > rename > throwsIfSourceExistsAsLinkToDirectory',
- 'File > copy > throwsIfDestinationDoesntExistViaTraversal',
- 'File > copy > throwsIfDestinationExistsAsDirectory',
'File > copy > succeedsIfDestinationExistsAsLinkToFile',
- 'File > copy > throwsIfDestinationExistsAsLinkToDirectory',
- 'File > copy > throwsIfSourceExistsAsDirectory',
'File > copy > succeedsIfSourceExistsAsLinkToFile',
'File > copy > succeedsIfSourceIsLinkToFileInDifferentDirectory',
'File > copy > succeedsIfDestinationIsLinkToFileInDifferentDirectory',
- 'File > open > READ > throwsIfDoesntExistViaTraversal',
- 'File > open > READ > RandomAccessFile > throwsIfWriteByte',
- 'File > open > READ > RandomAccessFile > throwsIfWriteFrom',
- 'File > open > READ > RandomAccessFile > throwsIfWriteString',
- 'File > open > READ > RandomAccessFile > position > throwsIfSetToNegativeNumber',
- 'File > open > READ > RandomAccessFile > throwsIfTruncate',
- 'File > open > WRITE > throwsIfDoesntExistViaTraversal',
- 'File > open > WRITE > RandomAccessFile > position > throwsIfSetToNegativeNumber',
- 'File > open > APPEND > throwsIfDoesntExistViaTraversal',
- 'File > open > APPEND > RandomAccessFile > position > throwsIfSetToNegativeNumber',
- 'File > open > WRITE_ONLY > throwsIfDoesntExistViaTraversal',
- 'File > open > WRITE_ONLY > RandomAccessFile > throwsIfReadByte',
- 'File > open > WRITE_ONLY > RandomAccessFile > throwsIfRead',
- 'File > open > WRITE_ONLY > RandomAccessFile > throwsIfReadInto',
- 'File > open > WRITE_ONLY > RandomAccessFile > position > throwsIfSetToNegativeNumber',
- 'File > open > WRITE_ONLY_APPEND > throwsIfDoesntExistViaTraversal',
- 'File > open > WRITE_ONLY_APPEND > RandomAccessFile > throwsIfReadByte',
- 'File > open > WRITE_ONLY_APPEND > RandomAccessFile > throwsIfRead',
- 'File > open > WRITE_ONLY_APPEND > RandomAccessFile > throwsIfReadInto',
- 'File > open > WRITE_ONLY_APPEND > RandomAccessFile > position > throwsIfSetToNegativeNumber',
- 'File > openRead > throwsIfExistsAsDirectory',
'File > openRead > succeedsIfExistsAsLinkToFile',
- 'File > openWrite > throwsIfExistsAsDirectory',
- 'File > openWrite > throwsIfExistsAsLinkToDirectory',
'File > openWrite > succeedsIfExistsAsLinkToFile',
'File > openWrite > ioSink > throwsIfEncodingIsNullAndWriteObject',
'File > openWrite > ioSink > allowsChangingEncoding',
@@ -127,48 +89,19 @@
'File > openWrite > ioSink > addStream > blocksCallToWriteCharCodeWhileStreamIsActive',
'File > openWrite > ioSink > addStream > blocksCallToWritelnWhileStreamIsActive',
'File > openWrite > ioSink > addStream > blocksCallToFlushWhileStreamIsActive',
- 'File > readAsBytes > throwsIfExistsAsDirectory',
- 'File > readAsBytes > throwsIfExistsAsLinkToDirectory',
'File > readAsBytes > succeedsIfExistsAsLinkToFile',
- 'File > readAsString > throwsIfExistsAsDirectory',
- 'File > readAsString > throwsIfExistsAsLinkToDirectory',
'File > readAsString > succeedsIfExistsAsLinkToFile',
- 'File > readAsLines > throwsIfExistsAsDirectory',
- 'File > readAsLines > throwsIfExistsAsLinkToDirectory',
- 'File > writeAsBytes > throwsIfExistsAsDirectory',
- 'File > writeAsBytes > throwsIfExistsAsLinkToDirectory',
'File > writeAsBytes > succeedsIfExistsAsLinkToFile',
- 'File > writeAsBytes > throwsIfFileModeRead',
- 'File > writeAsString > throwsIfExistsAsDirectory',
- 'File > writeAsString > throwsIfExistsAsLinkToDirectory',
'File > writeAsString > succeedsIfExistsAsLinkToFile',
- 'File > writeAsString > throwsIfFileModeRead',
'File > stat > isFileIfExistsAsLinkToFile',
- 'File > delete > throwsIfExistsAsDirectoryAndRecursiveFalse',
'File > delete > succeedsIfExistsAsLinkToFileAndRecursiveFalse',
- 'File > delete > throwsIfExistsAsLinkToDirectoryAndRecursiveFalse',
'Link > uri > whenTargetIsDirectory',
'Link > uri > whenTargetIsFile',
'Link > uri > whenLinkDoesntExist',
'Link > stat > isFileIfTargetIsFile',
'Link > stat > isDirectoryIfTargetIsDirectory',
- 'Link > delete > throwsIfPathReferencesFileAndRecursiveFalse',
- 'Link > delete > throwsIfPathReferencesDirectoryAndRecursiveFalse',
- 'Link > create > throwsIfLinkDoesntExistViaTraversalAndRecursiveFalse',
'Link > create > succeedsIfLinkDoesntExistViaTraversalAndRecursiveTrue',
- 'Link > create > throwsIfAlreadyExistsAsFile',
- 'Link > create > throwsIfAlreadyExistsAsDirectory',
- 'Link > create > throwsIfAlreadyExistsWithSameTarget',
- 'Link > create > throwsIfAlreadyExistsWithDifferentTarget',
- 'Link > update > throwsIfPathReferencesFile',
- 'Link > update > throwsIfPathReferencesDirectory',
- 'Link > target > throwsIfLinkDoesntExistViaTraversal',
- 'Link > target > throwsIfPathReferencesFile',
- 'Link > target > throwsIfPathReferencesDirectory',
'Link > rename > returnsCovariantType',
- 'Link > rename > throwsIfSourceIsFile',
- 'Link > rename > throwsIfSourceIsDirectory',
- 'Link > rename > throwsIfDestinationDoesntExistViaTraversal',
'Link > rename > succeedsIfDestinationExistsAsLinkToFile',
'Link > rename > throwsIfDestinationExistsAsLinkToDirectory',
'Link > rename > succeedsIfDestinationExistsAsLinkToNotFound',