Add end-to-end test (#22)

diff --git a/.bazelrc b/.bazelrc
new file mode 100644
index 0000000..b98fc09
--- /dev/null
+++ b/.bazelrc
@@ -0,0 +1 @@
+test --test_output=errors
diff --git a/examples/rollup/BUILD.bazel b/examples/rollup/BUILD.bazel
index 2a7bf00..a854874 100644
--- a/examples/rollup/BUILD.bazel
+++ b/examples/rollup/BUILD.bazel
@@ -15,3 +15,16 @@
     entry_point = "rollup/bin/rollup",
     node_modules = ":node_modules",
 )
+
+load(":rollup.bzl", "rollup")
+rollup(
+    name = "bundle",
+    entry_point = "examples/rollup/foo.js",
+    srcs = ["foo.js", "bar.js"],
+)
+
+sh_test(
+    name = "test",
+    srcs = ["test.sh"],
+    data = [":bundle.js"],
+)
diff --git a/examples/rollup/bar.js b/examples/rollup/bar.js
new file mode 100644
index 0000000..5195f60
--- /dev/null
+++ b/examples/rollup/bar.js
@@ -0,0 +1 @@
+export const name = 'Alice';
diff --git a/examples/rollup/foo.js b/examples/rollup/foo.js
new file mode 100644
index 0000000..35141cb
--- /dev/null
+++ b/examples/rollup/foo.js
@@ -0,0 +1,3 @@
+import {name} from './bar';
+
+console.log(`Hello, ${name}`);
diff --git a/examples/rollup/rollup.bzl b/examples/rollup/rollup.bzl
new file mode 100644
index 0000000..30ea45d
--- /dev/null
+++ b/examples/rollup/rollup.bzl
@@ -0,0 +1,44 @@
+# Copyright 2017 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+def _rollup(ctx):
+  """This is not a full-featured Rollup bazel rule, just enough to test the
+     other rules in this repo.
+  """
+  args = ["--input", ctx.attr.entry_point]
+  args += ["--output.file", ctx.outputs.bundle.path]
+  args += ["--output.format", "es"]
+
+  ctx.action(
+      inputs = ctx.files.srcs,
+      executable = ctx.executable.rollup,
+      outputs = [ctx.outputs.bundle],
+      arguments = args,
+  )
+  return struct()
+
+rollup = rule(
+    implementation = _rollup,
+    attrs = {
+        "srcs": attr.label_list(allow_files = True),
+        "entry_point": attr.string(mandatory = True),
+        "rollup": attr.label(
+            default = Label("//examples/rollup"),
+            executable = True,
+            cfg = "host"),
+    },
+    outputs = {
+        "bundle": "%{name}.js"
+    },
+)
\ No newline at end of file
diff --git a/examples/rollup/test.sh b/examples/rollup/test.sh
new file mode 100755
index 0000000..f47aaab
--- /dev/null
+++ b/examples/rollup/test.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+set -e
+
+readonly EXPECTED="${TEST_TMPDIR}/EXPECTED.js"
+(cat <<'EOF'
+const name = 'Alice';
+
+console.log(`Hello, ${name}`);
+EOF
+) > $EXPECTED
+
+readonly ACTUAL="${TEST_SRCDIR}/build_bazel_rules_nodejs/examples/rollup/bundle.js"
+diff $ACTUAL $EXPECTED || (
+  echo "Expected"
+  cat $EXPECTED
+  echo "But was"
+  cat $ACTUAL
+  exit 1
+)