Compile spawnUri entrypoints to JS with pub build/serve.

R=rnystrom@google.com
BUG=16210

Review URL: https://codereview.chromium.org//147923003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32093 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart
index a965dd7..89845af 100644
--- a/sdk/lib/_internal/pub/lib/src/dart.dart
+++ b/sdk/lib/_internal/pub/lib/src/dart.dart
@@ -106,11 +106,14 @@
 
 /// Returns whether [dart] looks like an entrypoint file.
 bool isEntrypoint(CompilationUnit dart) {
+  // Allow two or fewer arguments so that entrypoints intended for use with
+  // [spawnUri] get counted.
+  //
   // TODO(nweiz): this misses the case where a Dart file doesn't contain main(),
   // but it parts in another file that does.
   return dart.declarations.any((node) {
     return node is FunctionDeclaration && node.name.name == "main" &&
-        node.functionExpression.parameters.parameters.isEmpty;
+        node.functionExpression.parameters.parameters.length <= 2;
   });
 }
 
diff --git a/sdk/lib/_internal/pub/test/build/ignores_non_entrypoint_dart_files_test.dart b/sdk/lib/_internal/pub/test/build/ignores_non_entrypoint_dart_files_test.dart
index 51d6b9d..39de56e 100644
--- a/sdk/lib/_internal/pub/test/build/ignores_non_entrypoint_dart_files_test.dart
+++ b/sdk/lib/_internal/pub/test/build/ignores_non_entrypoint_dart_files_test.dart
@@ -13,7 +13,7 @@
       d.appPubspec(),
       d.dir('web', [
         d.file('file1.dart', 'var main = () => print("hello");'),
-        d.file('file2.dart', 'void main(arg) => print("hello");'),
+        d.file('file2.dart', 'void main(arg1, arg2, arg3) => print("hello");'),
         d.file('file3.dart', 'class Foo { void main() => print("hello"); }'),
         d.file('file4.dart', 'var foo;')
       ])
diff --git a/sdk/lib/_internal/pub/test/build/includes_dart_files_in_debug_mode_test.dart b/sdk/lib/_internal/pub/test/build/includes_dart_files_in_debug_mode_test.dart
index 96f3cd0..3d3281c 100644
--- a/sdk/lib/_internal/pub/test/build/includes_dart_files_in_debug_mode_test.dart
+++ b/sdk/lib/_internal/pub/test/build/includes_dart_files_in_debug_mode_test.dart
@@ -15,7 +15,7 @@
       d.appPubspec(),
       d.dir('web', [
         d.file('file1.dart', 'var main = () => print("hello");'),
-        d.file('file2.dart', 'void main(arg) => print("hello");'),
+        d.file('file2.dart', 'void main(arg1, arg2, arg3) => print("hello");'),
         d.file('file3.dart', 'class Foo { void main() => print("hello"); }'),
         d.file('file4.dart', 'var foo;')
       ])
diff --git a/sdk/lib/_internal/pub/test/transformer/dart2js/converts_isolate_entrypoint_in_web_test.dart b/sdk/lib/_internal/pub/test/transformer/dart2js/converts_isolate_entrypoint_in_web_test.dart
new file mode 100644
index 0000000..2430273
--- /dev/null
+++ b/sdk/lib/_internal/pub/test/transformer/dart2js/converts_isolate_entrypoint_in_web_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2013, 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_test.dart';
+
+import '../../descriptor.dart' as d;
+import '../../test_pub.dart';
+import '../../serve/utils.dart';
+
+main() {
+  initConfig();
+  integration("converts a Dart isolate entrypoint in web to JS", () {
+    d.dir(appPath, [
+      d.appPubspec(),
+      d.dir("web", [
+        d.file("isolate.dart", "void main(List<String> args, SendPort "
+            "sendPort) => print('hello');")
+      ])
+    ]).create();
+
+    pubServe();
+    requestShouldSucceed("isolate.dart.js", contains("hello"));
+    endPubServe();
+  });
+}