Refactor tests by moving common utilities to test_utils.{h,cc} and
removing unused test case classes.


Also includes the following changes:

Fixes images for design doc "Beautiful Error Messages".

--
MOS_MIGRATED_REVID=129725896
diff --git a/site/assets/error_example_1.png b/site/assets/error_example_1.png
index e69de29..07ba135 100644
--- a/site/assets/error_example_1.png
+++ b/site/assets/error_example_1.png
Binary files differ
diff --git a/site/assets/error_example_2.png b/site/assets/error_example_2.png
index e69de29..861171e 100644
--- a/site/assets/error_example_2.png
+++ b/site/assets/error_example_2.png
Binary files differ
diff --git a/site/assets/error_example_3.png b/site/assets/error_example_3.png
index e69de29..dc16eec 100644
--- a/site/assets/error_example_3.png
+++ b/site/assets/error_example_3.png
Binary files differ
diff --git a/site/assets/error_example_4.png b/site/assets/error_example_4.png
index e69de29..84383e6 100644
--- a/site/assets/error_example_4.png
+++ b/site/assets/error_example_4.png
Binary files differ
diff --git a/src/tools/singlejar/BUILD b/src/tools/singlejar/BUILD
index 497ff28..b16ec59 100644
--- a/src/tools/singlejar/BUILD
+++ b/src/tools/singlejar/BUILD
@@ -41,13 +41,13 @@
     name = "input_jar_preambled_test",
     srcs = [
         "input_jar_preambled_test.cc",
-        ":test_util",
     ],
     data = [
         ":test1",
     ],
     deps = [
         ":input_jar",
+        ":test_util",
         "//src/main/cpp/util",
         "//third_party:gtest",
     ],
@@ -59,7 +59,6 @@
     srcs = [
         "input_jar_scan_entries_test.h",
         "input_jar_scan_jartool_test.cc",
-        ":test_util",
     ],
     copts = ["-DJAR_TOOL_PATH=\\\"external/local_jdk/bin/jar\\\""],
     data = [
@@ -70,6 +69,7 @@
     tags = ["manual"],
     deps = [
         ":input_jar",
+        ":test_util",
         "//third_party:gtest",
     ],
 )
@@ -80,12 +80,12 @@
     srcs = [
         "input_jar_scan_entries_test.h",
         "input_jar_scan_ziptool_test.cc",
-        ":test_util",
     ],
     # Timing out, see https://github.com/bazelbuild/bazel/issues/1555
     tags = ["manual"],
     deps = [
         ":input_jar",
+        ":test_util",
         "//third_party:gtest",
     ],
 )
@@ -94,10 +94,10 @@
     name = "input_jar_bad_jar_test",
     srcs = [
         "input_jar_bad_jar_test.cc",
-        ":test_util",
     ],
     deps = [
         ":input_jar",
+        ":test_util",
         "//third_party:gtest",
     ],
 )
@@ -111,6 +111,8 @@
     ],
     deps = [
         ":options",
+        ":test_util",
+        "//src/main/cpp/util",
         "//third_party:gtest",
     ],
 )
@@ -129,6 +131,7 @@
         ":input_jar",
         ":options",
         ":output_jar",
+        ":test_util",
         "//src/main/cpp:blaze_util",
         "//src/main/cpp/util",
         "//third_party:gtest",
@@ -141,7 +144,10 @@
         "token_stream_test.cc",
         ":token_stream",
     ],
-    deps = ["//third_party:gtest"],
+    deps = [
+        ":test_util",
+        "//third_party:gtest",
+    ],
 )
 
 cc_test(
@@ -149,7 +155,6 @@
     size = "large",
     srcs = [
         "transient_bytes_test.cc",
-        ":test_util",
         ":transient_bytes",
         ":zlib_interface",
     ],
@@ -157,6 +162,7 @@
     tags = ["manual"],
     deps = [
         ":input_jar",
+        ":test_util",
         "//third_party:gtest",
         "//third_party/zlib",
     ],
@@ -179,6 +185,7 @@
         ":zlib_interface",
     ],
     deps = [
+        ":test_util",
         "//third_party:gtest",
         "//third_party/zlib",
     ],
@@ -227,6 +234,17 @@
     ],
 )
 
+cc_library(
+    name = "test_util",
+    srcs = ["test_util.cc"],
+    hdrs = ["test_util.h"],
+    deps = [
+        "//src/main/cpp:blaze_util",
+        "//src/main/cpp/util",
+        "//third_party:gtest",
+    ],
+)
+
 filegroup(
     name = "combiners",
     srcs = [
@@ -238,11 +256,6 @@
 )
 
 filegroup(
-    name = "test_util",
-    srcs = ["test_util.h"],
-)
-
-filegroup(
     name = "token_stream",
     srcs = [
         "diag.h",
diff --git a/src/tools/singlejar/input_jar_bad_jar_test.cc b/src/tools/singlejar/input_jar_bad_jar_test.cc
index aa0646c..7b0507f 100644
--- a/src/tools/singlejar/input_jar_bad_jar_test.cc
+++ b/src/tools/singlejar/input_jar_bad_jar_test.cc
@@ -12,36 +12,25 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <errno.h>
-#include <unistd.h>
-#include <memory>
 #include <string>
 
 #include "src/tools/singlejar/input_jar.h"
 #include "src/tools/singlejar/test_util.h"
-
 #include "gtest/gtest.h"
 
 static const char kJar[] = "jar.jar";
 
-class InputJarBadJarTest : public testing::Test {
- protected:
-  void SetUp() override {
-    input_jar_.reset(new InputJar);
-  }
-
-  std::unique_ptr<InputJar> input_jar_;
-};
-
-TEST_F(InputJarBadJarTest, NotAJar) {
-  ASSERT_EQ(0, chdir(getenv("TEST_TMPDIR")));
-  ASSERT_TRUE(TestUtil::AllocateFile(kJar, 1000));
-  ASSERT_FALSE(input_jar_->Open(kJar));
+TEST(InputJarBadJarTest, NotAJar) {
+  std::string out_path = singlejar_test_util::OutputFilePath(kJar);
+  ASSERT_TRUE(singlejar_test_util::AllocateFile(out_path, 1000));
+  InputJar input_jar;
+  ASSERT_FALSE(input_jar.Open(out_path));
 }
 
 // Check that an empty file does not cause trouble in MappedFile.
-TEST_F(InputJarBadJarTest, EmptyFile) {
-  ASSERT_EQ(0, chdir(getenv("TEST_TMPDIR")));
-  ASSERT_TRUE(TestUtil::AllocateFile(kJar, 0));
-  ASSERT_FALSE(input_jar_->Open(kJar));
+TEST(InputJarBadJarTest, EmptyFile) {
+  std::string out_path = singlejar_test_util::OutputFilePath(kJar);
+  ASSERT_TRUE(singlejar_test_util::AllocateFile(out_path, 0));
+  InputJar input_jar;
+  ASSERT_FALSE(input_jar.Open(out_path));
 }
diff --git a/src/tools/singlejar/input_jar_preambled_test.cc b/src/tools/singlejar/input_jar_preambled_test.cc
index b540198..60600e8 100644
--- a/src/tools/singlejar/input_jar_preambled_test.cc
+++ b/src/tools/singlejar/input_jar_preambled_test.cc
@@ -42,76 +42,71 @@
 #define DATA_DIR_TOP
 #endif
 
-class InputJarPreambledTest : public testing::Test {
- protected:
-  void SetUp() override { input_jar_.reset(new InputJar); }
-
-  void Verify(const std::string &path) {
-    ASSERT_TRUE(input_jar_->Open(path));
-    const LH *lh;
-    const CDH *cdh;
-    while ((cdh = input_jar_->NextEntry(&lh))) {
-      ASSERT_TRUE(cdh->is())
-          << "No expected tag in the Central Directory Entry.";
-      ASSERT_NE(nullptr, lh) << "No local header.";
-      ASSERT_TRUE(lh->is()) << "No expected tag in the Local Header.";
-      EXPECT_EQ(lh->file_name_string(), cdh->file_name_string());
-      if (!cdh->no_size_in_local_header()) {
-        EXPECT_EQ(lh->compressed_file_size(), cdh->compressed_file_size())
-            << "Entry: " << lh->file_name_string();
-        EXPECT_EQ(lh->uncompressed_file_size(), cdh->uncompressed_file_size())
-            << "Entry: " << cdh->file_name_string();
-      }
+void Verify(const std::string &path) {
+  InputJar input_jar;
+  ASSERT_TRUE(input_jar.Open(path));
+  const LH *lh;
+  const CDH *cdh;
+  while ((cdh = input_jar.NextEntry(&lh))) {
+    ASSERT_TRUE(cdh->is())
+        << "No expected tag in the Central Directory Entry.";
+    ASSERT_NE(nullptr, lh) << "No local header.";
+    ASSERT_TRUE(lh->is()) << "No expected tag in the Local Header.";
+    EXPECT_EQ(lh->file_name_string(), cdh->file_name_string());
+    if (!cdh->no_size_in_local_header()) {
+      EXPECT_EQ(lh->compressed_file_size(), cdh->compressed_file_size())
+          << "Entry: " << lh->file_name_string();
+      EXPECT_EQ(lh->uncompressed_file_size(), cdh->uncompressed_file_size())
+          << "Entry: " << cdh->file_name_string();
     }
-    input_jar_->Close();
   }
-
-  static std::string OutputFilePath(const char *relative_path) {
-    const char *out_dir = getenv("TEST_TMPDIR");
-    return blaze_util::JoinPath(nullptr == out_dir ? "." : out_dir,
-                                relative_path);
-  }
-
-  std::unique_ptr<InputJar> input_jar_;
-};
+  input_jar.Close();
+}
 
 // Archive not containing 64-bit End of Central Directory/Locator with preamble.
-TEST_F(InputJarPreambledTest, Small) {
-  std::string out_path = OutputFilePath("out.jwp");
-  std::string exe_path = OutputFilePath("exe");
-  ASSERT_TRUE(TestUtil::AllocateFile(exe_path.c_str(), 100));
+TEST(InputJarPreambledTest, Small) {
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jwp");
+  std::string exe_path = singlejar_test_util::OutputFilePath("exe");
+  ASSERT_TRUE(singlejar_test_util::AllocateFile(exe_path, 100));
   ASSERT_EQ(
-      0, TestUtil::RunCommand("cat", exe_path.c_str(),
-                              DATA_DIR_TOP "src/tools/singlejar/libtest1.jar",
-                              ">", out_path.c_str(), nullptr));
+      0,
+      singlejar_test_util::RunCommand(
+          "cat", exe_path.c_str(),
+          DATA_DIR_TOP "src/tools/singlejar/libtest1.jar",
+          ">", out_path.c_str(), nullptr));
   Verify(out_path);
 }
 
 // Same as above with zip -A applied to the file.
-TEST_F(InputJarPreambledTest, SmallAdjusted) {
-  std::string out_path = OutputFilePath("out.jwp");
-  std::string exe_path = OutputFilePath("exe");
-  ASSERT_TRUE(TestUtil::AllocateFile(exe_path.c_str(), 100));
+TEST(InputJarPreambledTest, SmallAdjusted) {
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jwp");
+  std::string exe_path = singlejar_test_util::OutputFilePath("exe");
+  ASSERT_TRUE(singlejar_test_util::AllocateFile(exe_path, 100));
   ASSERT_EQ(
-      0, TestUtil::RunCommand("cat", exe_path.c_str(),
-                              DATA_DIR_TOP "src/tools/singlejar/libtest1.jar",
-                              ">", out_path.c_str(), nullptr));
-  ASSERT_EQ(0, TestUtil::RunCommand("zip", "-A", out_path.c_str(), nullptr));
+      0,
+      singlejar_test_util::RunCommand(
+          "cat", exe_path.c_str(),
+          DATA_DIR_TOP "src/tools/singlejar/libtest1.jar",
+          ">", out_path.c_str(), nullptr));
+  ASSERT_EQ(0, singlejar_test_util::RunCommand("zip", "-A", out_path.c_str(),
+                                               nullptr));
   Verify(out_path);
 }
 
 // 64-bit Zip file with preamble
-TEST_F(InputJarPreambledTest, Huge) {
-  std::string file4g = OutputFilePath("file4g");
-  ASSERT_TRUE(TestUtil::AllocateFile(file4g.c_str(), 0x10000000F));
-  std::string huge_jar = OutputFilePath("huge.jar");
-  ASSERT_EQ(0, TestUtil::RunCommand("zip", "-0m", huge_jar.c_str(),
-                                    file4g.c_str(), nullptr));
-  std::string exe_path = OutputFilePath("exe");
-  std::string out_path = OutputFilePath("out.jwp");
+TEST(InputJarPreambledTest, Huge) {
+  std::string file4g = singlejar_test_util::OutputFilePath("file4g");
+  ASSERT_TRUE(singlejar_test_util::AllocateFile(file4g, 0x10000000F));
+  std::string huge_jar = singlejar_test_util::OutputFilePath("huge.jar");
+  ASSERT_EQ(0, singlejar_test_util::RunCommand("zip", "-0m", huge_jar.c_str(),
+                                               file4g.c_str(), nullptr));
+  std::string exe_path = singlejar_test_util::OutputFilePath("exe");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jwp");
   ASSERT_EQ(0,
-            TestUtil::RunCommand("cat", exe_path.c_str(), huge_jar.c_str(),
-                                 ">", out_path.c_str(), nullptr));
+            singlejar_test_util::RunCommand("cat", exe_path.c_str(),
+                                            huge_jar.c_str(),
+                                            ">", out_path.c_str(), nullptr));
   Verify(out_path);
 }
+
 }  // namespace
diff --git a/src/tools/singlejar/input_jar_random_jars_test.cc b/src/tools/singlejar/input_jar_random_jars_test.cc
index b2f4542..ffdc063 100644
--- a/src/tools/singlejar/input_jar_random_jars_test.cc
+++ b/src/tools/singlejar/input_jar_random_jars_test.cc
@@ -22,11 +22,12 @@
 
 #include "gtest/gtest.h"
 
+namespace {
+
 static const char kJarsDirPath[] =
     "third_party/bazel/src/tools/singlejar/jars_to_test";
-class InputJarRandomJarsTest : public testing::Test {};
 
-TEST_F(InputJarRandomJarsTest, ScanAllJars) {
+TEST(InputJarRandomJarsTest, ScanAllJars) {
   int processed_jars = 0;
   DIR *dirp = opendir(kJarsDirPath);
   ASSERT_NE(nullptr, dirp);
@@ -69,3 +70,5 @@
   closedir(dirp);
   EXPECT_LT(0, processed_jars);
 }
+
+}  // namespace
diff --git a/src/tools/singlejar/input_jar_scan_entries_test.h b/src/tools/singlejar/input_jar_scan_entries_test.h
index 5900b0c..8bf0fb6 100644
--- a/src/tools/singlejar/input_jar_scan_entries_test.h
+++ b/src/tools/singlejar/input_jar_scan_entries_test.h
@@ -49,8 +49,8 @@
   static void TearDownTestCase() { ZipCreator::TearDownTestCase(); }
 
   static void CreateBasicJar() {
-    ASSERT_TRUE(TestUtil::AllocateFile(kRes1, res1_size));
-    ASSERT_TRUE(TestUtil::AllocateFile(kRes2, res2_size));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kRes1, res1_size));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kRes2, res2_size));
     unlink(kJar);
     ASSERT_EQ(0, ZipCreator::Jar(true, kJar, kRes1, kRes2, nullptr));
     unlink(kRes1);
@@ -58,17 +58,17 @@
   }
 
   static void CreateJarWithHugeUncompressed() {
-    ASSERT_TRUE(TestUtil::AllocateFile(kHuge, huge_size));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kHuge, huge_size));
     unlink(kJar);
     ASSERT_EQ(0, ZipCreator::Jar(true, kJar, kHuge, nullptr));
     unlink(kHuge);
   }
 
   static void CreateJarWithZip64Entries() {
-    ASSERT_TRUE(TestUtil::AllocateFile(kXXXX, 0xFFFFFFFF));
-    ASSERT_TRUE(TestUtil::AllocateFile(kHuge, huge_size));
-    ASSERT_TRUE(TestUtil::AllocateFile(kEmpty, 0));
-    ASSERT_TRUE(TestUtil::AllocateFile(kRes1, res1_size));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kXXXX, 0xFFFFFFFF));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kHuge, huge_size));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kEmpty, 0));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile(kRes1, res1_size));
     ASSERT_EQ(
         0, ZipCreator::Jar(false, kJar, kXXXX, kHuge, kEmpty, kRes1, nullptr));
     unlink(kXXXX);
@@ -88,7 +88,7 @@
       for (int file = 0; file < 256; ++file) {
         char filepath[20];
         snprintf(filepath, sizeof(filepath), "%s/%d", dirname, file);
-        ASSERT_TRUE(TestUtil::AllocateFile(filepath, 1));
+        ASSERT_TRUE(singlejar_test_util::AllocateFile(filepath, 1));
       }
     }
     ASSERT_EQ(0, ZipCreator::Jar(false, kJar, "dir*", nullptr));
@@ -123,7 +123,7 @@
 TYPED_TEST_P(InputJarScanEntries, OpenClose) {
   ASSERT_EQ(0, chdir(getenv("TEST_TMPDIR")));
   this->CreateBasicJar();
-  TestUtil::LsZip(kJar);
+  singlejar_test_util::LsZip(kJar);
   ASSERT_TRUE(this->input_jar_->Open(kJar));
   EXPECT_GE(this->input_jar_->fd(), 0);
   this->input_jar_->Close();
@@ -173,7 +173,7 @@
 TYPED_TEST_P(InputJarScanEntries, HugeUncompressed) {
   ASSERT_EQ(0, chdir(getenv("TEST_TMPDIR")));
   this->CreateJarWithHugeUncompressed();
-  TestUtil::LsZip(kJar);
+  singlejar_test_util::LsZip(kJar);
   ASSERT_TRUE(this->input_jar_->Open(kJar));
   const LH *lh;
   const CDH *cdh;
@@ -200,7 +200,7 @@
 TYPED_TEST_P(InputJarScanEntries, TestZip64) {
   ASSERT_EQ(0, chdir(getenv("TEST_TMPDIR")));
   this->CreateJarWithZip64Entries();
-  TestUtil::LsZip(kJar);
+  singlejar_test_util::LsZip(kJar);
   ASSERT_TRUE(this->input_jar_->Open(kJar));
   const LH *lh;
   const CDH *cdh;
diff --git a/src/tools/singlejar/options_test.cc b/src/tools/singlejar/options_test.cc
index 9744d6c..4a4d53a 100644
--- a/src/tools/singlejar/options_test.cc
+++ b/src/tools/singlejar/options_test.cc
@@ -15,52 +15,48 @@
 #include <memory>
 
 #include "src/tools/singlejar/options.h"
+#include "src/tools/singlejar/test_util.h"
 
+#include "src/main/cpp/util/port.h"
 #include "gtest/gtest.h"
 
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
-class OptionsTest : public testing::Test {
- protected:
-  void SetUp() override { options_.reset(new Options); }
-  std::unique_ptr<Options> options_;
-};
-
-TEST_F(OptionsTest, Flags1) {
+TEST(OptionsTest, Flags1) {
   const char *args[] = {"--exclude_build_data",
                         "--compression",
                         "--normalize",
                         "--no_duplicates",
                         "--output", "output_jar"};
-  options_->ParseCommandLine(ARRAY_SIZE(args), args);
+  Options options;
+  options.ParseCommandLine(arraysize(args), args);
 
-  EXPECT_TRUE(options_->exclude_build_data);
-  EXPECT_TRUE(options_->force_compression);
-  EXPECT_TRUE(options_->normalize_timestamps);
-  EXPECT_TRUE(options_->no_duplicates);
-  EXPECT_FALSE(options_->preserve_compression);
-  EXPECT_FALSE(options_->verbose);
-  EXPECT_FALSE(options_->warn_duplicate_resources);
-  EXPECT_EQ("output_jar", options_->output_jar);
+  EXPECT_TRUE(options.exclude_build_data);
+  EXPECT_TRUE(options.force_compression);
+  EXPECT_TRUE(options.normalize_timestamps);
+  EXPECT_TRUE(options.no_duplicates);
+  EXPECT_FALSE(options.preserve_compression);
+  EXPECT_FALSE(options.verbose);
+  EXPECT_FALSE(options.warn_duplicate_resources);
+  EXPECT_EQ("output_jar", options.output_jar);
 }
 
-TEST_F(OptionsTest, Flags2) {
+TEST(OptionsTest, Flags2) {
   const char *args[] = {"--dont_change_compression",
                         "--verbose",
                         "--warn_duplicate_resources",
                         "--output", "output_jar"};
-  options_->ParseCommandLine(ARRAY_SIZE(args), args);
+  Options options;
+  options.ParseCommandLine(arraysize(args), args);
 
-  ASSERT_FALSE(options_->exclude_build_data);
-  ASSERT_FALSE(options_->force_compression);
-  ASSERT_FALSE(options_->normalize_timestamps);
-  ASSERT_FALSE(options_->no_duplicates);
-  ASSERT_TRUE(options_->preserve_compression);
-  ASSERT_TRUE(options_->verbose);
-  ASSERT_TRUE(options_->warn_duplicate_resources);
+  ASSERT_FALSE(options.exclude_build_data);
+  ASSERT_FALSE(options.force_compression);
+  ASSERT_FALSE(options.normalize_timestamps);
+  ASSERT_FALSE(options.no_duplicates);
+  ASSERT_TRUE(options.preserve_compression);
+  ASSERT_TRUE(options.verbose);
+  ASSERT_TRUE(options.warn_duplicate_resources);
 }
 
-TEST_F(OptionsTest, SingleOptargs) {
+TEST(OptionsTest, SingleOptargs) {
   const char *args[] = {"--output", "output_jar",
                         "--main_class", "com.google.Main",
                         "--java_launcher", "//tools:mylauncher",
@@ -68,44 +64,46 @@
                         "--extra_build_info", "extra_build_line1",
                         "--build_info_file", "build_file2",
                         "--extra_build_info", "extra_build_line2"};
-  options_->ParseCommandLine(ARRAY_SIZE(args), args);
+  Options options;
+  options.ParseCommandLine(arraysize(args), args);
 
-  EXPECT_EQ("output_jar", options_->output_jar);
-  EXPECT_EQ("com.google.Main", options_->main_class);
-  EXPECT_EQ("//tools:mylauncher", options_->java_launcher);
-  ASSERT_EQ(2, options_->build_info_files.size());
-  EXPECT_EQ("build_file1", options_->build_info_files[0]);
-  EXPECT_EQ("build_file2", options_->build_info_files[1]);
-  ASSERT_EQ(2, options_->build_info_lines.size());
-  EXPECT_EQ("extra_build_line1", options_->build_info_lines[0]);
-  EXPECT_EQ("extra_build_line2", options_->build_info_lines[1]);
+  EXPECT_EQ("output_jar", options.output_jar);
+  EXPECT_EQ("com.google.Main", options.main_class);
+  EXPECT_EQ("//tools:mylauncher", options.java_launcher);
+  ASSERT_EQ(2, options.build_info_files.size());
+  EXPECT_EQ("build_file1", options.build_info_files[0]);
+  EXPECT_EQ("build_file2", options.build_info_files[1]);
+  ASSERT_EQ(2, options.build_info_lines.size());
+  EXPECT_EQ("extra_build_line1", options.build_info_lines[0]);
+  EXPECT_EQ("extra_build_line2", options.build_info_lines[1]);
 }
 
-TEST_F(OptionsTest, MultiOptargs) {
-  const char *args[] = {"--output", "output_file",
+TEST(OptionsTest, MultiOptargs) {
+    const char *args[] = {"--output", "output_file",
                         "--sources", "jar1", "jar2",
                         "--resources", "res1", "res2",
                         "--classpath_resources", "cpres1", "cpres2",
                         "--sources", "jar3",
                         "--include_prefixes", "prefix1", "prefix2"};
-  options_->ParseCommandLine(ARRAY_SIZE(args), args);
+  Options options;
+  options.ParseCommandLine(arraysize(args), args);
 
-  ASSERT_EQ(3, options_->input_jars.size());
-  EXPECT_EQ("jar1", options_->input_jars[0]);
-  EXPECT_EQ("jar2", options_->input_jars[1]);
-  EXPECT_EQ("jar3", options_->input_jars[2]);
-  ASSERT_EQ(2, options_->resources.size());
-  EXPECT_EQ("res1", options_->resources[0]);
-  EXPECT_EQ("res2", options_->resources[1]);
-  ASSERT_EQ(2, options_->classpath_resources.size());
-  EXPECT_EQ("cpres1", options_->classpath_resources[0]);
-  EXPECT_EQ("cpres2", options_->classpath_resources[1]);
-  ASSERT_EQ(2, options_->include_prefixes.size());
-  EXPECT_EQ("prefix1", options_->include_prefixes[0]);
-  EXPECT_EQ("prefix2", options_->include_prefixes[1]);
+  ASSERT_EQ(3, options.input_jars.size());
+  EXPECT_EQ("jar1", options.input_jars[0]);
+  EXPECT_EQ("jar2", options.input_jars[1]);
+  EXPECT_EQ("jar3", options.input_jars[2]);
+  ASSERT_EQ(2, options.resources.size());
+  EXPECT_EQ("res1", options.resources[0]);
+  EXPECT_EQ("res2", options.resources[1]);
+  ASSERT_EQ(2, options.classpath_resources.size());
+  EXPECT_EQ("cpres1", options.classpath_resources[0]);
+  EXPECT_EQ("cpres2", options.classpath_resources[1]);
+  ASSERT_EQ(2, options.include_prefixes.size());
+  EXPECT_EQ("prefix1", options.include_prefixes[0]);
+  EXPECT_EQ("prefix2", options.include_prefixes[1]);
 }
 
-TEST_F(OptionsTest, EmptyMultiOptargs) {
+TEST(OptionsTest, EmptyMultiOptargs) {
   const char *args[] = {"--output", "output_file",
                         "--sources",
                         "--resources",
@@ -113,10 +111,11 @@
                         "--sources",
                         "--include_prefixes", "prefix1",
                         "--resources"};
-  options_->ParseCommandLine(ARRAY_SIZE(args), args);
+  Options options;
+  options.ParseCommandLine(arraysize(args), args);
 
-  EXPECT_EQ(0, options_->input_jars.size());
-  EXPECT_EQ(0, options_->resources.size());
-  EXPECT_EQ(0, options_->classpath_resources.size());
-  EXPECT_EQ(1, options_->include_prefixes.size());
+  EXPECT_EQ(0, options.input_jars.size());
+  EXPECT_EQ(0, options.resources.size());
+  EXPECT_EQ(0, options.classpath_resources.size());
+  EXPECT_EQ(1, options.include_prefixes.size());
 }
diff --git a/src/tools/singlejar/output_jar_simple_test.cc b/src/tools/singlejar/output_jar_simple_test.cc
index 598afcdf..a5852a3 100644
--- a/src/tools/singlejar/output_jar_simple_test.cc
+++ b/src/tools/singlejar/output_jar_simple_test.cc
@@ -19,6 +19,7 @@
 #include "src/tools/singlejar/input_jar.h"
 #include "src/tools/singlejar/options.h"
 #include "src/tools/singlejar/output_jar.h"
+#include "src/tools/singlejar/test_util.h"
 #include "gtest/gtest.h"
 
 namespace {
@@ -33,10 +34,6 @@
 
 class OutputJarSimpleTest : public ::testing::Test {
  protected:
-  OutputJarSimpleTest() {}
-
-  ~OutputJarSimpleTest() override {}
-
   void CreateOutput(const std::string &out_path, const char *first_arg...) {
     std::string args_string;
     va_list ap;
@@ -61,36 +58,7 @@
     printf("Arguments: %s\n", args_string.c_str());
     options_.ParseCommandLine(nargs, args);
     ASSERT_EQ(0, output_jar_.Doit(&options_));
-    EXPECT_EQ(0, VerifyZip(out_path));
-  }
-
-  static std::string OutputFilePath(const std::string &relpath) {
-    const char *out_dir = getenv("TEST_TMPDIR");
-    return blaze_util::JoinPath((nullptr == out_dir) ? "." : out_dir,
-                                relpath.c_str());
-  }
-
-  static int VerifyZip(const std::string &zip_path) {
-    std::string verify_command;
-    blaze_util::StringPrintf(&verify_command, "zip -Tv %s", zip_path.c_str());
-    return system(verify_command.c_str());
-  }
-
-  static void GetEntryContents(const std::string &zip_path,
-                               const char *entry_name, std::string *contents) {
-    contents->clear();
-    std::string command;
-    blaze_util::StringPrintf(&command, "unzip -p %s %s", zip_path.c_str(),
-                             entry_name);
-    FILE *fp = popen(command.c_str(), "r");
-    ASSERT_NE(nullptr, fp);
-    char buf[1024];
-    while (fgets(buf, sizeof(buf), fp)) {
-      contents->append(buf);
-    }
-    ASSERT_NE(0, feof(fp));
-    ASSERT_EQ(0, ferror(fp));
-    ASSERT_EQ(0, pclose(fp));
+    EXPECT_EQ(0, singlejar_test_util::VerifyZip(out_path));
   }
 
   OutputJar output_jar_;
@@ -99,10 +67,10 @@
 
 // No inputs at all.
 TEST_F(OutputJarSimpleTest, Empty) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, nullptr);
   InputJar input_jar;
-  ASSERT_TRUE(input_jar.Open(out_path.c_str()));
+  ASSERT_TRUE(input_jar.Open(out_path));
   const LH *lh;
   const CDH *cdh;
   while ((cdh = input_jar.NextEntry(&lh))) {
@@ -118,26 +86,26 @@
     }
   }
   input_jar.Close();
-  std::string manifest;
-  GetEntryContents(out_path, "META-INF/MANIFEST.MF", &manifest);
+  std::string manifest =
+      singlejar_test_util::GetEntryContents(out_path, "META-INF/MANIFEST.MF");
   EXPECT_EQ(
       "Manifest-Version: 1.0\r\n"
       "Created-By: singlejar\r\n"
       "\r\n",
       manifest);
-  std::string build_properties;
-  GetEntryContents(out_path, "build-data.properties", &build_properties);
+  std::string build_properties =
+      singlejar_test_util::GetEntryContents(out_path, "build-data.properties");
   EXPECT_PRED2(HasSubstr, build_properties, "build.target=");
 }
 
 // Source jars.
 TEST_F(OutputJarSimpleTest, Source) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--sources",
                DATA_DIR_TOP "src/tools/singlejar/libtest1.jar",
                DATA_DIR_TOP "src/tools/singlejar/libtest2.jar", nullptr);
   InputJar input_jar;
-  ASSERT_TRUE(input_jar.Open(out_path.c_str()));
+  ASSERT_TRUE(input_jar.Open(out_path));
   const LH *lh;
   const CDH *cdh;
   while ((cdh = input_jar.NextEntry(&lh))) {
@@ -157,7 +125,7 @@
 
 // Verify --java_launcher argument
 TEST_F(OutputJarSimpleTest, JavaLauncher) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   const char *launcher_path = DATA_DIR_TOP "src/tools/singlejar/libtest1.jar";
   CreateOutput(out_path, "--java_launcher", launcher_path, nullptr);
   // check that the offset of the first entry equals launcher size.
@@ -177,10 +145,10 @@
 
 // --main_class option.
 TEST_F(OutputJarSimpleTest, MainClass) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--main_class", "com.google.my.Main", nullptr);
-  std::string manifest;
-  GetEntryContents(out_path, "META-INF/MANIFEST.MF", &manifest);
+  std::string manifest =
+      singlejar_test_util::GetEntryContents(out_path, "META-INF/MANIFEST.MF");
   EXPECT_EQ(
       "Manifest-Version: 1.0\r\n"
       "Created-By: singlejar\r\n"
@@ -191,11 +159,11 @@
 
 // --deploy_manifest_lines option.
 TEST_F(OutputJarSimpleTest, DeployManifestLines) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--deploy_manifest_lines", "property1: foo",
                "property2: bar", nullptr);
-  std::string manifest;
-  GetEntryContents(out_path, "META-INF/MANIFEST.MF", &manifest);
+  std::string manifest =
+      singlejar_test_util::GetEntryContents(out_path, "META-INF/MANIFEST.MF");
   EXPECT_EQ(
       "Manifest-Version: 1.0\r\n"
       "Created-By: singlejar\r\n"
@@ -207,29 +175,31 @@
 
 // --extra_build_info option
 TEST_F(OutputJarSimpleTest, ExtraBuildInfo) {
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--extra_build_info", "property1=value1",
                "--extra_build_info", "property2=value2", nullptr);
-  std::string build_properties;
-  GetEntryContents(out_path, "build-data.properties", &build_properties);
+  std::string build_properties =
+      singlejar_test_util::GetEntryContents(out_path, "build-data.properties");
   EXPECT_PRED2(HasSubstr, build_properties, "\nproperty1=value1\n");
   EXPECT_PRED2(HasSubstr, build_properties, "\nproperty2=value2\n");
 }
 
 // --build_info_file and --extra_build_info options.
 TEST_F(OutputJarSimpleTest, BuildInfoFile) {
-  std::string build_info_path1 = OutputFilePath("buildinfo1");
+  std::string build_info_path1 =
+      singlejar_test_util::OutputFilePath("buildinfo1");
   ASSERT_TRUE(blaze::WriteFile("property11=value11\nproperty12=value12\n",
                                build_info_path1));
-  std::string build_info_path2 = OutputFilePath("buildinfo2");
+  std::string build_info_path2 =
+      singlejar_test_util::OutputFilePath("buildinfo2");
   ASSERT_TRUE(blaze::WriteFile("property21=value21\nproperty22=value22\n",
                                build_info_path2));
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--build_info_file", build_info_path1.c_str(),
                "--extra_build_info", "property=value", "--build_info_file",
                build_info_path2.c_str(), nullptr);
-  std::string build_properties;
-  GetEntryContents(out_path, "build-data.properties", &build_properties);
+  std::string build_properties =
+      singlejar_test_util::GetEntryContents(out_path, "build-data.properties");
   EXPECT_PRED2(HasSubstr, build_properties, "property11=value11\n");
   EXPECT_PRED2(HasSubstr, build_properties, "property12=value12\n");
   EXPECT_PRED2(HasSubstr, build_properties, "property21=value21\n");
@@ -239,68 +209,64 @@
 
 // --resources option.
 TEST_F(OutputJarSimpleTest, Resources) {
-  std::string res11_path = OutputFilePath("res11");
+  std::string res11_path = singlejar_test_util::OutputFilePath("res11");
   std::string res11_spec = std::string("res1:") + res11_path;
   ASSERT_TRUE(blaze::WriteFile("res11.line1\nres11.line2\n", res11_path));
 
-  std::string res12_path = OutputFilePath("res12");
+  std::string res12_path = singlejar_test_util::OutputFilePath("res12");
   std::string res12_spec = std::string("res1:") + res12_path;
   ASSERT_TRUE(blaze::WriteFile("res12.line1\nres12.line2\n", res12_path));
 
-  std::string res2_path = OutputFilePath("res2");
+  std::string res2_path = singlejar_test_util::OutputFilePath("res2");
   ASSERT_TRUE(blaze::WriteFile("res2.line1\nres2.line2\n", res2_path));
 
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--resources", res11_spec.c_str(), res12_spec.c_str(),
                res2_path.c_str(), nullptr);
 
   // The output should have 'res1' entry containing the concatenation of the
   // 'res11' and 'res12' files.
-  std::string res1;
-  GetEntryContents(out_path, "res1", &res1);
+  std::string res1 = singlejar_test_util::GetEntryContents(out_path, "res1");
   EXPECT_EQ("res11.line1\nres11.line2\nres12.line1\nres12.line2\n", res1);
 
   // The output should have res2 path entry and contents.
-  std::string res2;
-  GetEntryContents(out_path, res2_path.c_str(), &res2);
+  std::string res2 = singlejar_test_util::GetEntryContents(out_path, res2_path);
   EXPECT_EQ("res2.line1\nres2.line2\n", res2);
 }
 
 // --classpath_resources
 TEST_F(OutputJarSimpleTest, ClasspathResources) {
-  std::string res1_path = OutputFilePath("cp_res");
+  std::string res1_path = singlejar_test_util::OutputFilePath("cp_res");
   ASSERT_TRUE(blaze::WriteFile("line1\nline2\n", res1_path));
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--classpath_resources", res1_path.c_str(), nullptr);
-  std::string res;
-  GetEntryContents(out_path, "cp_res", &res);
+  std::string res = singlejar_test_util::GetEntryContents(out_path, "cp_res");
   EXPECT_EQ("line1\nline2\n", res);
 }
 
 // Duplicate entries for --resources or --classpath_resources
 TEST_F(OutputJarSimpleTest, DuplicateResources) {
-  std::string cp_res_path = OutputFilePath("cp_res");
+  std::string cp_res_path = singlejar_test_util::OutputFilePath("cp_res");
   ASSERT_TRUE(blaze::WriteFile("line1\nline2\n", cp_res_path));
 
-  std::string res1_path = OutputFilePath("res1");
+  std::string res1_path = singlejar_test_util::OutputFilePath("res1");
   std::string res1_spec = "foo:" + res1_path;
   ASSERT_TRUE(blaze::WriteFile("resline1\nresline2\n", res1_path));
 
-  std::string res2_path = OutputFilePath("res2");
+  std::string res2_path = singlejar_test_util::OutputFilePath("res2");
   std::string res2_spec = "foo:" + res2_path;
   ASSERT_TRUE(blaze::WriteFile("line3\nline4\n", res2_path));
 
-  std::string out_path = OutputFilePath("out.jar");
+  std::string out_path = singlejar_test_util::OutputFilePath("out.jar");
   CreateOutput(out_path, "--warn_duplicate_resources", "--resources",
                res1_spec.c_str(), res2_spec.c_str(), "--classpath_resources",
                cp_res_path.c_str(), cp_res_path.c_str(), nullptr);
 
-  std::string cp_res;
-  GetEntryContents(out_path, "cp_res", &cp_res);
+  std::string cp_res =
+      singlejar_test_util::GetEntryContents(out_path, "cp_res");
   EXPECT_EQ("line1\nline2\n", cp_res);
 
-  std::string foo;
-  GetEntryContents(out_path, "foo", &foo);
+  std::string foo = singlejar_test_util::GetEntryContents(out_path, "foo");
   EXPECT_EQ("resline1\nresline2\n", foo);
 }
 
diff --git a/src/tools/singlejar/test_util.cc b/src/tools/singlejar/test_util.cc
new file mode 100644
index 0000000..1c31259
--- /dev/null
+++ b/src/tools/singlejar/test_util.cc
@@ -0,0 +1,108 @@
+// Copyright 2016 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.
+#include "src/tools/singlejar/test_util.h"
+
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include <string>
+
+#include "src/main/cpp/blaze_util.h"
+#include "src/main/cpp/util/file.h"
+#include "src/main/cpp/util/strings.h"
+
+#include "gtest/gtest.h"
+
+namespace singlejar_test_util {
+
+bool AllocateFile(const std::string &name, size_t size) {
+  int fd = open(name.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0777);
+  if (fd < 0) {
+    perror(name.c_str());
+    return false;
+  }
+  if (size) {
+    if (ftruncate(fd, size) == 0) {
+      return close(fd) == 0;
+    } else {
+      auto last_error = errno;
+      close(fd);
+      errno = last_error;
+      return false;
+    }
+  } else {
+    return close(fd) == 0;
+  }
+}
+
+int RunCommand(const char *cmd, ...) {
+  std::string args_string(cmd);
+  va_list ap;
+  va_start(ap, cmd);
+  for (const char *arg = va_arg(ap, const char *); arg;
+       arg = va_arg(ap, const char *)) {
+    args_string += ' ';
+    args_string += arg;
+  }
+  va_end(ap);
+  fprintf(stderr, "Arguments: %s\n", args_string.c_str());
+  return system(args_string.c_str());
+}
+
+// List zip file contents.
+void LsZip(const char *zip_name) {
+#if !defined(__APPLE__)
+  std::string command = (std::string("unzip -v ") + zip_name).c_str();
+  system(command.c_str());
+#endif
+}
+
+std::string OutputFilePath(const std::string &relpath) {
+  const char *out_dir = getenv("TEST_TMPDIR");
+  return blaze_util::JoinPath((nullptr == out_dir) ? "." : out_dir,
+                              relpath.c_str());
+}
+
+int VerifyZip(const std::string &zip_path) {
+  std::string verify_command;
+  blaze_util::StringPrintf(&verify_command, "zip -Tv %s", zip_path.c_str());
+  return system(verify_command.c_str());
+}
+
+std::string GetEntryContents(const std::string &zip_path,
+                             const std::string &entry_name) {
+  std::string contents;
+  std::string command;
+  blaze_util::StringPrintf(&command, "unzip -p %s %s", zip_path.c_str(),
+                           entry_name.c_str());
+  FILE *fp = popen(command.c_str(), "r");
+  if (!fp) {
+    ADD_FAILURE() << "Command " << command << " failed.";
+    return std::string("");
+  }
+
+  char buf[1024];
+  while (fgets(buf, sizeof(buf), fp)) {
+    contents.append(buf);
+  }
+  if (feof(fp) && !ferror(fp) && !pclose(fp)) {
+    return contents;
+  }
+  ADD_FAILURE() << "Command " << command << " failed on close.";
+  return std::string("");
+}
+
+}  // namespace singlejar_test_util
diff --git a/src/tools/singlejar/test_util.h b/src/tools/singlejar/test_util.h
index 853455e..0a32705 100644
--- a/src/tools/singlejar/test_util.h
+++ b/src/tools/singlejar/test_util.h
@@ -14,61 +14,34 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdlib.h>
 #include <unistd.h>
-
 #include <string>
 
-class TestUtil {
- public:
-  // Allocate a file with given name and size. The contents is zeroes.
-  static bool AllocateFile(const char *name, size_t size) {
-    int fd = open(name, O_CREAT | O_RDWR | O_TRUNC, 0777);
-    if (fd < 0) {
-      perror(name);
-      return false;
-    }
-    if (size) {
-      if (ftruncate(fd, size) == 0) {
-        return close(fd) == 0;
-      } else {
-        auto last_error = errno;
-        close(fd);
-        errno = last_error;
-        return false;
-      }
-    } else {
-      return close(fd) == 0;
-    }
-  }
+namespace singlejar_test_util {
+
+// Allocate a file with given name and size. The contents is zeroes.
+  bool AllocateFile(const std::string& name, size_t size);
 
   // Combine the passed arguments to a shell command and run it.
   // E.g. calling RunCommand("cmd", "arg1", "arg2", nullptr) results in
   // running 'cmd arg1 arg2'.
   // Returns command's return code.
-  static int RunCommand(const char *cmd, ...) {
-    std::string args_string(cmd);
-    va_list ap;
-    va_start(ap, cmd);
-    for (const char *arg = va_arg(ap, const char *); arg;
-         arg = va_arg(ap, const char *)) {
-      args_string += ' ';
-      args_string += arg;
-    }
-    va_end(ap);
-    fprintf(stderr, "Arguments: %s\n", args_string.c_str());
-    return system(args_string.c_str());
-  }
+  int RunCommand(const char *cmd, ...);
 
   // List zip file contents.
-  static void LsZip(const char *zip_name) {
-#if !defined(__APPLE__)
-    std::string command = (std::string("unzip -v ") + zip_name).c_str();
-    system(command.c_str());
-#endif
-  }
-};
+  void LsZip(const char *zip_name);
+
+  // Return the full path to a file in a temporary directory.
+  std::string OutputFilePath(const std::string& relpath);
+
+  // Verify given archive contents by running 'zip -Tv' on it,
+  // returning its exit code (0 means success). Diagnostics goes
+  // tp stdout/stderr.
+  int VerifyZip(const std::string& zip_path);
+
+  // Read the contents of the given archive entry and return it as string.
+  std::string GetEntryContents(const std::string &zip_path,
+                        const std::string& entry_name);
+
+}  // namespace singlejar_test_util
 #endif  //  SRC_TOOLS_SINGLEJAR_TEST_UTIL_H_
diff --git a/src/tools/singlejar/token_stream_test.cc b/src/tools/singlejar/token_stream_test.cc
index 8a0742c..6d146cf 100644
--- a/src/tools/singlejar/token_stream_test.cc
+++ b/src/tools/singlejar/token_stream_test.cc
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string>
 
+#include "src/tools/singlejar/test_util.h"
 #include "src/tools/singlejar/token_stream.h"
 #include "gtest/gtest.h"
 
@@ -34,11 +35,8 @@
     "\\jkl", "\\xyz", "\"0", "continue", "x",
 };
 
-class TokenStreamTest : public testing::Test {
-};
-
 // Simple '-foo -bar' command line.
-TEST_F(TokenStreamTest, SimpleArgs) {
+TEST(TokenStreamTest, SimpleArgs) {
   const char *args[] = {"-foo", "-bar"};
   ArgTokenStream token_stream(ARRAY_SIZE(args), args);
   EXPECT_EQ("-foo", token_stream.token());
@@ -53,18 +51,18 @@
 }
 
 // '-foo @commandfile -bar' command line.
-TEST_F(TokenStreamTest, CommandFile) {
+TEST(TokenStreamTest, CommandFile) {
   const char *tempdir = getenv("TEST_TMPDIR");
   ASSERT_NE(nullptr, tempdir);
-  std::string command_file_path_ = std::string(tempdir) + "/tokens";
-  FILE *fp = fopen(command_file_path_.c_str(), "w");
+  std::string command_file_path = singlejar_test_util::OutputFilePath("tokens");
+  FILE *fp = fopen(command_file_path.c_str(), "w");
   ASSERT_NE(nullptr, fp);
   for (size_t i = 0; i < ARRAY_SIZE(lines); ++i) {
     fprintf(fp, "%s\n", lines[i]);
   }
   fclose(fp);
 
-  std::string command_file_arg = std::string("@") + command_file_path_;
+  std::string command_file_arg = std::string("@") + command_file_path;
   const char *args[] = {"-before_file", "", "-after_file"};
   args[1] = command_file_arg.c_str();
   ArgTokenStream token_stream(ARRAY_SIZE(args), args);
@@ -82,7 +80,7 @@
 }
 
 // '--arg1 optval1 --arg2' command line.
-TEST_F(TokenStreamTest, OptargOne) {
+TEST(TokenStreamTest, OptargOne) {
   const char *args[] = {"--arg1", "optval1", "--arg2", "--arg3", "optval3"};
   ArgTokenStream token_stream(ARRAY_SIZE(args), args);
   std::string optval;
@@ -98,7 +96,7 @@
 }
 
 // '--arg1 value1 value2 --arg2' command line.
-TEST_F(TokenStreamTest, OptargMulti) {
+TEST(TokenStreamTest, OptargMulti) {
   const char *args[] = {"--arg1", "value11", "value12",
                         "--arg2", "value21", "value22"};
   ArgTokenStream token_stream(ARRAY_SIZE(args), args);
diff --git a/src/tools/singlejar/transient_bytes_test.cc b/src/tools/singlejar/transient_bytes_test.cc
index 50bde41..11719ff 100644
--- a/src/tools/singlejar/transient_bytes_test.cc
+++ b/src/tools/singlejar/transient_bytes_test.cc
@@ -100,9 +100,9 @@
   }
 
   static void CreateStoredJar() {
-    ASSERT_TRUE(TestUtil::AllocateFile("small1", 100));
-    ASSERT_TRUE(TestUtil::AllocateFile("huge", 0x100000001));
-    ASSERT_TRUE(TestUtil::AllocateFile("small2", 100));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile("small1", 100));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile("huge", 0x100000001));
+    ASSERT_TRUE(singlejar_test_util::AllocateFile("small2", 100));
     unlink(kStoredJar);
     ASSERT_EQ(0, system("zip -0qm stored.zip small1 huge small2"));
 #if !defined(__APPLE__)
diff --git a/src/tools/singlejar/zlib_interface_test.cc b/src/tools/singlejar/zlib_interface_test.cc
index 802d153..02c544a 100644
--- a/src/tools/singlejar/zlib_interface_test.cc
+++ b/src/tools/singlejar/zlib_interface_test.cc
@@ -12,88 +12,82 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include <memory>
-
 #include "src/tools/singlejar/zlib_interface.h"
 
 #include "gtest/gtest.h"
 
 namespace {
 
-class ZlibInterfaceTest : public ::testing::Test {
- protected:
-  void SetUp() override {
-    inflater_.reset(new Inflater);
-    deflater_.reset(new Deflater);
-  }
-
-  std::unique_ptr<Inflater> inflater_;
-  std::unique_ptr<Deflater> deflater_;
-};
-
 static const uint8_t bytes[] = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4};
 
-TEST_F(ZlibInterfaceTest, DeflateFully) {
+TEST(ZlibInterfaceTest, DeflateFully) {
+  Deflater deflater;
   uint8_t compressed[256];
-  deflater_.get()->next_out = compressed;
-  deflater_.get()->avail_out = sizeof(compressed);
-  EXPECT_EQ(Z_STREAM_END, deflater_->Deflate(bytes, sizeof(bytes), Z_FINISH));
+  deflater.next_out = compressed;
+  deflater.avail_out = sizeof(compressed);
+  EXPECT_EQ(Z_STREAM_END, deflater.Deflate(bytes, sizeof(bytes), Z_FINISH));
 }
 
-TEST_F(ZlibInterfaceTest, DeflateIntoChunks) {
+TEST(ZlibInterfaceTest, DeflateIntoChunks) {
+  Deflater deflater;
   uint8_t compressed[256];
-  deflater_.get()->next_out = compressed;
-  deflater_.get()->avail_out = 2;
-  EXPECT_EQ(Z_OK, deflater_->Deflate(bytes, sizeof(bytes), Z_FINISH));
-  EXPECT_EQ(0, deflater_.get()->avail_out);
-  deflater_.get()->next_out = compressed + 2;
-  deflater_.get()->avail_out = sizeof(compressed) - 2;
+  deflater.next_out = compressed;
+  deflater.avail_out = 2;
+  EXPECT_EQ(Z_OK, deflater.Deflate(bytes, sizeof(bytes), Z_FINISH));
+  EXPECT_EQ(0, deflater.avail_out);
+  deflater.next_out = compressed + 2;
+  deflater.avail_out = sizeof(compressed) - 2;
   EXPECT_EQ(Z_STREAM_END,
-            deflater_->Deflate(deflater_.get()->next_in,
-                               deflater_.get()->avail_in, Z_FINISH));
+            deflater.Deflate(deflater.next_in,
+                               deflater.avail_in, Z_FINISH));
 }
 
-TEST_F(ZlibInterfaceTest, DeflateChunks) {
+TEST(ZlibInterfaceTest, DeflateChunks) {
+  Deflater deflater;
   uint8_t compressed[256];
-  deflater_.get()->next_out = compressed;
-  deflater_.get()->avail_out = sizeof(compressed);
-  EXPECT_EQ(Z_OK, deflater_->Deflate(bytes, 4, Z_NO_FLUSH));
+  deflater.next_out = compressed;
+  deflater.avail_out = sizeof(compressed);
+  EXPECT_EQ(Z_OK, deflater.Deflate(bytes, 4, Z_NO_FLUSH));
   EXPECT_EQ(Z_STREAM_END,
-            deflater_->Deflate(bytes + 4, sizeof(bytes) - 4, Z_FINISH));
+            deflater.Deflate(bytes + 4, sizeof(bytes) - 4, Z_FINISH));
 }
 
-TEST_F(ZlibInterfaceTest, InflateFully) {
+TEST(ZlibInterfaceTest, InflateFully) {
   uint8_t compressed[256];
-  deflater_.get()->next_out = compressed;
-  deflater_.get()->avail_out = sizeof(compressed);
-  EXPECT_EQ(Z_STREAM_END, deflater_->Deflate(bytes, sizeof(bytes), Z_FINISH));
+  Deflater deflater;
+  deflater.next_out = compressed;
+  deflater.avail_out = sizeof(compressed);
+  EXPECT_EQ(Z_STREAM_END, deflater.Deflate(bytes, sizeof(bytes), Z_FINISH));
 
   // Now we have deflated data, inflate it back and compare.
-  size_t compressed_size = sizeof(compressed) - deflater_.get()->avail_out;
-  inflater_->DataToInflate(compressed, compressed_size);
+  size_t compressed_size = sizeof(compressed) - deflater.avail_out;
+  Inflater inflater;
+  inflater.DataToInflate(compressed, compressed_size);
 
   uint8_t uncompressed[256];
   memset(uncompressed, 0, sizeof(uncompressed));
   EXPECT_EQ(Z_STREAM_END,
-            inflater_->Inflate(uncompressed, sizeof(uncompressed)));
-  EXPECT_EQ(sizeof(bytes), sizeof(uncompressed) - inflater_->available_out());
+            inflater.Inflate(uncompressed, sizeof(uncompressed)));
+  EXPECT_EQ(sizeof(bytes), sizeof(uncompressed) - inflater.available_out());
   EXPECT_EQ(0, memcmp(bytes, uncompressed, sizeof(bytes)));
 }
 
-TEST_F(ZlibInterfaceTest, InflateToChunks) {
+TEST(ZlibInterfaceTest, InflateToChunks) {
   uint8_t compressed[256];
-  deflater_.get()->next_out = compressed;
-  deflater_.get()->avail_out = sizeof(compressed);
-  EXPECT_EQ(Z_STREAM_END, deflater_->Deflate(bytes, sizeof(bytes), Z_FINISH));
+  Deflater deflater;
+  deflater.next_out = compressed;
+  deflater.avail_out = sizeof(compressed);
+  EXPECT_EQ(Z_STREAM_END, deflater.Deflate(bytes, sizeof(bytes), Z_FINISH));
 
   // Now we have deflated data, inflate it back and compare.
-  size_t compressed_size = sizeof(compressed) - deflater_.get()->avail_out;
-  inflater_->DataToInflate(compressed, compressed_size);
+  size_t compressed_size = sizeof(compressed) - deflater.avail_out;
+  Inflater inflater;
+  inflater.DataToInflate(compressed, compressed_size);
   uint8_t uncompressed[256];
   memset(uncompressed, 0, sizeof(uncompressed));
-  EXPECT_EQ(Z_OK, inflater_->Inflate(uncompressed, 3));
+  EXPECT_EQ(Z_OK, inflater.Inflate(uncompressed, 3));
   EXPECT_EQ(Z_STREAM_END,
-            inflater_->Inflate(uncompressed + 3, sizeof(uncompressed) - 3));
+            inflater.Inflate(uncompressed + 3, sizeof(uncompressed) - 3));
   EXPECT_EQ(0, memcmp(bytes, uncompressed, sizeof(bytes)));
 }