From b4f6d09998ae2d6681c939b665d8bbe004e2e5fc Mon Sep 17 00:00:00 2001
From: Natalie Weizenbaum <nweiz@google.com>
Date: Thu, 6 Aug 2015 15:49:18 -0700
Subject: [PATCH] Fix a bunch of pub tests that started running "pub get".

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//1281623002 .
---
 .../all_includes_all_default_directories_test.dart     |  2 +-
 test/barback/directory_args_test.dart                  |  2 +-
 test/barback/subdirectories_test.dart                  |  2 +-
 .../converts_isolate_entrypoint_in_web_test.dart       |  2 +-
 test/dart2js/does_not_compile_if_disabled_test.dart    |  2 +-
 ...not_compile_until_its_output_is_requested_test.dart |  2 +-
 ...support_invalid_command_line_options_type_test.dart |  2 +-
 ...does_not_support_invalid_environment_type_test.dart |  2 +-
 ...t_support_invalid_type_for_boolean_option_test.dart |  2 +-
 test/dart2js/environment_constant_test.dart            |  4 ++--
 test/dart2js/ignores_entrypoints_in_lib_test.dart      |  2 +-
 .../ignores_non_entrypoint_dart_files_test.dart        |  2 +-
 test/dart2js/minifies_in_release_mode_test.dart        |  2 +-
 .../minify_configuration_overrides_mode_test.dart      |  2 +-
 .../output_can_be_consumed_by_successive_phases.dart   |  2 +-
 .../passes_along_environment_constants_test.dart       |  2 +-
 test/dart2js/reports_dart_parse_errors_test.dart       |  1 +
 ...ce_maps_include_core_libs_in_subdirectory_test.dart |  2 +-
 test/dart2js/supports_valid_options_test.dart          |  2 +-
 test/dart2js/unminified_in_nonrelease_mode_test.dart   |  2 +-
 .../activate/activate_path_after_hosted_test.dart      | 10 +++++++---
 test/global/activate/path_package_test.dart            |  3 ++-
 test/serve/404_page_test.dart                          |  4 ++--
 test/serve/does_not_serve_hidden_assets_test.dart      |  2 +-
 test/serve/does_not_watch_compiled_js_files_test.dart  |  2 +-
 test/serve/invalid_method_test.dart                    |  2 +-
 test/serve/missing_asset_test.dart                     |  2 +-
 test/serve/missing_file_test.dart                      |  2 +-
 test/serve/native_watch_added_file_test.dart           |  2 +-
 test/serve/native_watch_modified_file_test.dart        |  2 +-
 test/serve/native_watch_removed_file_test.dart         |  2 +-
 test/serve/serve_from_app_lib_test.dart                |  2 +-
 test/serve/serve_from_app_web_test.dart                |  2 +-
 test/serve/serves_file_with_space_test.dart            |  2 +-
 test/serve/serves_index_html_for_directories_test.dart |  2 +-
 .../serves_web_and_test_dirs_by_default_test.dart      |  2 +-
 test/serve/supports_cross_origin_header_test.dart      |  2 +-
 test/serve/unknown_dependency_test.dart                |  2 +-
 test/serve/uses_appropriate_mime_types_test.dart       |  2 +-
 test/serve/watch_added_file_test.dart                  |  2 +-
 test/serve/watch_modified_file_test.dart               |  2 +-
 test/serve/watch_removed_file_test.dart                |  2 +-
 test/serve/web_socket/exit_on_close_test.dart          |  2 +-
 test/serve/web_socket/path_to_urls_with_line_test.dart |  2 +-
 .../serve_directory_already_served_test.dart           |  2 +-
 ...e_directory_and_immediately_request_asset_test.dart |  2 +-
 ...rve_directory_and_immediately_serve_again_test.dart |  2 +-
 .../serve_directory_and_immediately_unserve_test.dart  |  2 +-
 .../web_socket/serve_directory_arg_errors_test.dart    |  6 +++---
 .../web_socket/serve_directory_overlapping_test.dart   |  2 +-
 test/serve/web_socket/serve_directory_test.dart        |  2 +-
 .../web_socket/unserve_directory_arg_errors_test.dart  |  6 +++---
 .../web_socket/unserve_directory_not_served_test.dart  |  2 +-
 test/serve/web_socket/unserve_directory_test.dart      |  2 +-
 test/serve/web_socket/url_to_asset_id_errors_test.dart |  4 ++--
 .../web_socket/url_to_asset_id_with_line_test.dart     |  2 +-
 56 files changed, 70 insertions(+), 64 deletions(-)

diff --git a/test/barback/all_includes_all_default_directories_test.dart b/test/barback/all_includes_all_default_directories_test.dart
index 9e96e541..1cc0c0a6 100644
--- a/test/barback/all_includes_all_default_directories_test.dart
+++ b/test/barback/all_includes_all_default_directories_test.dart
@@ -49,7 +49,7 @@ main() {
   });
 
   integration("serve --all finds assets in default source directories", () {
-    pubServe(args: ["--all"]);
+    pubServe(args: ["--all"], shouldGetFirst: true);
 
     requestShouldSucceed("file.txt", "benchmark", root: "benchmark");
     requestShouldSucceed("file.txt", "bin", root: "bin");
diff --git a/test/barback/directory_args_test.dart b/test/barback/directory_args_test.dart
index 4a0c12d6..64e8b866 100644
--- a/test/barback/directory_args_test.dart
+++ b/test/barback/directory_args_test.dart
@@ -38,7 +38,7 @@ main() {
   });
 
   integration("serves only the given directories", () {
-    pubServe(args: ["foo", "bar"]);
+    pubServe(args: ["foo", "bar"], shouldGetFirst: true);
 
     requestShouldSucceed("file.txt", "bar", root: "bar");
     requestShouldSucceed("file.txt", "foo", root: "foo");
diff --git a/test/barback/subdirectories_test.dart b/test/barback/subdirectories_test.dart
index 5a74f387..f08d9a12 100644
--- a/test/barback/subdirectories_test.dart
+++ b/test/barback/subdirectories_test.dart
@@ -50,7 +50,7 @@ main() {
   });
 
   integration("serves subdirectories", () {
-    pubServe(args: [webOne, webTwoInner]);
+    pubServe(args: [webOne, webTwoInner], shouldGetFirst: true);
 
     requestShouldSucceed("inner/file.txt", "one", root: webOne);
     requestShouldSucceed("file.txt", "two", root: webTwoInner);
diff --git a/test/dart2js/converts_isolate_entrypoint_in_web_test.dart b/test/dart2js/converts_isolate_entrypoint_in_web_test.dart
index 4dcc2565..90e8c5e3 100644
--- a/test/dart2js/converts_isolate_entrypoint_in_web_test.dart
+++ b/test/dart2js/converts_isolate_entrypoint_in_web_test.dart
@@ -22,7 +22,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("isolate.dart.js", contains("hello"));
     endPubServe();
   });
diff --git a/test/dart2js/does_not_compile_if_disabled_test.dart b/test/dart2js/does_not_compile_if_disabled_test.dart
index 5e4af90a..3c8872c1 100644
--- a/test/dart2js/does_not_compile_if_disabled_test.dart
+++ b/test/dart2js/does_not_compile_if_disabled_test.dart
@@ -15,7 +15,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--no-dart2js"]);
+    pubServe(args: ["--no-dart2js"], shouldGetFirst: true);
     requestShould404("main.dart.js");
     endPubServe();
   });
diff --git a/test/dart2js/does_not_compile_until_its_output_is_requested_test.dart b/test/dart2js/does_not_compile_until_its_output_is_requested_test.dart
index 314c861b..448f3c2f 100644
--- a/test/dart2js/does_not_compile_until_its_output_is_requested_test.dart
+++ b/test/dart2js/does_not_compile_until_its_output_is_requested_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    var server = pubServe();
+    var server = pubServe(shouldGetFirst: true);
     server.stdout.expect("Build completed successfully");
 
     // Once we request the output, it should start compiling and fail.
diff --git a/test/dart2js/does_not_support_invalid_command_line_options_type_test.dart b/test/dart2js/does_not_support_invalid_command_line_options_type_test.dart
index 6a00ff8b..f3cc5465 100644
--- a/test/dart2js/does_not_support_invalid_command_line_options_type_test.dart
+++ b/test/dart2js/does_not_support_invalid_command_line_options_type_test.dart
@@ -20,7 +20,7 @@ main() {
       d.dir("web", [d.file("main.dart", "void main() {}")])
     ]).create();
 
-    var server = pubServe();
+    var server = pubServe(shouldGetFirst: true);
     // Make a request first to trigger compilation.
     requestShould404("main.dart.js");
     server.stderr.expect(emitsLines(
diff --git a/test/dart2js/does_not_support_invalid_environment_type_test.dart b/test/dart2js/does_not_support_invalid_environment_type_test.dart
index 43140afa..6fffe7e2 100644
--- a/test/dart2js/does_not_support_invalid_environment_type_test.dart
+++ b/test/dart2js/does_not_support_invalid_environment_type_test.dart
@@ -20,7 +20,7 @@ main() {
       d.dir("web", [d.file("main.dart", "void main() {}")])
     ]).create();
 
-    var server = pubServe();
+    var server = pubServe(shouldGetFirst: true);
     // Make a request first to trigger compilation.
     requestShould404("main.dart.js");
     server.stderr.expect(emitsLines(
diff --git a/test/dart2js/doesnt_support_invalid_type_for_boolean_option_test.dart b/test/dart2js/doesnt_support_invalid_type_for_boolean_option_test.dart
index e259d178..91e43fc0 100644
--- a/test/dart2js/doesnt_support_invalid_type_for_boolean_option_test.dart
+++ b/test/dart2js/doesnt_support_invalid_type_for_boolean_option_test.dart
@@ -20,7 +20,7 @@ main() {
       d.dir("web", [d.file("main.dart", "void main() {}")])
     ]).create();
 
-    var server = pubServe();
+    var server = pubServe(shouldGetFirst: true);
     requestShould404("main.dart.js");
     server.stderr.expect(emitsLines(
         'Build error:\n'
diff --git a/test/dart2js/environment_constant_test.dart b/test/dart2js/environment_constant_test.dart
index 1128105a..11716065 100644
--- a/test/dart2js/environment_constant_test.dart
+++ b/test/dart2js/environment_constant_test.dart
@@ -38,7 +38,7 @@ main() {
     });
 
     integration('from "pub serve"', () {
-      pubServe(args: ["--define", "name=fblthp"]);
+      pubServe(args: ["--define", "name=fblthp"], shouldGetFirst: true);
       requestShouldSucceed("file.dart.js", contains("fblthp"));
       endPubServe();
     });
@@ -53,7 +53,7 @@ main() {
         })
       ]).create();
 
-      pubServe(args: ["--define", "name=fblthp"]);
+      pubServe(args: ["--define", "name=fblthp"], shouldGetFirst: true);
       requestShouldSucceed("file.dart.js", allOf([
         contains("fblthp"),
         isNot(contains("slartibartfast"))
diff --git a/test/dart2js/ignores_entrypoints_in_lib_test.dart b/test/dart2js/ignores_entrypoints_in_lib_test.dart
index 5feba3a9..2aaed36c 100644
--- a/test/dart2js/ignores_entrypoints_in_lib_test.dart
+++ b/test/dart2js/ignores_entrypoints_in_lib_test.dart
@@ -33,7 +33,7 @@ main() {
   });
 
   integration("serve ignores Dart entrypoints in lib", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShould404("packages/myapp/main.dart.js");
     endPubServe();
   });
diff --git a/test/dart2js/ignores_non_entrypoint_dart_files_test.dart b/test/dart2js/ignores_non_entrypoint_dart_files_test.dart
index 8c639e59..00fa7615 100644
--- a/test/dart2js/ignores_non_entrypoint_dart_files_test.dart
+++ b/test/dart2js/ignores_non_entrypoint_dart_files_test.dart
@@ -33,7 +33,7 @@ main() {
   });
 
   integration("serve ignores non-entrypoint Dart files", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShould404("file1.dart.js");
     requestShould404("file2.dart.js");
     requestShould404("file3.dart.js");
diff --git a/test/dart2js/minifies_in_release_mode_test.dart b/test/dart2js/minifies_in_release_mode_test.dart
index 48621407..5369e27a 100644
--- a/test/dart2js/minifies_in_release_mode_test.dart
+++ b/test/dart2js/minifies_in_release_mode_test.dart
@@ -15,7 +15,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--mode", "release"]);
+    pubServe(args: ["--mode", "release"], shouldGetFirst: true);
     requestShouldSucceed("main.dart.js", isMinifiedDart2JSOutput);
     endPubServe();
   });
diff --git a/test/dart2js/minify_configuration_overrides_mode_test.dart b/test/dart2js/minify_configuration_overrides_mode_test.dart
index 3bc93611..de895103 100644
--- a/test/dart2js/minify_configuration_overrides_mode_test.dart
+++ b/test/dart2js/minify_configuration_overrides_mode_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("main.dart.js", isMinifiedDart2JSOutput);
     endPubServe();
   });
diff --git a/test/dart2js/output_can_be_consumed_by_successive_phases.dart b/test/dart2js/output_can_be_consumed_by_successive_phases.dart
index 374e8454..cdc5cf53 100644
--- a/test/dart2js/output_can_be_consumed_by_successive_phases.dart
+++ b/test/dart2js/output_can_be_consumed_by_successive_phases.dart
@@ -42,7 +42,7 @@ main() {
 
       createLockFile('myapp', pkg: ['barback']);
 
-      pubServe();
+      pubServe(shouldGetFirst: true);
       requestShouldSucceed("main.dart.out", isUnminifiedDart2JSOutput);
       endPubServe();
     });
diff --git a/test/dart2js/passes_along_environment_constants_test.dart b/test/dart2js/passes_along_environment_constants_test.dart
index e56ce5a7..68c69539 100644
--- a/test/dart2js/passes_along_environment_constants_test.dart
+++ b/test/dart2js/passes_along_environment_constants_test.dart
@@ -28,7 +28,7 @@ void main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("main.dart.js", contains("hello"));
     endPubServe();
   });
diff --git a/test/dart2js/reports_dart_parse_errors_test.dart b/test/dart2js/reports_dart_parse_errors_test.dart
index 120f3afa..be076fb0 100644
--- a/test/dart2js/reports_dart_parse_errors_test.dart
+++ b/test/dart2js/reports_dart_parse_errors_test.dart
@@ -27,6 +27,7 @@ main() {
       ])
     ]).create();
 
+    pubGet();
     var pub = startPub(args: ["build"]);
     pub.stdout.expect(startsWith("Loading source assets..."));
     pub.stdout.expect(startsWith("Building myapp..."));
diff --git a/test/dart2js/source_maps_include_core_libs_in_subdirectory_test.dart b/test/dart2js/source_maps_include_core_libs_in_subdirectory_test.dart
index f6a12675..94bbe8f0 100644
--- a/test/dart2js/source_maps_include_core_libs_in_subdirectory_test.dart
+++ b/test/dart2js/source_maps_include_core_libs_in_subdirectory_test.dart
@@ -26,7 +26,7 @@ main() {
     ]).create();
 
     var webSub = path.join("web", "sub");
-    pubServe(args: [webSub]);
+    pubServe(args: [webSub], shouldGetFirst: true);
 
     requestShouldSucceed("main.dart.js.map",
         contains(r"packages/$sdk/lib/core/duration.dart"),
diff --git a/test/dart2js/supports_valid_options_test.dart b/test/dart2js/supports_valid_options_test.dart
index 17fb66d3..ec02f4dd 100644
--- a/test/dart2js/supports_valid_options_test.dart
+++ b/test/dart2js/supports_valid_options_test.dart
@@ -35,7 +35,7 @@ main() {
     ]).create();
 
     // None of these options should be rejected, either by pub or by dart2js.
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("main.dart.js", isNot(isEmpty));
     endPubServe();
   });
diff --git a/test/dart2js/unminified_in_nonrelease_mode_test.dart b/test/dart2js/unminified_in_nonrelease_mode_test.dart
index 831ad6d8..ef8187c9 100644
--- a/test/dart2js/unminified_in_nonrelease_mode_test.dart
+++ b/test/dart2js/unminified_in_nonrelease_mode_test.dart
@@ -15,7 +15,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--mode", "whatever"]);
+    pubServe(args: ["--mode", "whatever"], shouldGetFirst: true);
     requestShouldSucceed("main.dart.js", isUnminifiedDart2JSOutput);
     endPubServe();
   });
diff --git a/test/global/activate/activate_path_after_hosted_test.dart b/test/global/activate/activate_path_after_hosted_test.dart
index 1f379109..318e45b2 100644
--- a/test/global/activate/activate_path_after_hosted_test.dart
+++ b/test/global/activate/activate_path_after_hosted_test.dart
@@ -4,6 +4,7 @@
 
 import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:scheduled_test/scheduled_test.dart';
 
 import '../../descriptor.dart' as d;
 import '../../test_pub.dart';
@@ -28,9 +29,12 @@ main() {
     schedulePub(args: ["global", "activate", "foo"]);
 
     var path = canonicalize(p.join(sandboxDir, "foo"));
-    schedulePub(args: ["global", "activate", "-spath", "../foo"], output: """
-        Package foo is currently active at version 1.0.0.
-        Activated foo 2.0.0 at path "$path".""");
+    schedulePub(
+        args: ["global", "activate", "-spath", "../foo"],
+        output: allOf([
+          contains("Package foo is currently active at version 1.0.0."),
+          contains('Activated foo 2.0.0 at path "$path".')
+        ]));
 
     // Should now run the path one.
     var pub = pubRun(global: true, args: ["foo"]);
diff --git a/test/global/activate/path_package_test.dart b/test/global/activate/path_package_test.dart
index 83c8dc77..37bfc1b2 100644
--- a/test/global/activate/path_package_test.dart
+++ b/test/global/activate/path_package_test.dart
@@ -4,6 +4,7 @@
 
 import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:scheduled_test/scheduled_test.dart';
 
 import '../../descriptor.dart' as d;
 import '../../test_pub.dart';
@@ -19,6 +20,6 @@ main() {
 
     var path = canonicalize(p.join(sandboxDir, "foo"));
     schedulePub(args: ["global", "activate", "--source", "path", "../foo"],
-        output: 'Activated foo 1.0.0 at path "$path".');
+        output: endsWith('Activated foo 1.0.0 at path "$path".'));
   });
 }
diff --git a/test/serve/404_page_test.dart b/test/serve/404_page_test.dart
index fe5fcc9f..3b478bcc 100644
--- a/test/serve/404_page_test.dart
+++ b/test/serve/404_page_test.dart
@@ -18,7 +18,7 @@ main() {
   });
 
   integration("the 404 page describes the missing asset", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     scheduleRequest("packages/foo/missing.txt").then((response) {
       expect(response.statusCode, equals(404));
@@ -32,7 +32,7 @@ main() {
   });
 
   integration("the 404 page describes the error", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     scheduleRequest("packages").then((response) {
       expect(response.statusCode, equals(404));
diff --git a/test/serve/does_not_serve_hidden_assets_test.dart b/test/serve/does_not_serve_hidden_assets_test.dart
index ab7404f4..6cab6b74 100644
--- a/test/serve/does_not_serve_hidden_assets_test.dart
+++ b/test/serve/does_not_serve_hidden_assets_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShould404(".outer.txt");
     requestShould404(".dir/inner.txt");
     endPubServe();
diff --git a/test/serve/does_not_watch_compiled_js_files_test.dart b/test/serve/does_not_watch_compiled_js_files_test.dart
index 94be8202..0a5e70d6 100644
--- a/test/serve/does_not_watch_compiled_js_files_test.dart
+++ b/test/serve/does_not_watch_compiled_js_files_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     waitForBuildSuccess();
     requestShouldSucceed("index.html", "body");
 
diff --git a/test/serve/invalid_method_test.dart b/test/serve/invalid_method_test.dart
index 95a8eafc..f384c973 100644
--- a/test/serve/invalid_method_test.dart
+++ b/test/serve/invalid_method_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     postShould405("index.html");
     endPubServe();
diff --git a/test/serve/missing_asset_test.dart b/test/serve/missing_asset_test.dart
index 42753b60..30a54c18 100644
--- a/test/serve/missing_asset_test.dart
+++ b/test/serve/missing_asset_test.dart
@@ -14,7 +14,7 @@ main() {
       d.appPubspec()
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShould404("index.html");
     requestShould404("packages/myapp/nope.dart");
     requestShould404("dir/packages/myapp/nope.dart");
diff --git a/test/serve/missing_file_test.dart b/test/serve/missing_file_test.dart
index 1596dff5..2cd36b50 100644
--- a/test/serve/missing_file_test.dart
+++ b/test/serve/missing_file_test.dart
@@ -26,7 +26,7 @@ main() {
 
     // Start the server with the files present so that it creates barback
     // assets for them.
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     // Now delete them.
     schedule(() {
diff --git a/test/serve/native_watch_added_file_test.dart b/test/serve/native_watch_added_file_test.dart
index 641917f4..a2a4ad94 100644
--- a/test/serve/native_watch_added_file_test.dart
+++ b/test/serve/native_watch_added_file_test.dart
@@ -21,7 +21,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--no-force-poll"]);
+    pubServe(args: ["--no-force-poll"], shouldGetFirst: true);
     waitForBuildSuccess();
     requestShouldSucceed("index.html", "body");
 
diff --git a/test/serve/native_watch_modified_file_test.dart b/test/serve/native_watch_modified_file_test.dart
index 9e3dbd0a..0eb1f288 100644
--- a/test/serve/native_watch_modified_file_test.dart
+++ b/test/serve/native_watch_modified_file_test.dart
@@ -21,7 +21,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--no-force-poll"]);
+    pubServe(args: ["--no-force-poll"], shouldGetFirst: true);
     requestShouldSucceed("index.html", "before");
 
     d.dir(appPath, [
diff --git a/test/serve/native_watch_removed_file_test.dart b/test/serve/native_watch_removed_file_test.dart
index 17295675..35dd02a8 100644
--- a/test/serve/native_watch_removed_file_test.dart
+++ b/test/serve/native_watch_removed_file_test.dart
@@ -25,7 +25,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["--no-force-poll"]);
+    pubServe(args: ["--no-force-poll"], shouldGetFirst: true);
     requestShouldSucceed("index.html", "body");
 
     schedule(() => deleteEntry(
diff --git a/test/serve/serve_from_app_lib_test.dart b/test/serve/serve_from_app_lib_test.dart
index 89b65ca4..68abeaa7 100644
--- a/test/serve/serve_from_app_lib_test.dart
+++ b/test/serve/serve_from_app_lib_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("packages/myapp/lib.dart", "foo() => 'foo';");
     requestShouldSucceed("packages/myapp/sub/lib.dart", "bar() => 'bar';");
 
diff --git a/test/serve/serve_from_app_web_test.dart b/test/serve/serve_from_app_web_test.dart
index 96363d97..6c09a779 100644
--- a/test/serve/serve_from_app_web_test.dart
+++ b/test/serve/serve_from_app_web_test.dart
@@ -22,7 +22,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("index.html", "<body>");
     requestShouldSucceed("file.dart", "main() => print('hello');");
     requestShouldSucceed("sub/file.html", "<body>in subdir</body>");
diff --git a/test/serve/serves_file_with_space_test.dart b/test/serve/serves_file_with_space_test.dart
index b65ce8a3..abc4e04a 100644
--- a/test/serve/serves_file_with_space_test.dart
+++ b/test/serve/serves_file_with_space_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("foo%20bar.txt", "outer contents");
     requestShouldSucceed("sub%20dir/inner.txt", "inner contents");
     endPubServe();
diff --git a/test/serve/serves_index_html_for_directories_test.dart b/test/serve/serves_index_html_for_directories_test.dart
index 90c87e42..e000e1ec 100644
--- a/test/serve/serves_index_html_for_directories_test.dart
+++ b/test/serve/serves_index_html_for_directories_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("", "<body>super");
     requestShouldSucceed("sub/", "<body>sub");
     requestShouldRedirect("sub", "/sub/");
diff --git a/test/serve/serves_web_and_test_dirs_by_default_test.dart b/test/serve/serves_web_and_test_dirs_by_default_test.dart
index 7367511a..6a5b4951 100644
--- a/test/serve/serves_web_and_test_dirs_by_default_test.dart
+++ b/test/serve/serves_web_and_test_dirs_by_default_test.dart
@@ -17,7 +17,7 @@ main() {
       d.dir("example", [d.file("baz", "contents")])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("foo", "contents", root: "web");
     requestShouldSucceed("bar", "contents", root: "test");
     requestShould404("baz", root: "web");
diff --git a/test/serve/supports_cross_origin_header_test.dart b/test/serve/supports_cross_origin_header_test.dart
index 96a08882..fbe54d7f 100644
--- a/test/serve/supports_cross_origin_header_test.dart
+++ b/test/serve/supports_cross_origin_header_test.dart
@@ -17,7 +17,7 @@ main() {
       d.dir("web", [d.file("index.html", "<body>")])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("index.html", "<body>",
         headers: containsPair("access-control-allow-origin", "*"));
     endPubServe();
diff --git a/test/serve/unknown_dependency_test.dart b/test/serve/unknown_dependency_test.dart
index ed7f70f1..b7e9c6b0 100644
--- a/test/serve/unknown_dependency_test.dart
+++ b/test/serve/unknown_dependency_test.dart
@@ -14,7 +14,7 @@ main() {
       d.appPubspec()
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShould404("packages/foo/nope.dart");
     requestShould404("assets/foo/nope.png");
     requestShould404("dir/packages/foo/nope.dart");
diff --git a/test/serve/uses_appropriate_mime_types_test.dart b/test/serve/uses_appropriate_mime_types_test.dart
index 265f3882..534fe891 100644
--- a/test/serve/uses_appropriate_mime_types_test.dart
+++ b/test/serve/uses_appropriate_mime_types_test.dart
@@ -22,7 +22,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("index.html", anything,
         headers: containsPair('content-type', 'text/html'));
     requestShouldSucceed("file.dart", anything,
diff --git a/test/serve/watch_added_file_test.dart b/test/serve/watch_added_file_test.dart
index b405bd68..9fafa62c 100644
--- a/test/serve/watch_added_file_test.dart
+++ b/test/serve/watch_added_file_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     waitForBuildSuccess();
     requestShouldSucceed("index.html", "body");
 
diff --git a/test/serve/watch_modified_file_test.dart b/test/serve/watch_modified_file_test.dart
index dc878a03..9fb0c318 100644
--- a/test/serve/watch_modified_file_test.dart
+++ b/test/serve/watch_modified_file_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("index.html", "before");
 
     d.dir(appPath, [
diff --git a/test/serve/watch_removed_file_test.dart b/test/serve/watch_removed_file_test.dart
index 45d7c51f..fffa86f8 100644
--- a/test/serve/watch_removed_file_test.dart
+++ b/test/serve/watch_removed_file_test.dart
@@ -21,7 +21,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
     requestShouldSucceed("index.html", "body");
 
     schedule(() => deleteEntry(
diff --git a/test/serve/web_socket/exit_on_close_test.dart b/test/serve/web_socket/exit_on_close_test.dart
index f32bbbd0..2dc0a381 100644
--- a/test/serve/web_socket/exit_on_close_test.dart
+++ b/test/serve/web_socket/exit_on_close_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    var server = pubServe();
+    var server = pubServe(shouldGetFirst: true);
 
     // Make sure the web socket is active.
     expectWebSocketResult("urlToAssetId", {
diff --git a/test/serve/web_socket/path_to_urls_with_line_test.dart b/test/serve/web_socket/path_to_urls_with_line_test.dart
index b3f07764..2de45e99 100644
--- a/test/serve/web_socket/path_to_urls_with_line_test.dart
+++ b/test/serve/web_socket/path_to_urls_with_line_test.dart
@@ -19,7 +19,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     expectWebSocketResult("pathToUrls", {
       "path": p.join("web", "main.dart"),
diff --git a/test/serve/web_socket/serve_directory_already_served_test.dart b/test/serve/web_socket/serve_directory_already_served_test.dart
index 84a5b7be..b472a3b8 100644
--- a/test/serve/web_socket/serve_directory_already_served_test.dart
+++ b/test/serve/web_socket/serve_directory_already_served_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     expectWebSocketResult("serveDirectory", {"path": "web"}, {
       "url": getServerUrl("web")
diff --git a/test/serve/web_socket/serve_directory_and_immediately_request_asset_test.dart b/test/serve/web_socket/serve_directory_and_immediately_request_asset_test.dart
index 27bc8b6d..87af20d1 100644
--- a/test/serve/web_socket/serve_directory_and_immediately_request_asset_test.dart
+++ b/test/serve/web_socket/serve_directory_and_immediately_request_asset_test.dart
@@ -23,7 +23,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["web"]);
+    pubServe(args: ["web"], shouldGetFirst: true);
 
     // Bind the new directory.
     expect(webSocketRequest("serveDirectory", {"path": "test"}), completes);
diff --git a/test/serve/web_socket/serve_directory_and_immediately_serve_again_test.dart b/test/serve/web_socket/serve_directory_and_immediately_serve_again_test.dart
index 96c4ddc9..5ac8f58c 100644
--- a/test/serve/web_socket/serve_directory_and_immediately_serve_again_test.dart
+++ b/test/serve/web_socket/serve_directory_and_immediately_serve_again_test.dart
@@ -25,7 +25,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["web"]);
+    pubServe(args: ["web"], shouldGetFirst: true);
 
     schedule(() {
       return Future.wait([
diff --git a/test/serve/web_socket/serve_directory_and_immediately_unserve_test.dart b/test/serve/web_socket/serve_directory_and_immediately_unserve_test.dart
index b73c3c83..2e263faf 100644
--- a/test/serve/web_socket/serve_directory_and_immediately_unserve_test.dart
+++ b/test/serve/web_socket/serve_directory_and_immediately_unserve_test.dart
@@ -25,7 +25,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["web"]);
+    pubServe(args: ["web"], shouldGetFirst: true);
 
     // We call [webSocketRequest] outside of the [schedule] call below because
     // we need it to schedule the sending of the request to guarantee that the
diff --git a/test/serve/web_socket/serve_directory_arg_errors_test.dart b/test/serve/web_socket/serve_directory_arg_errors_test.dart
index 5bd298eb..458a5ade 100644
--- a/test/serve/web_socket/serve_directory_arg_errors_test.dart
+++ b/test/serve/web_socket/serve_directory_arg_errors_test.dart
@@ -22,7 +22,7 @@ main() {
   });
 
   integration("responds with an error if 'path' is not a string", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("serveDirectory", {"path": 123},
         rpc_error_code.INVALID_PARAMS,
         'Parameter "path" for method "serveDirectory" must be a string, but '
@@ -31,7 +31,7 @@ main() {
   });
 
   integration("responds with an error if 'path' is absolute", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("serveDirectory", {"path": "/absolute.txt"},
         rpc_error_code.INVALID_PARAMS,
         '"path" must be a relative path. Got "/absolute.txt".');
@@ -39,7 +39,7 @@ main() {
   });
 
   integration("responds with an error if 'path' reaches out", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("serveDirectory", {"path": "a/../../bad.txt"},
         rpc_error_code.INVALID_PARAMS,
         '"path" cannot reach out of its containing directory. Got '
diff --git a/test/serve/web_socket/serve_directory_overlapping_test.dart b/test/serve/web_socket/serve_directory_overlapping_test.dart
index 00c7ec60..32035071 100644
--- a/test/serve/web_socket/serve_directory_overlapping_test.dart
+++ b/test/serve/web_socket/serve_directory_overlapping_test.dart
@@ -23,7 +23,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     var webSub = path.join("web", "sub");
     expectWebSocketError("serveDirectory", {"path": webSub}, 2,
diff --git a/test/serve/web_socket/serve_directory_test.dart b/test/serve/web_socket/serve_directory_test.dart
index bc48072c..70f20ca3 100644
--- a/test/serve/web_socket/serve_directory_test.dart
+++ b/test/serve/web_socket/serve_directory_test.dart
@@ -22,7 +22,7 @@ main() {
       ])
     ]).create();
 
-    pubServe(args: ["web"]);
+    pubServe(args: ["web"], shouldGetFirst: true);
 
     // Bind the new directory.
     schedule(() async {
diff --git a/test/serve/web_socket/unserve_directory_arg_errors_test.dart b/test/serve/web_socket/unserve_directory_arg_errors_test.dart
index 265df168..cddb9643 100644
--- a/test/serve/web_socket/unserve_directory_arg_errors_test.dart
+++ b/test/serve/web_socket/unserve_directory_arg_errors_test.dart
@@ -22,7 +22,7 @@ main() {
   });
 
   integration("responds with an error if 'path' is not a string", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("unserveDirectory", {"path": 123},
         rpc_error_code.INVALID_PARAMS,
         'Parameter "path" for method "unserveDirectory" must be a string, but '
@@ -31,7 +31,7 @@ main() {
   });
 
   integration("responds with an error if 'path' is absolute", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("unserveDirectory", {"path": "/absolute.txt"},
         rpc_error_code.INVALID_PARAMS,
         '"path" must be a relative path. Got "/absolute.txt".');
@@ -39,7 +39,7 @@ main() {
   });
 
   integration("responds with an error if 'path' reaches out", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("unserveDirectory", {"path": "a/../../bad.txt"},
         rpc_error_code.INVALID_PARAMS,
         '"path" cannot reach out of its containing directory. Got '
diff --git a/test/serve/web_socket/unserve_directory_not_served_test.dart b/test/serve/web_socket/unserve_directory_not_served_test.dart
index 4ca57533..2c418187 100644
--- a/test/serve/web_socket/unserve_directory_not_served_test.dart
+++ b/test/serve/web_socket/unserve_directory_not_served_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     // Unbind the directory.
     expectWebSocketError("unserveDirectory", {"path": "test"}, NOT_SERVED,
diff --git a/test/serve/web_socket/unserve_directory_test.dart b/test/serve/web_socket/unserve_directory_test.dart
index b4bf97a5..acd2f5da 100644
--- a/test/serve/web_socket/unserve_directory_test.dart
+++ b/test/serve/web_socket/unserve_directory_test.dart
@@ -20,7 +20,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     requestShouldSucceed("index.html", "<body>");
     requestShouldSucceed("index.html", "<test body>", root: "test");
diff --git a/test/serve/web_socket/url_to_asset_id_errors_test.dart b/test/serve/web_socket/url_to_asset_id_errors_test.dart
index c3cfa911..10a60339 100644
--- a/test/serve/web_socket/url_to_asset_id_errors_test.dart
+++ b/test/serve/web_socket/url_to_asset_id_errors_test.dart
@@ -18,7 +18,7 @@ main() {
   });
 
   integration("responds with NOT_SERVED for an unknown domain", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("urlToAssetId", {
       "url": "http://example.com:80/index.html"
     }, NOT_SERVED, '"example.com:80" is not being served by pub.');
@@ -26,7 +26,7 @@ main() {
   });
 
   integration("responds with NOT_SERVED for an unknown port", () {
-    pubServe();
+    pubServe(shouldGetFirst: true);
     expectWebSocketError("urlToAssetId", {
       "url": "http://localhost:80/index.html"
     }, NOT_SERVED, '"localhost:80" is not being served by pub.');
diff --git a/test/serve/web_socket/url_to_asset_id_with_line_test.dart b/test/serve/web_socket/url_to_asset_id_with_line_test.dart
index e83efe5f..ca0b9152 100644
--- a/test/serve/web_socket/url_to_asset_id_with_line_test.dart
+++ b/test/serve/web_socket/url_to_asset_id_with_line_test.dart
@@ -17,7 +17,7 @@ main() {
       ])
     ]).create();
 
-    pubServe();
+    pubServe(shouldGetFirst: true);
 
     // Paths in web/.
     expectWebSocketResult("urlToAssetId", {
-- 
GitLab