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

Unified Diff: sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart

Issue 657673002: Regenerate pub sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
Index: sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart
diff --git a/sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart b/sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart
index b5ea7cb4a6260b6e2de9c4412c76364a5e185328..fada25db129cfbb7e4c0d3db5de36d19ef316530 100644
--- a/sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart
+++ b/sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart
@@ -1,9 +1,16 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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.
+
library pub_tests;
+
import 'package:scheduled_test/scheduled_stream.dart';
import 'package:scheduled_test/scheduled_test.dart';
+
import '../descriptor.dart' as d;
import '../test_pub.dart';
import '../serve/utils.dart';
+
const REPLACE_FROM_LIBRARY_TRANSFORMER = """
import 'dart:async';
@@ -24,9 +31,14 @@ class ReplaceTransformer extends Transformer {
}
}
""";
+
+// TODO(nweiz): Currently scheduled_test.setUp doesn't play well with test_pub,
+// since it only assigns the sandbox directory once the main test body has
+// run. Fix this and move this to a real setUp call.
void setUp() {
servePackages((builder) {
builder.serveRepoPackage('barback');
+
builder.serve("foo", "1.2.3", deps: {
'barback': 'any'
},
@@ -34,6 +46,7 @@ void setUp() {
d.dir(
"lib",
[d.file("transformer.dart", replaceTransformer("Hello", "Goodbye"))])]);
+
builder.serve("bar", "1.2.3", deps: {
'barback': 'any'
},
@@ -41,8 +54,10 @@ void setUp() {
d.dir(
"lib",
[d.file("transformer.dart", replaceTransformer("Goodbye", "See ya"))])]);
+
builder.serve("baz", "1.2.3");
});
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -52,15 +67,20 @@ void setUp() {
"transformers": ["foo"]
}),
d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).create();
+
pubGet();
}
+
main() {
initConfig();
+
integration("caches a transformer snapshot", () {
setUp();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -69,23 +89,30 @@ main() {
[
d.file("manifest.txt", "0.1.2+3\nfoo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
+
+ // Run the executable again to make sure loading the transformer from the
+ // cache works.
process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
});
+
integration("recaches if the SDK version is out-of-date", () {
setUp();
+
d.dir(
appPath,
[
d.dir(
".pub/transformers",
- [
- d.file("manifest.txt", "0.0.1\nfoo"),
- d.file("transformers.snapshot", "junk")])]).create();
+ [// The version 0.0.1 is different than the test version 0.1.2+3.
+ d.file("manifest.txt", "0.0.1\nfoo"),
+ d.file("transformers.snapshot", "junk")])]).create();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -95,11 +122,14 @@ main() {
d.file("manifest.txt", "0.1.2+3\nfoo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
});
+
integration("recaches if the transformers change", () {
setUp();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -108,6 +138,7 @@ main() {
[
d.file("manifest.txt", "0.1.2+3\nfoo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -117,9 +148,11 @@ main() {
"transformers": ["foo", "bar"]
}),
d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).create();
+
process = pubRun(args: ['myapp']);
process.stdout.expect("See ya!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -129,11 +162,14 @@ main() {
d.file("manifest.txt", "0.1.2+3\nbar,foo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
});
+
integration("recaches if the transformer version changes", () {
setUp();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -142,6 +178,7 @@ main() {
[
d.file("manifest.txt", "0.1.2+3\nfoo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
+
servePackages((builder) {
builder.serve("foo", "2.0.0", deps: {
'barback': 'any'
@@ -151,6 +188,7 @@ main() {
"lib",
[d.file("transformer.dart", replaceTransformer("Hello", "New"))])]);
});
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -158,10 +196,13 @@ main() {
},
"transformers": ["foo"]
})]).create();
+
pubUpgrade();
+
process = pubRun(args: ['myapp']);
process.stdout.expect("New!");
process.shouldExit();
+
d.dir(
appPath,
[
@@ -171,21 +212,25 @@ main() {
d.file("manifest.txt", "0.1.2+3\nfoo"),
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
});
+
integration("recaches if a transitive dependency version changes", () {
servePackages((builder) {
builder.serveRepoPackage('barback');
+
builder.serve("foo", "1.2.3", deps: {
'barback': 'any',
'bar': 'any'
},
contents: [
d.dir("lib", [d.file("transformer.dart", REPLACE_FROM_LIBRARY_TRANSFORMER)])]);
+
builder.serve(
"bar",
"1.2.3",
contents: [
d.dir("lib", [d.file("bar.dart", "final replacement = 'Goodbye';")])]);
});
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -194,10 +239,13 @@ main() {
"transformers": ["foo"]
}),
d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).create();
+
pubGet();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("Goodbye!");
process.shouldExit();
+
servePackages((builder) {
builder.serve(
"bar",
@@ -205,6 +253,7 @@ main() {
contents: [
d.dir("lib", [d.file("bar.dart", "final replacement = 'See ya';")])]);
});
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -212,13 +261,18 @@ main() {
},
"transformers": ["foo"]
})]).create();
+
pubUpgrade();
+
process = pubRun(args: ['myapp']);
process.stdout.expect("See ya!");
process.shouldExit();
});
+
+ // Issue 21298.
integration("doesn't recache when a transformer is removed", () {
setUp();
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
@@ -228,23 +282,31 @@ main() {
"transformers": ["foo", "bar"]
}),
d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).create();
+
var process = pubRun(args: ['myapp']);
process.stdout.expect("See ya!");
process.shouldExit();
+
d.dir(appPath, [d.pubspec({
"name": "myapp",
"dependencies": {
"foo": "1.2.3",
+ // Add a new dependency to trigger another "pub get". This works
+ // around issue 20498.
"baz": "1.2.3"
},
"transformers": ["foo"]
}),
d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).create();
+
process = pubRun(args: ['myapp']);
process.stdout.expect(
"Your pubspec has changed, so we need to update your lockfile:");
process.stdout.expect(consumeThrough("Goodbye!"));
process.shouldExit();
+
+ // "bar" should still be in the manifest, since there's no reason to
+ // recompile the cache.
d.dir(
appPath,
[
@@ -255,6 +317,7 @@ main() {
d.matcherFile("transformers.snapshot", isNot(isEmpty))])]).validate();
});
}
+
String replaceTransformer(String input, String output) {
return """
import 'dart:async';

Powered by Google App Engine
This is Rietveld 408576698