Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: utils/tests/pub/validator_test.dart

Issue 12782005: Revert "Use scheduled_test for Pub tests." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/tests/pub/update/pub_update_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/validator_test.dart
diff --git a/utils/tests/pub/validator_test.dart b/utils/tests/pub/validator_test.dart
index 12dbd8287a7ac325e92421222ceb5ad1ad67a677..fcbb5617206fbee192da5b8262093df9556db9d6 100644
--- a/utils/tests/pub/validator_test.dart
+++ b/utils/tests/pub/validator_test.dart
@@ -12,8 +12,9 @@ import 'dart:math' as math;
import '../../../pkg/http/lib/http.dart' as http;
import '../../../pkg/http/lib/testing.dart';
import '../../../pkg/pathos/lib/path.dart' as path;
-import '../../../pkg/scheduled_test/lib/scheduled_test.dart';
+import '../../../pkg/unittest/lib/unittest.dart';
+import 'test_pub.dart';
import '../../pub/entrypoint.dart';
import '../../pub/io.dart';
import '../../pub/validator.dart';
@@ -26,31 +27,27 @@ import '../../pub/validator/name.dart';
import '../../pub/validator/pubspec_field.dart';
import '../../pub/validator/size.dart';
import '../../pub/validator/utf8_readme.dart';
-import 'descriptor.dart' as d;
-import 'test_pub.dart';
void expectNoValidationError(ValidatorCreator fn) {
- expect(schedulePackageValidation(fn), completion(pairOf(isEmpty, isEmpty)));
+ expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isEmpty));
}
void expectValidationError(ValidatorCreator fn) {
- expect(schedulePackageValidation(fn),
- completion(pairOf(isNot(isEmpty), anything)));
+ expectLater(schedulePackageValidation(fn), pairOf(isNot(isEmpty), anything));
}
void expectValidationWarning(ValidatorCreator fn) {
- expect(schedulePackageValidation(fn),
- completion(pairOf(isEmpty, isNot(isEmpty))));
+ expectLater(schedulePackageValidation(fn), pairOf(isEmpty, isNot(isEmpty)));
}
expectDependencyValidationError(String error) {
- expect(schedulePackageValidation(dependency),
- completion(pairOf(someElement(contains(error)), isEmpty)));
+ expectLater(schedulePackageValidation(dependency),
+ pairOf(someElement(contains(error)), isEmpty));
}
expectDependencyValidationWarning(String warning) {
- expect(schedulePackageValidation(dependency),
- completion(pairOf(isEmpty, someElement(contains(warning)))));
+ expectLater(schedulePackageValidation(dependency),
+ pairOf(isEmpty, someElement(contains(warning))));
}
Validator compiledDartdoc(Entrypoint entrypoint) =>
@@ -79,9 +76,7 @@ Function size(int size) {
Validator utf8Readme(Entrypoint entrypoint) =>
new Utf8ReadmeValidator(entrypoint);
-void scheduleNormalPackage() {
- d.validPackage.create();
-}
+void scheduleNormalPackage() => normalPackage.scheduleCreate();
/// Sets up a test package with dependency [dep] and mocks a server with
/// [hostedVersions] of the package available.
@@ -101,9 +96,9 @@ setUpDependency(Map dep, {List<String> hostedVersions}) {
}
}));
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [dep])
- ]).create();
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [dep])
+ ]).scheduleCreate();
}
main() {
@@ -112,7 +107,7 @@ main() {
setUp(scheduleNormalPackage);
integration('looks normal', () {
- d.dir(appPath, [d.libPubspec("test_pkg", "1.0.0")]).create();
+ dir(appPath, [libPubspec("test_pkg", "1.0.0")]).scheduleCreate();
expectNoValidationError(dependency);
expectNoValidationError(lib);
expectNoValidationError(license);
@@ -121,55 +116,55 @@ main() {
});
integration('has a COPYING file', () {
- schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE')));
- d.file(path.join(appPath, 'COPYING'), '').create();
+ file(path.join(appPath, 'LICENSE'), '').scheduleDelete();
+ file(path.join(appPath, 'COPYING'), '').scheduleCreate();
expectNoValidationError(license);
});
integration('has a prefixed LICENSE file', () {
- schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE')));
- d.file(path.join(appPath, 'MIT_LICENSE'), '').create();
+ file(path.join(appPath, 'LICENSE'), '').scheduleDelete();
+ file(path.join(appPath, 'MIT_LICENSE'), '').scheduleCreate();
expectNoValidationError(license);
});
integration('has a suffixed LICENSE file', () {
- schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE')));
- d.file(path.join(appPath, 'LICENSE.md'), '').create();
+ file(path.join(appPath, 'LICENSE'), '').scheduleDelete();
+ file(path.join(appPath, 'LICENSE.md'), '').scheduleCreate();
expectNoValidationError(license);
});
integration('has "authors" instead of "author"', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["authors"] = [pkg.remove("author")];
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectNoValidationError(pubspecField);
});
integration('has a badly-named library in lib/src', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [
- d.file("test_pkg.dart", "int i = 1;"),
- d.dir("src", [d.file("8ball.dart", "int j = 2;")])
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [
+ file("test_pkg.dart", "int i = 1;"),
+ dir("src", [file("8ball.dart", "int j = 2;")])
])
- ]).create();
+ ]).scheduleCreate();
expectNoValidationError(name);
});
integration('has a non-Dart file in lib', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [
- d.file("thing.txt", "woo hoo")
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [
+ file("thing.txt", "woo hoo")
])
- ]).create();
+ ]).scheduleCreate();
expectNoValidationError(lib);
});
integration('has a nested directory named "tools"', () {
- d.dir(appPath, [
- d.dir("foo", [d.dir("tools")])
- ]).create();
+ dir(appPath, [
+ dir("foo", [dir("tools")])
+ ]).scheduleCreate();
expectNoValidationError(directory);
});
@@ -179,22 +174,22 @@ main() {
});
integration('has most but not all files from compiling dartdoc', () {
- d.dir(appPath, [
- d.dir("doc-out", [
- d.file("nav.json", ""),
- d.file("index.html", ""),
- d.file("styles.css", ""),
- d.file("dart-logo-small.png", "")
+ dir(appPath, [
+ dir("doc-out", [
+ file("nav.json", ""),
+ file("index.html", ""),
+ file("styles.css", ""),
+ file("dart-logo-small.png", "")
])
- ]).create();
+ ]).scheduleCreate();
expectNoValidationError(compiledDartdoc);
});
integration('has a non-primary readme with invalid utf-8', () {
- d.dir(appPath, [
- d.file("README", "Valid utf-8"),
- d.binaryFile("README.invalid", [192])
- ]).create();
+ dir(appPath, [
+ file("README", "Valid utf-8"),
+ binaryFile("README.invalid", [192])
+ ]).scheduleCreate();
expectNoValidationError(utf8Readme);
});
});
@@ -203,161 +198,158 @@ main() {
setUp(scheduleNormalPackage);
integration('is missing the "homepage" field', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("homepage");
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationError(pubspecField);
});
integration('is missing the "description" field', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("description");
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationError(pubspecField);
});
integration('is missing the "author" field', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("author");
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationError(pubspecField);
});
integration('has a single author without an email', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "Nathan Weizenbaum";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationWarning(pubspecField);
});
integration('has one of several authors without an email', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("author");
pkg["authors"] = [
"Bob Nystrom <rnystrom@google.com>",
"Nathan Weizenbaum",
"John Messerly <jmesserly@google.com>"
];
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationWarning(pubspecField);
});
integration('has a single author without a name', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg["author"] = "<nweiz@google.com>";
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationWarning(pubspecField);
});
integration('has one of several authors without a name', () {
- var pkg = packageMap("test_pkg", "1.0.0");
+ var pkg = package("test_pkg", "1.0.0");
pkg.remove("author");
pkg["authors"] = [
"Bob Nystrom <rnystrom@google.com>",
"<nweiz@google.com>",
"John Messerly <jmesserly@google.com>"
];
- d.dir(appPath, [d.pubspec(pkg)]).create();
+ dir(appPath, [pubspec(pkg)]).scheduleCreate();
expectValidationWarning(pubspecField);
});
integration('has no LICENSE file', () {
- schedule(() => deleteFile(path.join(sandboxDir, appPath, 'LICENSE')));
+ file(path.join(appPath, 'LICENSE'), '').scheduleDelete();
expectValidationError(license);
});
integration('has an empty package name', () {
- d.dir(appPath, [d.libPubspec("", "1.0.0")]).create();
+ dir(appPath, [libPubspec("", "1.0.0")]).scheduleCreate();
expectValidationError(name);
});
integration('has a package name with an invalid character', () {
- d.dir(appPath, [d.libPubspec("test-pkg", "1.0.0")]).create();
+ dir(appPath, [libPubspec("test-pkg", "1.0.0")]).scheduleCreate();
expectValidationError(name);
});
integration('has a package name that begins with a number', () {
- d.dir(appPath, [d.libPubspec("8ball", "1.0.0")]).create();
+ dir(appPath, [libPubspec("8ball", "1.0.0")]).scheduleCreate();
expectValidationError(name);
});
integration('has a package name that contains upper-case letters', () {
- d.dir(appPath, [d.libPubspec("TestPkg", "1.0.0")]).create();
+ dir(appPath, [libPubspec("TestPkg", "1.0.0")]).scheduleCreate();
expectValidationWarning(name);
});
integration('has a package name that is a Dart reserved word', () {
- d.dir(appPath, [d.libPubspec("final", "1.0.0")]).create();
+ dir(appPath, [libPubspec("final", "1.0.0")]).scheduleCreate();
expectValidationError(name);
});
integration('has a library name with an invalid character', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [d.file("test-pkg.dart", "int i = 0;")])
- ]).create();
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("test-pkg.dart", "int i = 0;")])
+ ]).scheduleCreate();
expectValidationWarning(name);
});
integration('has a library name that begins with a number', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [d.file("8ball.dart", "int i = 0;")])
- ]).create();
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("8ball.dart", "int i = 0;")])
+ ]).scheduleCreate();
expectValidationWarning(name);
});
integration('has a library name that contains upper-case letters', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [d.file("TestPkg.dart", "int i = 0;")])
- ]).create();
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("TestPkg.dart", "int i = 0;")])
+ ]).scheduleCreate();
expectValidationWarning(name);
});
integration('has a library name that is a Dart reserved word', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0"),
- d.dir("lib", [d.file("for.dart", "int i = 0;")])
- ]).create();
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0"),
+ dir("lib", [file("for.dart", "int i = 0;")])
+ ]).scheduleCreate();
expectValidationWarning(name);
});
integration('has a single library named differently than the package', () {
- schedule(() =>
- deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart")));
- d.dir(appPath, [
- d.dir("lib", [d.file("best_pkg.dart", "int i = 0;")])
- ]).create();
+ file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
+ dir(appPath, [
+ dir("lib", [file("best_pkg.dart", "int i = 0;")])
+ ]).scheduleCreate();
expectValidationWarning(name);
});
integration('has no lib directory', () {
- schedule(() => deleteDir(path.join(sandboxDir, appPath, "lib")));
+ dir(path.join(appPath, "lib")).scheduleDelete();
expectValidationError(lib);
});
integration('has an empty lib directory', () {
- schedule(() =>
- deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart")));
+ file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
expectValidationError(lib);
});
integration('has a lib directory containing only src', () {
- schedule(() =>
- deleteFile(path.join(sandboxDir, appPath, "lib", "test_pkg.dart")));
- d.dir(appPath, [
- d.dir("lib", [
- d.dir("src", [d.file("test_pkg.dart", "int i = 0;")])
+ file(path.join(appPath, "lib", "test_pkg.dart"), '').scheduleDelete();
+ dir(appPath, [
+ dir("lib", [
+ dir("src", [file("test_pkg.dart", "int i = 0;")])
])
- ]).create();
+ ]).scheduleCreate();
expectValidationError(lib);
});
@@ -450,23 +442,23 @@ main() {
group('has an unconstrained dependency', () {
group('and it should not suggest a version', () {
integration("if there's no lockfile", () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [
{'hosted': 'foo'}
])
- ]).create();
+ ]).scheduleCreate();
- expect(schedulePackageValidation(dependency), completion(
- pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
+ expectLater(schedulePackageValidation(dependency),
+ pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))));
});
integration("if the lockfile doesn't have an entry for the "
"dependency", () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [
{'hosted': 'foo'}
]),
- d.file("pubspec.lock", json.stringify({
+ file("pubspec.lock", json.stringify({
'packages': {
'bar': {
'version': '1.2.3',
@@ -478,21 +470,21 @@ main() {
}
}
}))
- ]).create();
+ ]).scheduleCreate();
- expect(schedulePackageValidation(dependency), completion(
- pairOf(isEmpty, everyElement(isNot(contains("\n foo:"))))));
+ expectLater(schedulePackageValidation(dependency),
+ pairOf(isEmpty, everyElement(isNot(contains("\n foo:")))));
});
});
group('with a lockfile', () {
integration('and it should suggest a constraint based on the locked '
'version', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [
{'hosted': 'foo'}
]),
- d.file("pubspec.lock", json.stringify({
+ file("pubspec.lock", json.stringify({
'packages': {
'foo': {
'version': '1.2.3',
@@ -504,18 +496,18 @@ main() {
}
}
}))
- ]).create();
+ ]).scheduleCreate();
expectDependencyValidationWarning(' foo: ">=1.2.3 <2.0.0"');
});
integration('and it should suggest a concrete constraint if the locked '
'version is pre-1.0.0', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [
{'hosted': 'foo'}
]),
- d.file("pubspec.lock", json.stringify({
+ file("pubspec.lock", json.stringify({
'packages': {
'foo': {
'version': '0.1.2',
@@ -527,7 +519,7 @@ main() {
}
}
}))
- ]).create();
+ ]).scheduleCreate();
expectDependencyValidationWarning(' foo: ">=0.1.2 <0.1.3"');
});
@@ -535,11 +527,11 @@ main() {
});
integration('has a hosted dependency on itself', () {
- d.dir(appPath, [
- d.libPubspec("test_pkg", "1.0.0", deps: [
+ dir(appPath, [
+ libPubspec("test_pkg", "1.0.0", deps: [
{'hosted': {'name': 'test_pkg', 'version': '>=1.0.0'}}
])
- ]).create();
+ ]).scheduleCreate();
expectValidationWarning(dependency);
});
@@ -550,7 +542,7 @@ main() {
var names = ["tools", "tests", "docs", "examples", "sample", "samples"];
for (var name in names) {
integration('"$name"', () {
- d.dir(appPath, [d.dir(name)]).create();
+ dir(appPath, [dir(name)]).scheduleCreate();
expectValidationWarning(directory);
});
}
@@ -561,23 +553,23 @@ main() {
});
integration('contains compiled dartdoc', () {
- d.dir(appPath, [
- d.dir('doc-out', [
- d.file('nav.json', ''),
- d.file('index.html', ''),
- d.file('styles.css', ''),
- d.file('dart-logo-small.png', ''),
- d.file('client-live-nav.js', '')
+ dir(appPath, [
+ dir('doc-out', [
+ file('nav.json', ''),
+ file('index.html', ''),
+ file('styles.css', ''),
+ file('dart-logo-small.png', ''),
+ file('client-live-nav.js', '')
])
- ]).create();
+ ]).scheduleCreate();
expectValidationWarning(compiledDartdoc);
});
integration('has a README with invalid utf-8', () {
- d.dir(appPath, [
- d.binaryFile("README", [192])
- ]).create();
+ dir(appPath, [
+ binaryFile("README", [192])
+ ]).scheduleCreate();
expectValidationWarning(utf8Readme);
});
});
« no previous file with comments | « utils/tests/pub/update/pub_update_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698