aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/benchmark/javatests
diff options
context:
space:
mode:
authorGravatar Yue Gan <yueg@google.com>2017-02-01 15:20:15 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-02-01 16:36:30 +0000
commiteaa5281942eaeda294b7e36ab012f592c1f637c2 (patch)
treeb569dd2f39bd6c5ec1c7667841cef188f435dd6c /src/tools/benchmark/javatests
parentb3c833f2ee6e6daf7cfa5c616092d10cb14bd963 (diff)
Benchmark part 3: main stuff
-- PiperOrigin-RevId: 146240366 MOS_MIGRATED_REVID=146240366
Diffstat (limited to 'src/tools/benchmark/javatests')
-rw-r--r--src/tools/benchmark/javatests/com/google/devtools/build/benchmark/BUILD10
-rw-r--r--src/tools/benchmark/javatests/com/google/devtools/build/benchmark/MainTest.java50
2 files changed, 60 insertions, 0 deletions
diff --git a/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/BUILD b/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/BUILD
index f2bc4e85b4..b70bebb4aa 100644
--- a/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/BUILD
+++ b/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/BUILD
@@ -1,6 +1,16 @@
package(default_visibility = ["//src/tools/benchmark:__subpackages__"])
java_test(
+ name = "MainTest",
+ srcs = ["MainTest.java"],
+ deps = [
+ "//src/main/java/com/google/devtools/common/options",
+ "//src/tools/benchmark/java/com/google/devtools/build/benchmark:benchmark_lib",
+ "//third_party:junit4",
+ ],
+)
+
+java_test(
name = "BazelBuildCaseTest",
srcs = ["BazelBuildCaseTest.java"],
deps = [
diff --git a/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/MainTest.java b/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/MainTest.java
new file mode 100644
index 0000000000..015c2f6325
--- /dev/null
+++ b/src/tools/benchmark/javatests/com/google/devtools/build/benchmark/MainTest.java
@@ -0,0 +1,50 @@
+// 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.
+
+package com.google.devtools.build.benchmark;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import com.google.devtools.common.options.OptionsParsingException;
+import java.io.IOException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test for {@link Main}. */
+@RunWith(JUnit4.class)
+public class MainTest {
+
+ @Test
+ public void testParseArgsMissingArgs() throws OptionsParsingException, IOException {
+ try {
+ Main.parseArgs(new String[] {"--workspace=workspace", "--from=1"});
+ fail("Should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Argument value should not be empty.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testParseArgsCorrect() throws OptionsParsingException, IOException {
+ BenchmarkOptions opt =
+ Main.parseArgs(
+ new String[] {"--output=output", "--workspace=workspace", "--from=1", "--to=3"});
+ assertEquals(opt.output, "output");
+ assertEquals(opt.workspace, "workspace");
+ assertEquals(opt.from, "1");
+ assertEquals(opt.to, "3");
+ }
+}