Fix pkg/glob tests on Windows.
R=rnystrom@google.com
BUG=21071
Review URL: https://codereview.chromium.org//598103003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40644 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2500c62..5747978 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,5 @@
## 1.0.0+1
* Fix several analyzer warnings.
+
+* Fix the tests on Windows.
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 40ac5a6..35526c0 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -65,6 +65,6 @@
///
/// This is useful when converting from Windows paths to globs.
String separatorToForwardSlash(String path) {
- if (p.context != p.Style.windows) return path;
+ if (p.style != p.Style.windows) return path;
return path.replaceAll('\\', '/');
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 0a2254c..1365f27 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: glob
-version: 1.0.1-dev
+version: 1.0.1
author: "Dart Team <misc@dartlang.org>"
homepage: http://www.dartlang.org
description: Bash-style filename globbing.
diff --git a/test/list_test.dart b/test/list_test.dart
index 676d6f0..59c5841 100644
--- a/test/list_test.dart
+++ b/test/list_test.dart
@@ -55,7 +55,8 @@
syncAndAsync((list) {
group("literals", () {
test("lists a single literal", () {
- expect(list("foo/baz/qux"), completion(equals(["foo/baz/qux"])));
+ expect(list("foo/baz/qux"),
+ completion(equals([p.join("foo", "baz", "qux")])));
});
test("lists a non-matching literal", () {
@@ -65,33 +66,45 @@
group("star", () {
test("lists within filenames but not across directories", () {
- expect(list("foo/b*"),
- completion(unorderedEquals(["foo/bar", "foo/baz"])));
+ expect(list("foo/b*"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz")
+ ])));
});
test("lists the empy string", () {
- expect(list("foo/bar*"), completion(equals(["foo/bar"])));
+ expect(list("foo/bar*"), completion(equals([p.join("foo", "bar")])));
});
});
group("double star", () {
test("lists within filenames", () {
- expect(list("foo/baz/**"),
- completion(unorderedEquals(["foo/baz/qux", "foo/baz/bang"])));
+ expect(list("foo/baz/**"), completion(unorderedEquals([
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ])));
});
test("lists the empty string", () {
- expect(list("foo/bar**"), completion(equals(["foo/bar"])));
+ expect(list("foo/bar**"), completion(equals([p.join("foo", "bar")])));
});
test("lists recursively", () {
- expect(list("foo/**"), completion(unorderedEquals(
- ["foo/bar", "foo/baz", "foo/baz/qux", "foo/baz/bang"])));
+ expect(list("foo/**"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ])));
});
test("combines with literals", () {
- expect(list("foo/ba**"), completion(unorderedEquals(
- ["foo/bar", "foo/baz", "foo/baz/qux", "foo/baz/bang"])));
+ expect(list("foo/ba**"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ])));
});
test("lists recursively in the middle of a glob", () {
@@ -107,15 +120,19 @@
])
]).create();
- expect(list("deep/**/?/?"),
- completion(unorderedEquals(["deep/a/b/c", "deep/a/b/c/d"])));
+ expect(list("deep/**/?/?"), completion(unorderedEquals([
+ p.join("deep", "a", "b", "c"),
+ p.join("deep", "a", "b", "c", "d")
+ ])));
});
});
group("any char", () {
test("matches a character", () {
- expect(list("foo/ba?"),
- completion(unorderedEquals(["foo/bar", "foo/baz"])));
+ expect(list("foo/ba?"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz")
+ ])));
});
test("doesn't match a separator", () {
@@ -125,23 +142,27 @@
group("range", () {
test("matches a range of characters", () {
- expect(list("foo/ba[a-z]"),
- completion(unorderedEquals(["foo/bar", "foo/baz"])));
+ expect(list("foo/ba[a-z]"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz")
+ ])));
});
test("matches a specific list of characters", () {
- expect(list("foo/ba[rz]"),
- completion(unorderedEquals(["foo/bar", "foo/baz"])));
+ expect(list("foo/ba[rz]"), completion(unorderedEquals([
+ p.join("foo", "bar"),
+ p.join("foo", "baz")
+ ])));
});
test("doesn't match outside its range", () {
expect(list("foo/ba[a-x]"),
- completion(unorderedEquals(["foo/bar"])));
+ completion(unorderedEquals([p.join("foo", "bar")])));
});
test("doesn't match outside its specific list", () {
expect(list("foo/ba[rx]"),
- completion(unorderedEquals(["foo/bar"])));
+ completion(unorderedEquals([p.join("foo", "bar")])));
});
});
@@ -152,7 +173,7 @@
]).create();
expect(list("multi/{start-*/f*,*-end/*e}"),
- completion(equals(["multi/start-end/file"])));
+ completion(equals([p.join("multi", "start-end", "file")])));
});
test("the same file shouldn't be recursively listed multiple times", () {
@@ -173,7 +194,9 @@
]).create();
expect(list("multi/{*/*/*/file,a/**/file}"), completion(unorderedEquals([
- "multi/a/b/file", "multi/a/b/c/file", "multi/a/x/y/file"
+ p.join("multi", "a", "b", "file"),
+ p.join("multi", "a", "b", "c", "file"),
+ p.join("multi", "a", "x", "y", "file")
])));
});
@@ -187,13 +210,15 @@
test("follows symlinks by default", () {
expect(list("dir/**"), completion(unorderedEquals([
- "dir/link", "dir/link/bang", "dir/link/qux"
+ p.join("dir", "link"),
+ p.join("dir", "link", "bang"),
+ p.join("dir", "link", "qux")
])));
});
test("doesn't follow symlinks with followLinks: false", () {
expect(list("dir/**", followLinks: false),
- completion(equals(["dir/link"])));
+ completion(equals([p.join("dir", "link")])));
});
test("shouldn't crash on broken symlinks", () {
@@ -201,13 +226,18 @@
return new Directory(p.join(sandbox, "foo")).delete(recursive: true);
});
- expect(list("dir/**"), completion(equals(["dir/link"])));
+ expect(list("dir/**"), completion(equals([p.join("dir", "link")])));
});
});
test("always lists recursively with recursive: true", () {
- expect(list("foo", recursive: true), completion(unorderedEquals(
- ["foo", "foo/bar", "foo/baz", "foo/baz/qux", "foo/baz/bang"])));
+ expect(list("foo", recursive: true), completion(unorderedEquals([
+ "foo",
+ p.join("foo", "bar"),
+ p.join("foo", "baz"),
+ p.join("foo", "baz", "qux"),
+ p.join("foo", "baz", "bang")
+ ])));
});
test("lists an absolute glob", () {
@@ -216,7 +246,10 @@
p.absolute(p.join(sandbox, 'foo/baz/**')));
return list(pattern);
- }), completion(unorderedEquals(["foo/baz/bang", "foo/baz/qux"])));
+ }), completion(unorderedEquals([
+ p.join("foo", "baz", "bang"),
+ p.join("foo", "baz", "qux")
+ ])));
});
});
}