summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:26:53 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:26:53 +0000
commit7236d3a53cbef9a6b057da43f8de7b555bdf3007 (patch)
tree979158939e93d02e955246282be44c8e8deac1ba
parent786c692c37099c20c5c2331c594c25dcea3abec5 (diff)
parent7eae4114c5b03eb4b991167a2eacabf021f50441 (diff)
downloadgtest_extras-7236d3a53cbef9a6b057da43f8de7b555bdf3007.tar.gz
Change-Id: I07c132c48908d1dca5314d86ea6c0c496006d43a
-rw-r--r--Android.bp31
-rw-r--r--Isolate.cpp8
-rw-r--r--Isolate.h4
-rw-r--r--IsolateMain.cpp21
-rw-r--r--Options.cpp131
-rw-r--r--Options.h6
-rw-r--r--TEST_MAPPING7
-rw-r--r--Test.cpp86
-rw-r--r--Test.h4
-rw-r--r--tests/OptionsTest.cpp564
-rw-r--r--tests/SystemTests.cpp620
11 files changed, 682 insertions, 800 deletions
diff --git a/Android.bp b/Android.bp
index e339a4f..b0f9456 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library_static {
+cc_library {
name: "libgtest_isolated",
host_supported: true,
cflags: ["-Wall", "-Werror"],
@@ -27,22 +27,17 @@ cc_library_static {
"Test.cpp",
],
- // NOTE: libbase is re-exported by including them below.
- // When Soong supports transitive static dependency includes, this
- // library can be removed.
+ // NOTE: libbase and liblog are re-exported by including them below.
+ // When Soong supports transitive static dependency includes, these
+ // libraries can be removed.
whole_static_libs: [
"libbase",
"libgtest",
- ],
-
- // Add liblog as a shared library so that gtests can override liblog
- // functions without getting duplicate symbols.
- shared_libs: [
"liblog",
],
}
-cc_library_static {
+cc_library {
name: "libgtest_isolated_main",
host_supported: true,
cflags: ["-Wall", "-Werror"],
@@ -53,12 +48,6 @@ cc_library_static {
whole_static_libs: [
"libgtest_isolated",
],
-
- // Add liblog as a shared library so that gtests can override liblog
- // functions without getting duplicate symbols.
- shared_libs: [
- "liblog",
- ],
}
cc_test {
@@ -70,14 +59,6 @@ cc_test {
],
cflags: ["-Wall", "-Werror"],
- shared_libs: [
- "libbase",
- "liblog",
- ],
- static_libs: [
- "libgmock",
- ],
+ shared_libs: ["libbase"],
whole_static_libs: ["libgtest_isolated_main"],
-
- test_suites: ["device-tests"],
}
diff --git a/Isolate.cpp b/Isolate.cpp
index 756f194..7782042 100644
--- a/Isolate.cpp
+++ b/Isolate.cpp
@@ -176,14 +176,14 @@ int Isolate::ChildProcessFn(const std::tuple<std::string, std::string>& test) {
unsetenv("GTEST_FILTER");
// Add the filter argument.
- std::vector<char*> args(child_args_);
+ std::vector<const char*> args(child_args_);
std::string filter("--gtest_filter=" + GetTestName(test));
- args.push_back(strdup(filter.c_str()));
+ args.push_back(filter.c_str());
int argc = args.size();
// Add the null terminator.
args.push_back(nullptr);
- ::testing::InitGoogleTest(&argc, args.data());
+ ::testing::InitGoogleTest(&argc, const_cast<char**>(args.data()));
return RUN_ALL_TESTS();
}
@@ -301,7 +301,7 @@ size_t Isolate::CheckTestsFinished() {
}
}
- test->Print();
+ test->Print(options_.gtest_format());
switch (test->result()) {
case TEST_PASS:
diff --git a/Isolate.h b/Isolate.h
index 5919c66..aca409d 100644
--- a/Isolate.h
+++ b/Isolate.h
@@ -37,7 +37,7 @@ namespace gtest_extras {
class Isolate {
public:
- Isolate(const Options& options, const std::vector<char*>& child_args)
+ Isolate(const Options& options, const std::vector<const char*>& child_args)
: options_(options), child_args_(child_args) {}
void EnumerateTests();
@@ -79,7 +79,7 @@ class Isolate {
}
const Options& options_;
- const std::vector<char*>& child_args_;
+ const std::vector<const char*>& child_args_;
size_t total_suites_ = 0;
size_t total_tests_ = 0;
diff --git a/IsolateMain.cpp b/IsolateMain.cpp
index 30b871b..b25fc9c 100644
--- a/IsolateMain.cpp
+++ b/IsolateMain.cpp
@@ -59,6 +59,11 @@ static void PrintHelpInfo() {
printf(
" will be called slow.\n"
" Only valid in isolation mode. Default slow threshold is 2000 ms.\n");
+ ColoredPrintf(COLOR_GREEN, " --gtest_format\n");
+ printf(
+ " Use the default gtest format, not the enhanced format.\n"
+ "\n"
+ "Default test option is ");
ColoredPrintf(COLOR_GREEN, "-j");
printf(
".\n"
@@ -134,7 +139,19 @@ int IsolateMain(int argc, char** argv, char**) {
args.insert(args.begin() + 1, initial_args.begin(), initial_args.end());
}
- std::vector<char*> child_args;
+ // To run a DeathTest in threadsafe mode, gtest requires that the user must
+ // invoke the test program directly, not by running it from the path.
+ // This is because gtest uses clone() + execve() to run a DeathTest() and
+ // execve() doesn't search the path to execute.
+ std::vector<const char*> child_args;
+ std::string exec_path; // Need to be scoped through the entire function.
+ if (strchr(args[0], '/') == nullptr) {
+ exec_path = android::base::GetExecutablePath();
+ child_args.push_back(exec_path.c_str());
+ } else {
+ child_args.push_back(args[0]);
+ }
+
android::gtest_extras::Options options;
if (!options.Process(args, &child_args)) {
return 1;
@@ -142,7 +159,7 @@ int IsolateMain(int argc, char** argv, char**) {
// Add the --no_isolate option to force child processes not to rerun
// in isolation mode.
- child_args.push_back(strdup("--no_isolate"));
+ child_args.push_back("--no_isolate");
// Set the flag values.
::testing::GTEST_FLAG(color) = options.color();
diff --git a/Options.cpp b/Options.cpp
index bcc4b06..0b2ba51 100644
--- a/Options.cpp
+++ b/Options.cpp
@@ -26,9 +26,7 @@
#include <unordered_map>
#include <vector>
-#include <android-base/file.h>
#include <android-base/parseint.h>
-#include <android-base/strings.h>
#include <gtest/gtest.h>
#include "Options.h"
@@ -45,9 +43,10 @@ constexpr uint64_t kDefaultSlowThresholdMs = 2000;
const std::unordered_map<std::string, Options::ArgInfo> Options::kArgs = {
{"deadline_threshold_ms", {FLAG_REQUIRES_VALUE, &Options::SetNumeric}},
{"slow_threshold_ms", {FLAG_REQUIRES_VALUE, &Options::SetNumeric}},
+ {"gtest_format", {FLAG_NONE, &Options::SetBool}},
+ {"no_gtest_format", {FLAG_NONE, &Options::SetBool}},
{"gtest_list_tests", {FLAG_NONE, &Options::SetBool}},
{"gtest_filter", {FLAG_ENVIRONMENT_VARIABLE | FLAG_REQUIRES_VALUE, &Options::SetString}},
- {"gtest_flagfile", {FLAG_REQUIRES_VALUE, &Options::SetString}},
{
"gtest_repeat",
{FLAG_ENVIRONMENT_VARIABLE | FLAG_REQUIRES_VALUE, &Options::SetIterations},
@@ -72,8 +71,6 @@ const std::unordered_map<std::string, Options::ArgInfo> Options::kArgs = {
{FLAG_ENVIRONMENT_VARIABLE | FLAG_REQUIRES_VALUE, &Options::SetNumericEnvOnly}},
{"gtest_total_shards",
{FLAG_ENVIRONMENT_VARIABLE | FLAG_REQUIRES_VALUE, &Options::SetNumericEnvOnly}},
- // This does nothing, only added so that passing this option does not exit.
- {"gtest_format", {FLAG_NONE, &Options::SetBool}},
};
static void PrintError(const std::string& arg, std::string msg, bool from_env) {
@@ -214,84 +211,7 @@ bool Options::HandleArg(const std::string& arg, const std::string& value, const
return true;
}
-bool Options::ProcessFlagfile(const std::string& file, std::vector<char*>* child_args) {
- std::string contents;
- if (!android::base::ReadFileToString(file, &contents)) {
- printf("Unable to read data from file %s\n", file.c_str());
- return false;
- }
-
- size_t idx = 0;
- while (idx < contents.size()) {
- size_t newline_idx = contents.find('\n', idx);
- if (newline_idx == std::string::npos) {
- newline_idx = contents.size();
- }
- std::string line(&contents[idx], newline_idx - idx);
- idx = newline_idx + 1;
- line = android::base::Trim(line);
- if (line.empty()) {
- // Skip lines with only whitespace.
- continue;
- }
- if (!ProcessSingle(line.c_str(), child_args, false)) {
- return false;
- }
- }
- return true;
-}
-
-bool Options::ProcessSingle(const char* arg, std::vector<char*>* child_args, bool allow_flagfile) {
- if (strncmp("--", arg, 2) != 0) {
- if (arg[0] == '-') {
- printf("Unknown argument: %s\n", arg);
- return false;
- } else {
- printf("Unexpected argument '%s'\n", arg);
- return false;
- }
- }
-
- // See if this is a name=value argument.
- std::string name;
- std::string value;
- const char* equal = strchr(arg, '=');
- if (equal != nullptr) {
- name = std::string(&arg[2], static_cast<size_t>(equal - arg) - 2);
- value = equal + 1;
- } else {
- name = &arg[2];
- }
- auto entry = kArgs.find(name);
- if (entry == kArgs.end()) {
- printf("Unknown argument: %s\n", arg);
- return false;
- }
-
- if (entry->second.flags & FLAG_CHILD) {
- child_args->push_back(strdup(arg));
- }
-
- if (!HandleArg(name, value, entry->second)) {
- return false;
- }
-
- // Special case, if gtest_flagfile is set, then we need to read the
- // file and treat each line as a flag.
- if (name == "gtest_flagfile") {
- if (!allow_flagfile) {
- printf("Argument: %s is not allowed in flag file.\n", arg);
- return false;
- }
- if (!ProcessFlagfile(value, child_args)) {
- return false;
- }
- }
-
- return true;
-}
-
-bool Options::Process(const std::vector<const char*>& args, std::vector<char*>* child_args) {
+bool Options::Process(const std::vector<const char*>& args, std::vector<const char*>* child_args) {
// Initialize the variables.
job_count_ = static_cast<size_t>(sysconf(_SC_NPROCESSORS_ONLN));
num_iterations_ = ::testing::GTEST_FLAG(repeat);
@@ -304,14 +224,14 @@ bool Options::Process(const std::vector<const char*>& args, std::vector<char*>*
strings_["gtest_color"] = ::testing::GTEST_FLAG(color);
strings_["xml_file"] = ::testing::GTEST_FLAG(output);
strings_["gtest_filter"] = "";
- strings_["gtest_flagfile"] = "";
bools_.clear();
bools_["gtest_print_time"] = ::testing::GTEST_FLAG(print_time);
+ bools_["gtest_format"] = true;
+ bools_["no_gtest_format"] = false;
bools_["gtest_also_run_disabled_tests"] = ::testing::GTEST_FLAG(also_run_disabled_tests);
bools_["gtest_list_tests"] = false;
- // This does nothing, only added so that passing this option does not exit.
- bools_["gtest_format"] = true;
+ child_args->clear();
// Loop through all of the possible environment variables.
for (const auto& entry : kArgs) {
@@ -330,12 +250,11 @@ bool Options::Process(const std::vector<const char*>& args, std::vector<char*>*
}
}
- child_args->push_back(strdup(args[0]));
+ child_args->push_back(args[0]);
// Assumes the first value is not an argument, so skip it.
for (size_t i = 1; i < args.size(); i++) {
- // Special handle of -j or -jXX. This flag is not allowed to be present
- // in a --gtest_flagfile.
+ // Special handle of -j or -jXX.
if (strncmp(args[i], "-j", 2) == 0) {
const char* value = &args[i][2];
if (*value == '\0') {
@@ -350,13 +269,43 @@ bool Options::Process(const std::vector<const char*>& args, std::vector<char*>*
if (!GetNumeric<size_t>("-j", value, &job_count_, false)) {
return false;
}
- } else {
- if (!ProcessSingle(args[i], child_args, true)) {
+ } else if (strncmp("--", args[i], 2) == 0) {
+ // See if this is a name=value argument.
+ std::string name;
+ std::string value;
+ const char* equal = strchr(args[i], '=');
+ if (equal != nullptr) {
+ name = std::string(&args[i][2], static_cast<size_t>(equal - args[i]) - 2);
+ value = equal + 1;
+ } else {
+ name = args[i] + 2;
+ }
+ auto entry = kArgs.find(name);
+ if (entry == kArgs.end()) {
+ printf("Unknown argument: %s\n", args[i]);
+ return false;
+ }
+
+ if (entry->second.flags & FLAG_CHILD) {
+ child_args->push_back(args[i]);
+ }
+
+ if (!HandleArg(name, value, entry->second)) {
return false;
}
+ } else if (args[i][0] == '-') {
+ printf("Unknown argument: %s\n", args[i]);
+ return false;
+ } else {
+ printf("Unexpected argument '%s'\n", args[i]);
+ return false;
}
}
+ // If no_gtest_format was specified, it overrides gtest_format.
+ if (bools_.at("no_gtest_format")) {
+ bools_["gtest_format"] = false;
+ }
return true;
}
diff --git a/Options.h b/Options.h
index 883940a..3edbafe 100644
--- a/Options.h
+++ b/Options.h
@@ -32,7 +32,7 @@ class Options {
Options() = default;
~Options() = default;
- bool Process(const std::vector<const char*>& args, std::vector<char*>* child_args);
+ bool Process(const std::vector<const char*>& args, std::vector<const char*>* child_args);
size_t job_count() const { return job_count_; }
int num_iterations() const { return num_iterations_; }
@@ -44,6 +44,7 @@ class Options {
uint64_t total_shards() const { return numerics_.at("gtest_total_shards"); }
bool print_time() const { return bools_.at("gtest_print_time"); }
+ bool gtest_format() const { return bools_.at("gtest_format"); }
bool allow_disabled_tests() const { return bools_.at("gtest_also_run_disabled_tests"); }
bool list_tests() const { return bools_.at("gtest_list_tests"); }
@@ -77,9 +78,6 @@ class Options {
bool HandleArg(const std::string& arg, const std::string& value, const ArgInfo& info,
bool from_env = false);
- bool ProcessFlagfile(const std::string& file, std::vector<char*>* child_args);
- bool ProcessSingle(const char* arg, std::vector<char*>* child_args, bool allow_flagfile);
-
bool SetNumeric(const std::string&, const std::string&, bool);
bool SetNumericEnvOnly(const std::string&, const std::string&, bool);
bool SetBool(const std::string&, const std::string&, bool);
diff --git a/TEST_MAPPING b/TEST_MAPPING
deleted file mode 100644
index c4002f2..0000000
--- a/TEST_MAPPING
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "presubmit": [
- {
- "name": "gtest_isolated_tests"
- }
- ]
-}
diff --git a/Test.cpp b/Test.cpp
index e2351e3..bd7528c 100644
--- a/Test.cpp
+++ b/Test.cpp
@@ -49,7 +49,7 @@ void Test::CloseFd() {
fd_.reset();
}
-void Test::Print() {
+void Test::PrintGtestFormat() {
ColoredPrintf(COLOR_GREEN, "[ RUN ]");
printf(" %s\n", name_.c_str());
printf("%s", output_.c_str());
@@ -74,6 +74,41 @@ void Test::Print() {
fflush(stdout);
}
+void Test::Print(bool gtest_format) {
+ if (gtest_format) {
+ PrintGtestFormat();
+ return;
+ }
+
+ switch (result_) {
+ case TEST_XFAIL:
+ case TEST_PASS:
+ ColoredPrintf(COLOR_GREEN, "[ OK ]");
+ break;
+ case TEST_XPASS:
+ case TEST_FAIL:
+ ColoredPrintf(COLOR_RED, "[ FAILED ]");
+ break;
+ case TEST_TIMEOUT:
+ ColoredPrintf(COLOR_RED, "[ TIMEOUT ]");
+ break;
+ case TEST_SKIPPED:
+ ColoredPrintf(COLOR_GREEN, "[ SKIPPED ]");
+ break;
+ case TEST_NONE:
+ LOG(FATAL) << "Test result is TEST_NONE, this should not be possible.";
+ }
+
+ printf(" %s", name_.c_str());
+ if (::testing::GTEST_FLAG(print_time)) {
+ printf(" (%" PRId64 " ms)", (end_ns_ - start_ns_) / kNsPerMs);
+ }
+ printf("\n");
+
+ printf("%s", output_.c_str());
+ fflush(stdout);
+}
+
bool Test::Read() {
char buffer[2048];
ssize_t bytes = TEMP_FAILURE_RETRY(read(fd_, buffer, sizeof(buffer) - 1));
@@ -117,40 +152,23 @@ void Test::SetResultFromOutput() {
// <filename>:(<line_number>) Failure in test <testname>
// Skipped
// <Skip Message>
-
- // There can be multiple skip messages, so remove all of them.
- size_t start_index = 0;
- while (true) {
- size_t skipped_index = output_.find("\nSkipped\n", start_index);
- if (skipped_index == std::string::npos) {
- return;
- }
- if (skipped_index == 0) {
- // The output starts with Skipped, so skip over it and keep looking.
- start_index = skipped_index + 9;
- continue;
- }
- // Look backwards for start of line before "Skipped" message.
- size_t failure_line_start = output_.rfind('\n', skipped_index - 1);
- if (failure_line_start == std::string::npos) {
- failure_line_start = 0;
- }
- skipped_index += 9;
- size_t failure_index = output_.find(" Failure in test ", failure_line_start);
- if (failure_index == std::string::npos || failure_index > skipped_index) {
- // Could still be another skipped message matching the pattern after
- // this one.
- start_index = skipped_index - 1;
- continue;
- }
- start_index = 0;
- result_ = TEST_SKIPPED;
- if (failure_line_start != 0) {
- output_ = output_.substr(0, failure_line_start + 1) + output_.substr(skipped_index);
- } else {
- output_ = output_.substr(skipped_index);
- }
+ size_t line_end = output_.find('\n');
+ if (line_end == std::string::npos) {
+ return;
}
+ std::string second_line(output_.substr(line_end, 9));
+ if (output_.substr(line_end, 9) != "\nSkipped\n") {
+ return;
+ }
+ size_t failure_index = output_.find(" Failure in test ");
+ if (failure_index == std::string::npos || failure_index >= line_end) {
+ return;
+ }
+
+ // Only leave the output from the skip message.
+ output_ = output_.substr(line_end + 9);
+
+ result_ = TEST_SKIPPED;
}
} // namespace gtest_extras
diff --git a/Test.h b/Test.h
index 147b6c8..76845ff 100644
--- a/Test.h
+++ b/Test.h
@@ -38,7 +38,9 @@ class Test {
public:
Test(std::tuple<std::string, std::string>& test, size_t test_index, size_t run_index, int fd);
- void Print();
+ void PrintGtestFormat();
+
+ void Print(bool gtest_format);
void Stop();
diff --git a/tests/OptionsTest.cpp b/tests/OptionsTest.cpp
index 97089a3..c1bb59e 100644
--- a/tests/OptionsTest.cpp
+++ b/tests/OptionsTest.cpp
@@ -22,70 +22,52 @@
#include <string>
#include <vector>
-#include <android-base/file.h>
#include <android-base/test_utils.h>
-#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "Options.h"
-using ::testing::ElementsAre;
-using ::testing::StrEq;
-
namespace android {
namespace gtest_extras {
-class OptionsTest : public ::testing::Test {
- protected:
- void ClearChildArgs() {
- for (auto arg : child_args_) {
- free(arg);
- }
- child_args_.clear();
- }
-
- void TearDown() { ClearChildArgs(); }
-
- void CheckIncompatible(const std::string arg);
- void CheckIncompatibleFromEnv(const std::string env_var);
-
- std::vector<char*> child_args_;
-};
-
-TEST_F(OptionsTest, unknown_arg) {
+TEST(OptionsTest, unknown_arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--unknown_arg"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("Unknown argument: --unknown_arg\n", capture.str());
}
-TEST_F(OptionsTest, unknown_arg_single_dash) {
+TEST(OptionsTest, unknown_arg_single_dash) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "-unknown_arg"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("Unknown argument: -unknown_arg\n", capture.str());
}
-TEST_F(OptionsTest, extra_arg) {
+TEST(OptionsTest, extra_arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "extra"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("Unexpected argument 'extra'\n", capture.str());
}
-TEST_F(OptionsTest, check_defaults) {
+TEST(OptionsTest, check_defaults) {
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_LT(0U, options.job_count());
EXPECT_EQ(90000ULL, options.deadline_threshold_ms());
EXPECT_EQ(2000ULL, options.slow_threshold_ms());
@@ -96,177 +78,243 @@ TEST_F(OptionsTest, check_defaults) {
EXPECT_EQ("", options.filter());
EXPECT_EQ(1, options.num_iterations());
EXPECT_TRUE(options.print_time());
+ EXPECT_TRUE(options.gtest_format());
EXPECT_FALSE(options.allow_disabled_tests());
EXPECT_FALSE(options.list_tests());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
+}
+
+TEST(OptionsTest, gtest_format) {
+ std::vector<const char*> cur_args{"ignore", "--gtest_format"};
+ std::vector<const char*> child_args;
+ Options options;
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
+ EXPECT_TRUE(options.gtest_format());
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
+}
+
+TEST(OptionsTest, gtest_format_error_argument) {
+ CapturedStdout capture;
+ std::vector<const char*> cur_args{"ignore", "--gtest_format=not_allowed"};
+ std::vector<const char*> child_args;
+ Options options;
+ bool parsed = options.Process(cur_args, &child_args);
+ capture.Stop();
+ ASSERT_FALSE(parsed) << "Process did not fail properly.";
+ EXPECT_EQ("--gtest_format does not take an argument.\n", capture.str());
+}
+
+TEST(OptionsTest, no_gtest_format) {
+ std::vector<const char*> cur_args{"ignore", "--no_gtest_format"};
+ std::vector<const char*> child_args;
+ Options options;
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
+ EXPECT_FALSE(options.gtest_format());
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
+}
+
+TEST(OptionsTest, no_gtest_format_and_gtest_format) {
+ std::vector<const char*> cur_args{"ignore", "--no_gtest_format", "--gtest_format"};
+ std::vector<const char*> child_args;
+ Options options;
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
+ EXPECT_FALSE(options.gtest_format());
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
+}
+
+TEST(OptionsTest, no_gtest_format_error_argument) {
+ CapturedStdout capture;
+ std::vector<const char*> cur_args{"ignore", "--no_gtest_format=not_allowed"};
+ std::vector<const char*> child_args;
+ Options options;
+ bool parsed = options.Process(cur_args, &child_args);
+ capture.Stop();
+ ASSERT_FALSE(parsed) << "Process did not fail properly.";
+ EXPECT_EQ("--no_gtest_format does not take an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_list_tests) {
+TEST(OptionsTest, gtest_list_tests) {
std::vector<const char*> cur_args{"ignore", "--gtest_list_tests"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.list_tests());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, gtest_list_tests_error_argument) {
+TEST(OptionsTest, gtest_list_tests_error_argument) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_list_tests=nothing"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_list_tests does not take an argument.\n", capture.str());
}
-TEST_F(OptionsTest, job_count_single_arg) {
+TEST(OptionsTest, job_count_single_arg) {
std::vector<const char*> cur_args{"ignore", "-j11"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(11U, options.job_count());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, job_count_second_arg) {
+TEST(OptionsTest, job_count_second_arg) {
std::vector<const char*> cur_args{"ignore", "-j", "23"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(23U, options.job_count());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, job_count_error_single_arg) {
+TEST(OptionsTest, job_count_error_single_arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "-j0bad"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("-j value is not formatted as a numeric value (0bad)\n", capture.str());
}
-TEST_F(OptionsTest, job_count_error_second_arg) {
+TEST(OptionsTest, job_count_error_second_arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "-j", "34b"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("-j value is not formatted as a numeric value (34b)\n", capture.str());
}
-TEST_F(OptionsTest, job_count_error_no_arg) {
+TEST(OptionsTest, job_count_error_no_arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "-j"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("-j requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, deadline_threshold_ms) {
+TEST(OptionsTest, deadline_threshold_ms) {
std::vector<const char*> cur_args{"ignore", "--deadline_threshold_ms=3200"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(3200ULL, options.deadline_threshold_ms());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, deadline_threshold_ms_error_no_value) {
+TEST(OptionsTest, deadline_threshold_ms_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--deadline_threshold_ms"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--deadline_threshold_ms requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, deadline_threshold_ms_error_not_a_number) {
+TEST(OptionsTest, deadline_threshold_ms_error_not_a_number) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--deadline_threshold_ms=bad"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--deadline_threshold_ms value is not formatted as a numeric value (bad)\n",
capture.str());
}
-TEST_F(OptionsTest, deadline_threshold_ms_error_illegal_value) {
+TEST(OptionsTest, deadline_threshold_ms_error_illegal_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--deadline_threshold_ms=0"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--deadline_threshold_ms requires a number greater than zero.\n", capture.str());
}
-TEST_F(OptionsTest, slow_threshold_ms) {
+TEST(OptionsTest, slow_threshold_ms) {
std::vector<const char*> cur_args{"ignore", "--slow_threshold_ms=4580"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(4580ULL, options.slow_threshold_ms());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, slow_threshold_ms_error_no_value) {
+TEST(OptionsTest, slow_threshold_ms_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--slow_threshold_ms"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--slow_threshold_ms requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, slow_threshold_ms_error_not_a_number) {
+TEST(OptionsTest, slow_threshold_ms_error_not_a_number) {
CapturedStdout capture;
Options options;
std::vector<const char*> cur_args{"ignore", "--slow_threshold_ms=not"};
- bool parsed = options.Process(cur_args, &child_args_);
+ std::vector<const char*> child_args;
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--slow_threshold_ms value is not formatted as a numeric value (not)\n", capture.str());
}
-TEST_F(OptionsTest, slow_threshold_ms_error_illegal_value) {
+TEST(OptionsTest, slow_threshold_ms_error_illegal_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--slow_threshold_ms=0"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--slow_threshold_ms requires a number greater than zero.\n", capture.str());
}
-TEST_F(OptionsTest, shard_index) {
+TEST(OptionsTest, shard_index) {
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "100", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(100ULL, options.shard_index());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "0", 1));
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(0ULL, options.shard_index());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_SHARD_INDEX"));
}
-TEST_F(OptionsTest, shard_index_error_no_value) {
+TEST(OptionsTest, shard_index_error_no_value) {
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_SHARD_INDEX] requires an argument.\n", capture.str());
@@ -274,13 +322,14 @@ TEST_F(OptionsTest, shard_index_error_no_value) {
ASSERT_NE(-1, unsetenv("GTEST_SHARD_INDEX"));
}
-TEST_F(OptionsTest, shard_index_error_not_a_number) {
+TEST(OptionsTest, shard_index_error_not_a_number) {
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "bad", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_SHARD_INDEX] value is not formatted as a numeric value (bad)\n",
@@ -289,41 +338,43 @@ TEST_F(OptionsTest, shard_index_error_not_a_number) {
ASSERT_NE(-1, unsetenv("GTEST_SHARD_INDEX"));
}
-TEST_F(OptionsTest, shard_index_error_not_from_env) {
+TEST(OptionsTest, shard_index_error_not_from_env) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_shard_index=100"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_shard_index is only supported as an environment variable.\n", capture.str());
}
-TEST_F(OptionsTest, total_shards) {
+TEST(OptionsTest, total_shards) {
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "500", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(500ULL, options.total_shards());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "0", 1));
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(0ULL, options.total_shards());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_TOTAL_SHARDS"));
}
-TEST_F(OptionsTest, total_shards_error_no_value) {
+TEST(OptionsTest, total_shards_error_no_value) {
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_TOTAL_SHARDS] requires an argument.\n", capture.str());
@@ -331,13 +382,14 @@ TEST_F(OptionsTest, total_shards_error_no_value) {
ASSERT_NE(-1, unsetenv("GTEST_TOTAL_SHARDS"));
}
-TEST_F(OptionsTest, total_shards_error_not_a_number) {
+TEST(OptionsTest, total_shards_error_not_a_number) {
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "bad", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_TOTAL_SHARDS] value is not formatted as a numeric value (bad)\n",
@@ -346,299 +398,224 @@ TEST_F(OptionsTest, total_shards_error_not_a_number) {
ASSERT_NE(-1, unsetenv("GTEST_TOTAL_SHARDS"));
}
-TEST_F(OptionsTest, total_shards_error_not_from_env) {
+TEST(OptionsTest, total_shards_error_not_from_env) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_total_shards=100"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_total_shards is only supported as an environment variable.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_color) {
+TEST(OptionsTest, gtest_color) {
std::vector<const char*> cur_args{"ignore", "--gtest_color=yes"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("yes", options.color());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore"), StrEq("--gtest_color=yes")));
+ EXPECT_EQ((std::vector<const char*>{"ignore", "--gtest_color=yes"}), child_args);
}
-TEST_F(OptionsTest, gtest_color_error_no_value) {
+TEST(OptionsTest, gtest_color_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_color="};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_color requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_filter) {
+TEST(OptionsTest, gtest_filter) {
std::vector<const char*> cur_args{"ignore", "--gtest_filter=filter"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("filter", options.filter());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, gtest_filter_error_no_value) {
+TEST(OptionsTest, gtest_filter_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_filter"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_filter requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_also_run_disabled_tests) {
+TEST(OptionsTest, gtest_also_run_disabled_tests) {
std::vector<const char*> cur_args{"ignore", "--gtest_also_run_disabled_tests"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.allow_disabled_tests());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore"), StrEq("--gtest_also_run_disabled_tests")));
+ EXPECT_EQ((std::vector<const char*>{"ignore", "--gtest_also_run_disabled_tests"}), child_args);
}
-TEST_F(OptionsTest, gtest_also_run_disabled_tests_error_argument) {
+TEST(OptionsTest, gtest_also_run_disabled_tests_error_argument) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_also_run_disabled_tests=nothing"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_also_run_disabled_tests does not take an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_repeat) {
+TEST(OptionsTest, gtest_repeat) {
std::vector<const char*> cur_args{"ignore", "--gtest_repeat=10"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(10, options.num_iterations());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
cur_args = std::vector<const char*>{"ignore", "--gtest_repeat=-1"};
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(-1, options.num_iterations());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, gtest_repeat_error_no_value) {
+TEST(OptionsTest, gtest_repeat_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_repeat"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_repeat requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_repeat_error_overflow) {
+TEST(OptionsTest, gtest_repeat_error_overflow) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_repeat=2147483747"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_repeat value overflows (2147483747)\n", capture.str());
- ClearChildArgs();
capture.Reset();
capture.Start();
cur_args = std::vector<const char*>{"ignore", "--gtest_repeat=-2147483747"};
- parsed = options.Process(cur_args, &child_args_);
+ parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_repeat value overflows (-2147483747)\n", capture.str());
}
-TEST_F(OptionsTest, gtest_print_time) {
+TEST(OptionsTest, gtest_print_time) {
std::vector<const char*> cur_args{"ignore", "--gtest_print_time"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.print_time());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
cur_args = std::vector<const char*>{"ignore", "--gtest_print_time=0"};
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_FALSE(options.print_time());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
cur_args = std::vector<const char*>{"ignore", "--gtest_print_time=1"};
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.print_time());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, gtest_output) {
+TEST(OptionsTest, gtest_output) {
std::vector<const char*> cur_args{"ignore", "--gtest_output=xml:/file.xml"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("/file.xml", options.xml_file());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
cur_args = std::vector<const char*>{"ignore", "--gtest_output=xml:/directory/"};
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("/directory/test_details.xml", options.xml_file());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
- ClearChildArgs();
cur_args = std::vector<const char*>{"ignore", "--gtest_output=xml:cwd.xml"};
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
char* cwd = getcwd(nullptr, 0);
std::string expected_file(cwd);
expected_file += "/cwd.xml";
free(cwd);
EXPECT_EQ(expected_file, options.xml_file());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
}
-TEST_F(OptionsTest, gtest_output_error_no_value) {
+TEST(OptionsTest, gtest_output_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_output"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_output requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_output_error_no_xml) {
+TEST(OptionsTest, gtest_output_error_no_xml) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_output=xml:"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_output requires a file name after xml:\n", capture.str());
- ClearChildArgs();
capture.Reset();
capture.Start();
cur_args = std::vector<const char*>{"ignore", "--gtest_output=not_xml"};
- parsed = options.Process(cur_args, &child_args_);
+ parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_output only supports an xml output file.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_death_test_style) {
+TEST(OptionsTest, gtest_death_test_style) {
std::vector<const char*> cur_args{"ignore", "--gtest_death_test_style=something"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
- EXPECT_THAT(child_args_,
- ElementsAre(StrEq("ignore"), StrEq("--gtest_death_test_style=something")));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
+ EXPECT_EQ((std::vector<const char*>{"ignore", "--gtest_death_test_style=something"}), child_args);
}
-TEST_F(OptionsTest, gtest_death_test_style_error_no_value) {
+TEST(OptionsTest, gtest_death_test_style_error_no_value) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", "--gtest_death_test_style"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("--gtest_death_test_style requires an argument.\n", capture.str());
}
-TEST_F(OptionsTest, gtest_flagfile) {
- TemporaryFile tf;
- ASSERT_TRUE(
- android::base::WriteStringToFile("--gtest_color=no\n"
- "\n"
- "--gtest_print_time=0\n"
- "--gtest_repeat=10\n",
- tf.path));
-
- std::string flag("--gtest_flagfile=");
- flag += tf.path;
- std::vector<const char*> cur_args{"ignore", flag.c_str()};
- Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
- EXPECT_EQ("no", options.color());
- EXPECT_FALSE(options.print_time());
- EXPECT_EQ(10U, options.num_iterations());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore"), StrEq("--gtest_color=no")));
-}
-
-TEST_F(OptionsTest, gtest_flagfile_no_newline) {
- TemporaryFile tf;
- ASSERT_TRUE(android::base::WriteStringToFile("--gtest_color=no", tf.path));
-
- std::string flag("--gtest_flagfile=");
- flag += tf.path;
- std::vector<const char*> cur_args{"ignore", flag.c_str()};
- Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
- EXPECT_EQ("no", options.color());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore"), StrEq("--gtest_color=no")));
-}
-
-TEST_F(OptionsTest, gtest_flagfile_empty_file) {
- TemporaryFile tf;
-
- std::string flag("--gtest_flagfile=");
- flag += tf.path;
- std::vector<const char*> cur_args{"ignore", flag.c_str()};
- Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
-}
-
-TEST_F(OptionsTest, gtest_flagfile_disallow_j_option) {
- TemporaryFile tf;
- ASSERT_TRUE(android::base::WriteStringToFile("-j1\n", tf.path));
-
- CapturedStdout capture;
- std::string flag("--gtest_flagfile=");
- flag += tf.path;
- std::vector<const char*> cur_args{"ignore", flag.c_str()};
- Options options;
- bool parsed = options.Process(cur_args, &child_args_);
- capture.Stop();
- ASSERT_FALSE(parsed) << "Process did not fail properly.";
- EXPECT_EQ("Unknown argument: -j1\n", capture.str());
-}
-
-TEST_F(OptionsTest, gtest_flagfile_disallow_gtest_flagfile_option_in_file) {
- TemporaryFile tf;
- ASSERT_TRUE(android::base::WriteStringToFile("--gtest_flagfile=nothing\n", tf.path));
-
- CapturedStdout capture;
- std::string flag("--gtest_flagfile=");
- flag += tf.path;
- std::vector<const char*> cur_args{"ignore", flag.c_str()};
- Options options;
- bool parsed = options.Process(cur_args, &child_args_);
- capture.Stop();
- ASSERT_FALSE(parsed) << "Process did not fail properly.";
- EXPECT_EQ("Argument: --gtest_flagfile=nothing is not allowed in flag file.\n", capture.str());
-}
-
-TEST_F(OptionsTest, gtest_flagfile_does_not_exist) {
- CapturedStdout capture;
- std::vector<const char*> cur_args{"ignore", "--gtest_flagfile=/this/does/not/exist"};
- Options options;
- bool parsed = options.Process(cur_args, &child_args_);
- capture.Stop();
- ASSERT_FALSE(parsed) << "Process did not fail properly.";
- EXPECT_EQ("Unable to read data from file /this/does/not/exist\n", capture.str());
-}
-
-void OptionsTest::CheckIncompatible(const std::string arg) {
+static void CheckIncompatible(const std::string arg) {
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore", arg.c_str()};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly for arg " + arg;
EXPECT_EQ(arg + " is not compatible with isolation runs.\n", capture.str());
}
-TEST_F(OptionsTest, incompatible) {
+TEST(OptionsTest, incompatible) {
ASSERT_NO_FATAL_FAILURE(CheckIncompatible("--gtest_break_on_failure"));
ASSERT_NO_FATAL_FAILURE(CheckIncompatible("--gtest_catch_exceptions"));
ASSERT_NO_FATAL_FAILURE(CheckIncompatible("--gtest_random_seed"));
@@ -647,15 +624,16 @@ TEST_F(OptionsTest, incompatible) {
ASSERT_NO_FATAL_FAILURE(CheckIncompatible("--gtest_throw_on_failure"));
}
-TEST_F(OptionsTest, verify_non_env_variables) {
+TEST(OptionsTest, verify_non_env_variables) {
EXPECT_NE(-1, setenv("DEADLINE_THRESHOLD_MS", "VALUE", 1));
EXPECT_NE(-1, setenv("SLOW_THRESHOLD_MS", "VALUE", 1));
EXPECT_NE(-1, setenv("GTEST_FORMAT", "VALUE", 1));
EXPECT_NE(-1, setenv("GTEST_LIST_TESTS", "VALUE", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- EXPECT_TRUE(options.Process(cur_args, &child_args_));
+ EXPECT_TRUE(options.Process(cur_args, &child_args));
EXPECT_LT(0U, options.job_count());
EXPECT_EQ(90000ULL, options.deadline_threshold_ms());
EXPECT_EQ(2000ULL, options.slow_threshold_ms());
@@ -664,9 +642,10 @@ TEST_F(OptionsTest, verify_non_env_variables) {
EXPECT_EQ("", options.filter());
EXPECT_EQ(1, options.num_iterations());
EXPECT_TRUE(options.print_time());
+ EXPECT_TRUE(options.gtest_format());
EXPECT_FALSE(options.allow_disabled_tests());
EXPECT_FALSE(options.list_tests());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
EXPECT_NE(-1, unsetenv("DEADLINE_THRESHOLD_MS"));
EXPECT_NE(-1, unsetenv("SLOW_THRESHOLD_MS"));
@@ -674,25 +653,27 @@ TEST_F(OptionsTest, verify_non_env_variables) {
EXPECT_NE(-1, unsetenv("GTEST_LIST_TESTS"));
}
-TEST_F(OptionsTest, gtest_filter_from_env) {
+TEST(OptionsTest, gtest_filter_from_env) {
ASSERT_NE(-1, setenv("GTEST_FILTER", "filter_value", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- EXPECT_TRUE(options.Process(cur_args, &child_args_));
+ EXPECT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("filter_value", options.filter());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_FILTER"));
}
-TEST_F(OptionsTest, gtest_filter_error_no_value_from_env) {
+TEST(OptionsTest, gtest_filter_error_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_FILTER", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_FILTER] requires an argument.\n", capture.str());
@@ -700,25 +681,27 @@ TEST_F(OptionsTest, gtest_filter_error_no_value_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_FILTER"));
}
-TEST_F(OptionsTest, gtest_also_run_disabled_tests_from_env) {
+TEST(OptionsTest, gtest_also_run_disabled_tests_from_env) {
ASSERT_NE(-1, setenv("GTEST_ALSO_RUN_DISABLED_TESTS", "", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.allow_disabled_tests());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_ALSO_RUN_DISABLED_TESTS"));
}
-TEST_F(OptionsTest, gtest_also_run_disabled_tests_error_argument_from_env) {
+TEST(OptionsTest, gtest_also_run_disabled_tests_error_argument_from_env) {
ASSERT_NE(-1, setenv("GTEST_ALSO_RUN_DISABLED_TESTS", "one", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_ALSO_RUN_DISABLED_TESTS] does not take an argument.\n", capture.str());
@@ -726,25 +709,27 @@ TEST_F(OptionsTest, gtest_also_run_disabled_tests_error_argument_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_ALSO_RUN_DISABLED_TESTS"));
}
-TEST_F(OptionsTest, gtest_repeat_from_env) {
+TEST(OptionsTest, gtest_repeat_from_env) {
ASSERT_NE(-1, setenv("GTEST_REPEAT", "34", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ(34, options.num_iterations());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_REPEAT"));
}
-TEST_F(OptionsTest, gtest_repeat_error_no_value_from_env) {
+TEST(OptionsTest, gtest_repeat_error_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_REPEAT", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_REPEAT] requires an argument.\n", capture.str());
@@ -752,23 +737,23 @@ TEST_F(OptionsTest, gtest_repeat_error_no_value_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_REPEAT"));
}
-TEST_F(OptionsTest, gtest_repeat_error_overflow_from_env) {
+TEST(OptionsTest, gtest_repeat_error_overflow_from_env) {
ASSERT_NE(-1, setenv("GTEST_REPEAT", "2147483747", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_REPEAT] value overflows (2147483747)\n", capture.str());
ASSERT_NE(-1, setenv("GTEST_REPEAT", "-2147483747", 1));
- ClearChildArgs();
capture.Reset();
capture.Start();
- parsed = options.Process(cur_args, &child_args_);
+ parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_REPEAT] value overflows (-2147483747)\n", capture.str());
@@ -776,75 +761,80 @@ TEST_F(OptionsTest, gtest_repeat_error_overflow_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_REPEAT"));
}
-TEST_F(OptionsTest, gtest_color_from_env) {
+TEST(OptionsTest, gtest_color_from_env) {
ASSERT_NE(-1, setenv("GTEST_COLOR", "yes", 1));
std::vector<const char*> cur_args{"ignore"};
std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("yes", options.color());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_COLOR"));
}
-TEST_F(OptionsTest, gtest_color_error_no_value_from_env) {
+TEST(OptionsTest, gtest_color_error_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_COLOR", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_COLOR] requires an argument.\n", capture.str());
ASSERT_NE(-1, unsetenv("GTEST_COLOR"));
}
-TEST_F(OptionsTest, gtest_print_time_from_env) {
+TEST(OptionsTest, gtest_print_time_from_env) {
ASSERT_NE(-1, setenv("GTEST_PRINT_TIME", "0", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_FALSE(options.print_time());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_PRINT_TIME"));
}
-TEST_F(OptionsTest, gtest_print_time_no_value_from_env) {
+TEST(OptionsTest, gtest_print_time_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_PRINT_TIME", "", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_TRUE(options.print_time());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_PRINT_TIME"));
}
-TEST_F(OptionsTest, gtest_output_from_env) {
+TEST(OptionsTest, gtest_output_from_env) {
ASSERT_NE(-1, setenv("GTEST_OUTPUT", "xml:/file.xml", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
EXPECT_EQ("/file.xml", options.xml_file());
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_PRINT_TIME"));
}
-TEST_F(OptionsTest, gtest_output_error_no_value_from_env) {
+TEST(OptionsTest, gtest_output_error_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_OUTPUT", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_OUTPUT] requires an argument.\n", capture.str());
@@ -852,23 +842,23 @@ TEST_F(OptionsTest, gtest_output_error_no_value_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_OUTPUT"));
}
-TEST_F(OptionsTest, gtest_output_error_no_xml_from_env) {
+TEST(OptionsTest, gtest_output_error_no_xml_from_env) {
ASSERT_NE(-1, setenv("GTEST_OUTPUT", "xml:", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_OUTPUT] requires a file name after xml:\n", capture.str());
ASSERT_NE(-1, setenv("GTEST_OUTPUT", "not_xml", 1));
- ClearChildArgs();
capture.Reset();
capture.Start();
- parsed = options.Process(cur_args, &child_args_);
+ parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_OUTPUT] only supports an xml output file.\n", capture.str());
@@ -876,24 +866,26 @@ TEST_F(OptionsTest, gtest_output_error_no_xml_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_OUTPUT"));
}
-TEST_F(OptionsTest, gtest_death_test_style_from_env) {
+TEST(OptionsTest, gtest_death_test_style_from_env) {
ASSERT_NE(-1, setenv("GTEST_DEATH_TEST_STYLE", "fast", 1));
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- ASSERT_TRUE(options.Process(cur_args, &child_args_));
- EXPECT_THAT(child_args_, ElementsAre(StrEq("ignore")));
+ ASSERT_TRUE(options.Process(cur_args, &child_args));
+ EXPECT_EQ(std::vector<const char*>{"ignore"}, child_args);
ASSERT_NE(-1, unsetenv("GTEST_DEATH_TEST_STYLE"));
}
-TEST_F(OptionsTest, gtest_death_test_style_error_no_value_from_env) {
+TEST(OptionsTest, gtest_death_test_style_error_no_value_from_env) {
ASSERT_NE(-1, setenv("GTEST_DEATH_TEST_STYLE", "", 1));
CapturedStdout capture;
std::vector<const char*> cur_args{"ignore"};
+ std::vector<const char*> child_args;
Options options;
- bool parsed = options.Process(cur_args, &child_args_);
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly.";
EXPECT_EQ("env[GTEST_DEATH_TEST_STYLE] requires an argument.\n", capture.str());
@@ -901,23 +893,23 @@ TEST_F(OptionsTest, gtest_death_test_style_error_no_value_from_env) {
ASSERT_NE(-1, unsetenv("GTEST_DEATH_TEST_STYLE"));
}
-void OptionsTest::CheckIncompatibleFromEnv(const std::string env_var) {
+static void CheckIncompatibleFromEnv(const std::string env_var) {
ASSERT_NE(-1, setenv(env_var.c_str(), "", 1));
CapturedStdout capture;
Options options;
std::vector<const char*> cur_args{"ignore"};
- bool parsed = options.Process(cur_args, &child_args_);
+ std::vector<const char*> child_args;
+ bool parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly for env var " + env_var;
EXPECT_EQ("env[" + env_var + "] is not compatible with isolation runs.\n", capture.str());
ASSERT_NE(-1, setenv(env_var.c_str(), "not_empty", 1));
- ClearChildArgs();
capture.Reset();
capture.Start();
- parsed = options.Process(cur_args, &child_args_);
+ parsed = options.Process(cur_args, &child_args);
capture.Stop();
ASSERT_FALSE(parsed) << "Process did not fail properly for env var " + env_var;
EXPECT_EQ("env[" + env_var + "] is not compatible with isolation runs.\n", capture.str());
@@ -925,7 +917,7 @@ void OptionsTest::CheckIncompatibleFromEnv(const std::string env_var) {
ASSERT_NE(-1, unsetenv(env_var.c_str()));
}
-TEST_F(OptionsTest, incompatible_from_env) {
+TEST(OptionsTest, incompatible_from_env) {
ASSERT_NO_FATAL_FAILURE(CheckIncompatibleFromEnv("GTEST_BREAK_ON_FAILURE"));
ASSERT_NO_FATAL_FAILURE(CheckIncompatibleFromEnv("GTEST_CATCH_EXCEPTIONS"));
ASSERT_NO_FATAL_FAILURE(CheckIncompatibleFromEnv("GTEST_RANDOM_SEED"));
diff --git a/tests/SystemTests.cpp b/tests/SystemTests.cpp
index ee7b176..847d44f 100644
--- a/tests/SystemTests.cpp
+++ b/tests/SystemTests.cpp
@@ -20,12 +20,10 @@
#endif
#include <signal.h>
#include <stdio.h>
-#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <map>
#include <regex>
#include <sstream>
#include <string>
@@ -38,15 +36,6 @@
#include "NanoTime.h"
-#if defined(__APPLE__)
-extern char** environ;
-
-int clearenv() {
- *environ = nullptr;
- return 0;
-}
-#endif
-
// Change the slow threshold for these tests since a few can take around
// 20 seconds.
extern "C" bool GetInitialArgs(const char*** args, size_t* num_args) {
@@ -65,10 +54,6 @@ class SystemTests : public ::testing::Test {
raw_output_ = "";
sanitized_output_ = "";
exitcode_ = 0;
-
- // Clear all environment variables to make sure the test isn't affected
- // by GTEST_XXX ones.
- clearenv();
}
void SanitizeOutput();
@@ -80,8 +65,6 @@ class SystemTests : public ::testing::Test {
std::vector<const char*> extra_args = {});
void Verify(const std::string& test_name, const std::string& expected_output,
int expected_exitcode, std::vector<const char*> extra_args = {});
- void VerifySortedOutput(const std::string& test_name, const std::string& expected_output,
- int expected_exitcode, std::vector<const char*> extra_args = {});
std::string raw_output_;
std::string sanitized_output_;
@@ -90,58 +73,6 @@ class SystemTests : public ::testing::Test {
int fd_;
};
-static std::string SortTestOutput(const std::string& output) {
- std::map<std::string, std::string> tests;
-
- std::vector<std::string> lines(android::base::Split(output, "\n"));
- std::string prefix;
- std::string suffix;
- bool capture_prefix = true;
- for (auto iter = lines.begin(); iter != lines.end(); ++iter) {
- const char* line = iter->c_str();
- if (line[0] == '\x1B') {
- // Skip the escape sequence.
- line = &line[7];
- }
- if (strncmp(line, "[ RUN ]", 12) == 0) {
- std::string test_name(iter->substr(12));
- std::string test_body(*iter + '\n');
- bool ended = false;
- for (++iter; iter != lines.end(); ++iter) {
- test_body += *iter + '\n';
- line = iter->c_str();
- if (line[0] == '\x1B') {
- // Skip the escape sequence.
- line = &line[7];
- }
- if (strncmp(line, "[ ", 2) == 0) {
- ended = true;
- break;
- }
- }
- if (!ended) {
- return output;
- }
- tests[test_name] = test_body;
- capture_prefix = false;
- } else if (capture_prefix) {
- prefix += *iter + '\n';
- } else {
- suffix += *iter + '\n';
- }
- }
-
- std::string new_output("Output Sorted\n" + prefix);
- for (auto entry : tests) {
- new_output += entry.second;
- }
- new_output += suffix;
- if (android::base::EndsWith(new_output, "\n\n")) {
- new_output.resize(new_output.size() - 1);
- }
- return new_output;
-}
-
void SystemTests::SanitizeOutput() {
// Change (100 ms to (XX ms
sanitized_output_ =
@@ -158,10 +89,6 @@ void SystemTests::SanitizeOutput() {
// Change any error message like .../file.cc:(200) to file:(XX)
sanitized_output_ = std::regex_replace(
sanitized_output_, std::regex("\\b([^/\\s]+/)*[^/\\s]+:\\(\\d+\\)\\s"), "file:(XX) ");
-
- // Change any terminated by signal message to ignore the actual signal name.
- sanitized_output_ =
- std::regex_replace(sanitized_output_, std::regex("( terminated by signal:) .*"), "$1 XXX");
}
void SystemTests::Exec(std::vector<const char*> args) {
@@ -258,18 +185,42 @@ void SystemTests::Verify(const std::string& test_name, const std::string& expect
}
}
-void SystemTests::VerifySortedOutput(const std::string& test_name,
- const std::string& expected_output, int expected_exitcode,
- std::vector<const char*> extra_args) {
- ASSERT_NO_FATAL_FAILURE(RunTest(test_name, extra_args));
- ASSERT_EQ(expected_exitcode, exitcode_) << "Test output:\n" << raw_output_;
- if (!expected_output.empty()) {
- std::string sorted_output = SortTestOutput(sanitized_output_);
- ASSERT_EQ(expected_output, sorted_output);
- }
+TEST_F(SystemTests, verify_pass) {
+ std::string expected =
+ "Note: Google Test filter = *.DISABLED_pass\n"
+ "[==========] Running 1 test from 1 test suite (20 jobs).\n"
+ "[ OK ] SystemTests.DISABLED_pass (XX ms)\n"
+ "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
+ "[ PASSED ] 1 test.\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_pass", expected, 0, std::vector<const char*>{"--no_gtest_format"}));
}
-TEST_F(SystemTests, verify_pass) {
+TEST_F(SystemTests, verify_pass_no_print_time) {
+ std::string expected =
+ "Note: Google Test filter = *.DISABLED_pass\n"
+ "[==========] Running 1 test from 1 test suite (20 jobs).\n"
+ "[ OK ] SystemTests.DISABLED_pass\n"
+ "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
+ "[ PASSED ] 1 test.\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_pass", expected, 0,
+ std::vector<const char*>{"--gtest_print_time=0", "--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_pass_color) {
+ std::string expected =
+ "\x1B[0;33mNote: Google Test filter = *.DISABLED_pass\x1B[m\n"
+ "\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTests.DISABLED_pass (XX ms)\n"
+ "\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
+ "\x1B[0;32m[ PASSED ]\x1B[m 1 test.\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_pass", expected, 0,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_pass_gtest_format) {
std::string expected =
"Note: Google Test filter = *.DISABLED_pass\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
@@ -280,7 +231,7 @@ TEST_F(SystemTests, verify_pass) {
ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_pass", expected, 0));
}
-TEST_F(SystemTests, verify_pass_no_print_time) {
+TEST_F(SystemTests, verify_pass_gtest_format_no_print_time) {
std::string expected =
"Note: Google Test filter = *.DISABLED_pass\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
@@ -292,7 +243,7 @@ TEST_F(SystemTests, verify_pass_no_print_time) {
Verify("*.DISABLED_pass", expected, 0, std::vector<const char*>{"--gtest_print_time=0"}));
}
-TEST_F(SystemTests, verify_pass_color) {
+TEST_F(SystemTests, verify_pass_gtest_format_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.DISABLED_pass\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
@@ -308,98 +259,85 @@ TEST_F(SystemTests, verify_skip) {
std::string expected =
"Note: Google Test filter = *.DISABLED_skip_no_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_no_message\n"
"[ SKIPPED ] SystemTests.DISABLED_skip_no_message (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ SKIPPED ] 1 test, listed below:\n"
"[ SKIPPED ] SystemTests.DISABLED_skip_no_message\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_no_message", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_no_message", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_skip_with_message) {
std::string expected =
"Note: Google Test filter = *.DISABLED_skip_with_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_with_message\n"
- "This is a skip message\n"
"[ SKIPPED ] SystemTests.DISABLED_skip_with_message (XX ms)\n"
+ "This is a skip message\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ SKIPPED ] 1 test, listed below:\n"
"[ SKIPPED ] SystemTests.DISABLED_skip_with_message\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_message", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_message", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
}
-TEST_F(SystemTests, verify_skip_with_output_before_message) {
+TEST_F(SystemTests, verify_skip_no_print_time) {
std::string expected =
- "Note: Google Test filter = *.DISABLED_skip_with_output_before\n"
+ "Note: Google Test filter = *.DISABLED_skip_no_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_with_output_before\n"
- "This is the message before the skip message\n"
- "This is the skip message\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_before (XX ms)\n"
+ "[ SKIPPED ] SystemTests.DISABLED_skip_no_message\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ SKIPPED ] 1 test, listed below:\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_before\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_output_before", expected, 0));
+ "[ SKIPPED ] SystemTests.DISABLED_skip_no_message\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_skip_no_message", expected, 0,
+ std::vector<const char*>{"--gtest_print_time=0", "--no_gtest_format"}));
}
-TEST_F(SystemTests, verify_skip_with_output_after_message) {
+TEST_F(SystemTests, verify_skip_color) {
std::string expected =
- "Note: Google Test filter = *.DISABLED_skip_with_output_after\n"
- "[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_with_output_after\n"
- "This is the skip message\n"
- "This is the message after the skip message\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_after (XX ms)\n"
- "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
- "[ PASSED ] 0 tests.\n"
- "[ SKIPPED ] 1 test, listed below:\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_output_after\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_output_after", expected, 0));
+ "\x1B[0;33mNote: Google Test filter = *.DISABLED_skip_no_message\x1B[m\n"
+ "\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
+ "\x1B[0;32m[ SKIPPED ]\x1B[m SystemTests.DISABLED_skip_no_message (XX ms)\n"
+ "\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
+ "\x1B[0;32m[ PASSED ]\x1B[m 0 tests.\n"
+ "\x1B[0;32m[ SKIPPED ]\x1B[m 1 test, listed below:\n"
+ "\x1B[0;32m[ SKIPPED ]\x1B[m SystemTests.DISABLED_skip_no_message\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_skip_no_message", expected, 0,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
}
-TEST_F(SystemTests, verify_skip_with_skipped_line) {
+TEST_F(SystemTests, verify_skip_gtest_format) {
std::string expected =
- "Note: Google Test filter = *.DISABLED_skip_with_skipped_line\n"
+ "Note: Google Test filter = *.DISABLED_skip_no_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_with_skipped_line\n"
- "\n"
- "Skipped\n"
- "This is the skip message 1\n"
- "Skipped\n"
- "This is the skip message 2\n"
- "Skipped\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_skipped_line (XX ms)\n"
+ "[ RUN ] SystemTests.DISABLED_skip_no_message\n"
+ "[ SKIPPED ] SystemTests.DISABLED_skip_no_message (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ SKIPPED ] 1 test, listed below:\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_with_skipped_line\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_skipped_line", expected, 0));
+ "[ SKIPPED ] SystemTests.DISABLED_skip_no_message\n";
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_no_message", expected, 0));
}
-TEST_F(SystemTests, verify_skip_multiple) {
+TEST_F(SystemTests, verify_skip_gtest_format_with_message) {
std::string expected =
- "Note: Google Test filter = *.DISABLED_skip_multiple\n"
+ "Note: Google Test filter = *.DISABLED_skip_with_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_skip_multiple\n"
- "This is not a skip message 1\n"
- "This is the skip message 1\n"
- "This is not a skip message 2\n"
- "This is the skip message 2\n"
- "This is the skip message 3\n"
- "This is not a skip message 4\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_multiple (XX ms)\n"
+ "[ RUN ] SystemTests.DISABLED_skip_with_message\n"
+ "This is a skip message\n"
+ "[ SKIPPED ] SystemTests.DISABLED_skip_with_message (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ SKIPPED ] 1 test, listed below:\n"
- "[ SKIPPED ] SystemTests.DISABLED_skip_multiple\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_multiple", expected, 0));
+ "[ SKIPPED ] SystemTests.DISABLED_skip_with_message\n";
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_skip_with_message", expected, 0));
}
-TEST_F(SystemTests, verify_skip_no_print_time) {
+TEST_F(SystemTests, verify_skip_gtest_format_no_print_time) {
std::string expected =
"Note: Google Test filter = *.DISABLED_skip_no_message\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
@@ -413,7 +351,7 @@ TEST_F(SystemTests, verify_skip_no_print_time) {
std::vector<const char*>{"--gtest_print_time=0"}));
}
-TEST_F(SystemTests, verify_skip_color) {
+TEST_F(SystemTests, verify_skip_gtest_format_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.DISABLED_skip_no_message\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
@@ -431,6 +369,39 @@ TEST_F(SystemTests, verify_xfail_fail_expect_to_fail) {
std::string expected =
"Note: Google Test filter = *.xfail_fail\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
+ "[ OK ] DISABLED_SystemTestsXfail.xfail_fail (XX ms)\n"
+ "file:(XX) Failure in test DISABLED_SystemTestsXfail.xfail_fail\n"
+ "Expected equality of these values:\n"
+ " 1\n"
+ " 0\n"
+ "DISABLED_SystemTestsXfail.xfail_fail exited with exitcode 1.\n"
+ "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
+ "[ PASSED ] 1 test. (1 expected failure)\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.xfail_fail", expected, 0, std::vector<const char*>{"--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_xfail_fail_expect_to_fail_color) {
+ std::string expected =
+ "\x1B[0;33mNote: Google Test filter = *.xfail_fail\x1B[m\n"
+ "\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
+ "\x1B[0;32m[ OK ]\x1B[m DISABLED_SystemTestsXfail.xfail_fail (XX ms)\n"
+ "file:(XX) Failure in test DISABLED_SystemTestsXfail.xfail_fail\n"
+ "Expected equality of these values:\n"
+ " 1\n"
+ " 0\n"
+ "DISABLED_SystemTestsXfail.xfail_fail exited with exitcode 1.\n"
+ "\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
+ "\x1B[0;32m[ PASSED ]\x1B[m 1 test. (1 expected failure)\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.xfail_fail", expected, 0,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_xfail_fail_expect_to_fail_gtest_format) {
+ std::string expected =
+ "Note: Google Test filter = *.xfail_fail\n"
+ "[==========] Running 1 test from 1 test suite (20 jobs).\n"
"[ RUN ] DISABLED_SystemTestsXfail.xfail_fail\n"
"file:(XX) Failure in test DISABLED_SystemTestsXfail.xfail_fail\n"
"Expected equality of these values:\n"
@@ -447,6 +418,21 @@ TEST_F(SystemTests, verify_xfail_pass_expect_to_fail) {
std::string expected =
"Note: Google Test filter = *.xfail_pass\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
+ "[ FAILED ] DISABLED_SystemTestsXfail.xfail_pass (XX ms)\n"
+ "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
+ "[ PASSED ] 0 tests.\n"
+ "[ FAILED ] 1 test should have failed, listed below:\n"
+ "[ FAILED ] DISABLED_SystemTestsXfail.xfail_pass\n"
+ "\n"
+ " 1 SHOULD HAVE FAILED TEST\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.xfail_pass", expected, 1, std::vector<const char*>{"--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_xfail_pass_expect_to_fail_gtest_format) {
+ std::string expected =
+ "Note: Google Test filter = *.xfail_pass\n"
+ "[==========] Running 1 test from 1 test suite (20 jobs).\n"
"[ RUN ] DISABLED_SystemTestsXfail.xfail_pass\n"
"[ FAILED ] DISABLED_SystemTestsXfail.xfail_pass (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
@@ -462,7 +448,6 @@ TEST_F(SystemTests, verify_xfail_pass_expect_to_fail_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.xfail_pass\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
- "\x1B[0;32m[ RUN ]\x1B[m DISABLED_SystemTestsXfail.xfail_pass\n"
"\x1B[0;31m[ FAILED ]\x1B[m DISABLED_SystemTestsXfail.xfail_pass (XX ms)\n"
"\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
"\x1B[0;32m[ PASSED ]\x1B[m 0 tests.\n"
@@ -471,24 +456,66 @@ TEST_F(SystemTests, verify_xfail_pass_expect_to_fail_color) {
"\n"
" 1 SHOULD HAVE FAILED TEST\n";
ASSERT_NO_FATAL_FAILURE(
- Verify("*.xfail_pass", expected, 1, std::vector<const char*>{"--gtest_color=yes"}));
+ Verify("*.xfail_pass", expected, 1,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_deathtest_pass) {
std::string expected =
"Note: Google Test filter = *.DISABLED_death_pass\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTestsDeathTest.DISABLED_death_pass\n"
- "[ OK ] SystemTestsDeathTest.DISABLED_death_pass (XX ms)\n"
+ "[ OK ] SystemTestsDeathTest.DISABLED_death_pass (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 1 test.\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_death_pass", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_death_pass", expected, 0, std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_fail) {
std::string expected =
"Note: Google Test filter = *.DISABLED_fail\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
+ "[ FAILED ] SystemTests.DISABLED_fail (XX ms)\n"
+ "file:(XX) Failure in test SystemTests.DISABLED_fail\n"
+ "Expected equality of these values:\n"
+ " 1\n"
+ " 0\n"
+ "SystemTests.DISABLED_fail exited with exitcode 1.\n"
+ "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
+ "[ PASSED ] 0 tests.\n"
+ "[ FAILED ] 1 test, listed below:\n"
+ "[ FAILED ] SystemTests.DISABLED_fail\n"
+ "\n"
+ " 1 FAILED TEST\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_fail", expected, 1, std::vector<const char*>{"--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_fail_color) {
+ std::string expected =
+ "\x1B[0;33mNote: Google Test filter = *.DISABLED_fail\x1B[m\n"
+ "\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
+ "\x1B[0;31m[ FAILED ]\x1B[m SystemTests.DISABLED_fail (XX ms)\n"
+ "file:(XX) Failure in test SystemTests.DISABLED_fail\n"
+ "Expected equality of these values:\n"
+ " 1\n"
+ " 0\n"
+ "SystemTests.DISABLED_fail exited with exitcode 1.\n"
+ "\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
+ "\x1B[0;32m[ PASSED ]\x1B[m 0 tests.\n"
+ "\x1B[0;31m[ FAILED ]\x1B[m 1 test, listed below:\n"
+ "\x1B[0;31m[ FAILED ]\x1B[m SystemTests.DISABLED_fail\n"
+ "\n"
+ " 1 FAILED TEST\n";
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_fail", expected, 1,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
+}
+
+TEST_F(SystemTests, verify_fail_gtest_format) {
+ std::string expected =
+ "Note: Google Test filter = *.DISABLED_fail\n"
+ "[==========] Running 1 test from 1 test suite (20 jobs).\n"
"[ RUN ] SystemTests.DISABLED_fail\n"
"file:(XX) Failure in test SystemTests.DISABLED_fail\n"
"Expected equality of these values:\n"
@@ -505,7 +532,7 @@ TEST_F(SystemTests, verify_fail) {
ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_fail", expected, 1));
}
-TEST_F(SystemTests, verify_fail_color) {
+TEST_F(SystemTests, verify_fail_gtest_format_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.DISABLED_fail\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
@@ -530,61 +557,64 @@ TEST_F(SystemTests, verify_deathtest_fail) {
std::string expected =
"Note: Google Test filter = *.DISABLED_death_fail\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTestsDeathTest.DISABLED_death_fail\n"
+ "[ FAILED ] SystemTestsDeathTest.DISABLED_death_fail (XX ms)\n"
"file:(XX) Failure in test SystemTestsDeathTest.DISABLED_death_fail\n"
"Death test: DeathTestHelperFail()\n"
" Result: failed to die.\n"
" Error msg:\n"
"[ DEATH ] \n"
"SystemTestsDeathTest.DISABLED_death_fail exited with exitcode 1.\n"
- "[ FAILED ] SystemTestsDeathTest.DISABLED_death_fail (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ FAILED ] 1 test, listed below:\n"
"[ FAILED ] SystemTestsDeathTest.DISABLED_death_fail\n"
"\n"
" 1 FAILED TEST\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_death_fail", expected, 1));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_death_fail", expected, 1, std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_crash) {
std::string expected =
"Note: Google Test filter = *.DISABLED_crash\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_crash\n"
- "SystemTests.DISABLED_crash terminated by signal: XXX\n"
"[ FAILED ] SystemTests.DISABLED_crash (XX ms)\n"
+#if defined(__APPLE__)
+ "SystemTests.DISABLED_crash terminated by signal: Segmentation fault: 11.\n"
+#else
+ "SystemTests.DISABLED_crash terminated by signal: Segmentation fault.\n"
+#endif
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ FAILED ] 1 test, listed below:\n"
"[ FAILED ] SystemTests.DISABLED_crash\n"
"\n"
" 1 FAILED TEST\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_crash", expected, 1));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_crash", expected, 1, std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_warning_slow) {
std::string expected =
"Note: Google Test filter = *.DISABLED_sleep5\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_sleep5\n"
- "[ OK ] SystemTests.DISABLED_sleep5 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_sleep5 (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 1 test.\n"
"[ SLOW ] 1 test, listed below:\n"
"[ SLOW ] SystemTests.DISABLED_sleep5 (XX ms, exceeded 3000 ms)\n"
"\n"
" 1 SLOW TEST\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_sleep5", expected, 0,
- std::vector<const char*>{"--slow_threshold_ms=3000"}));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_sleep5", expected, 0,
+ std::vector<const char*>{"--slow_threshold_ms=3000", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_warning_slow_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.DISABLED_sleep5\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTests.DISABLED_sleep5\n"
- "\x1B[0;32m[ OK ]\x1B[m SystemTests.DISABLED_sleep5 (XX ms)\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTests.DISABLED_sleep5 (XX ms)\n"
"\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
"\x1B[0;32m[ PASSED ]\x1B[m 1 test.\n"
"\x1B[0;33m[ SLOW ]\x1B[m 1 test, listed below:\n"
@@ -593,24 +623,25 @@ TEST_F(SystemTests, verify_warning_slow_color) {
" 1 SLOW TEST\n";
ASSERT_NO_FATAL_FAILURE(
Verify("*.DISABLED_sleep5", expected, 0,
- std::vector<const char*>{"--slow_threshold_ms=3000", "--gtest_color=yes"}));
+ std::vector<const char*>{"--slow_threshold_ms=3000", "--gtest_color=yes",
+ "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_timeout) {
std::string expected =
"Note: Google Test filter = *.DISABLED_sleep_forever\n"
"[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_sleep_forever\n"
+ "[ TIMEOUT ] SystemTests.DISABLED_sleep_forever (XX ms)\n"
"SystemTests.DISABLED_sleep_forever killed because of timeout at XX ms.\n"
- "[ FAILED ] SystemTests.DISABLED_sleep_forever (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 0 tests.\n"
"[ TIMEOUT ] 1 test, listed below:\n"
"[ TIMEOUT ] SystemTests.DISABLED_sleep_forever (stopped at XX ms)\n"
"\n"
" 1 TIMEOUT TEST\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_sleep_forever", expected, 1,
- std::vector<const char*>{"--deadline_threshold_ms=3000"}));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_sleep_forever", expected, 1,
+ std::vector<const char*>{"--deadline_threshold_ms=3000", "--no_gtest_format"}));
}
// Verify that tests that timeout do not get marked as slow too when
@@ -619,11 +650,9 @@ TEST_F(SystemTests, verify_timeout_not_slow) {
std::string expected =
"Note: Google Test filter = *.DISABLED_sleep*\n"
"[==========] Running 2 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_sleep5\n"
- "[ OK ] SystemTests.DISABLED_sleep5 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_sleep_forever\n"
+ "[ OK ] SystemTests.DISABLED_sleep5 (XX ms)\n"
+ "[ TIMEOUT ] SystemTests.DISABLED_sleep_forever (XX ms)\n"
"SystemTests.DISABLED_sleep_forever killed because of timeout at XX ms.\n"
- "[ FAILED ] SystemTests.DISABLED_sleep_forever (XX ms)\n"
"[==========] 2 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 1 test.\n"
"[ SLOW ] 1 test, listed below:\n"
@@ -633,18 +662,18 @@ TEST_F(SystemTests, verify_timeout_not_slow) {
"\n"
" 1 SLOW TEST\n"
" 1 TIMEOUT TEST\n";
- ASSERT_NO_FATAL_FAILURE(Verify(
- "*.DISABLED_sleep*", expected, 1,
- std::vector<const char*>{"--slow_threshold_ms=1000", "--deadline_threshold_ms=10000"}));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_sleep*", expected, 1,
+ std::vector<const char*>{"--slow_threshold_ms=1000", "--deadline_threshold_ms=10000",
+ "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_timeout_color) {
std::string expected =
"\x1B[0;33mNote: Google Test filter = *.DISABLED_sleep_forever\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (20 jobs).\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTests.DISABLED_sleep_forever\n"
+ "\x1B[0;31m[ TIMEOUT ]\x1B[m SystemTests.DISABLED_sleep_forever (XX ms)\n"
"SystemTests.DISABLED_sleep_forever killed because of timeout at XX ms.\n"
- "\x1B[0;31m[ FAILED ]\x1B[m SystemTests.DISABLED_sleep_forever (XX ms)\n"
"\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
"\x1B[0;32m[ PASSED ]\x1B[m 0 tests.\n"
"\x1B[0;31m[ TIMEOUT ]\x1B[m 1 test, listed below:\n"
@@ -653,22 +682,21 @@ TEST_F(SystemTests, verify_timeout_color) {
" 1 TIMEOUT TEST\n";
ASSERT_NO_FATAL_FAILURE(
Verify("*.DISABLED_sleep_forever", expected, 1,
- std::vector<const char*>{"--deadline_threshold_ms=3000", "--gtest_color=yes"}));
+ std::vector<const char*>{"--deadline_threshold_ms=3000", "--gtest_color=yes",
+ "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_order_isolated) {
std::string expected =
"Note: Google Test filter = *.DISABLED_order_*\n"
"[==========] Running 3 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_order_3\n"
- "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_2\n"
- "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_1\n"
- "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_order_*", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("*.DISABLED_order_*", expected, 0, std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_order_not_isolated) {
@@ -688,8 +716,8 @@ TEST_F(SystemTests, verify_order_not_isolated) {
"[----------] Global test environment tear-down\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
- ASSERT_NO_FATAL_FAILURE(
- Verify("*.DISABLED_order_*", expected, 0, std::vector<const char*>{"--no_isolate"}));
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_order_*", expected, 0,
+ std::vector<const char*>{"--no_isolate", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_fail_ge10) {
@@ -734,31 +762,26 @@ TEST_F(SystemTests, verify_job_count_single) {
std::string expected =
"Note: Google Test filter = *.DISABLED_job_*\n"
"[==========] Running 3 tests from 1 test suite (1 job).\n"
- "[ RUN ] SystemTests.DISABLED_job_1\n"
- "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_2\n"
- "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_3\n"
- "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
- ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_job_*", expected, 0, std::vector<const char*>{"-j1"}));
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_job_*", expected, 0,
+ std::vector<const char*>{"-j1", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_job_count_multiple) {
std::string expected =
"Note: Google Test filter = *.DISABLED_job_*\n"
"[==========] Running 3 tests from 1 test suite (2 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_job_2\n"
- "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_1\n"
- "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_3\n"
- "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
- ASSERT_NO_FATAL_FAILURE(
- Verify("*.DISABLED_job_*", expected, 0, std::vector<const char*>{"-j", "2"}));
+ ASSERT_NO_FATAL_FAILURE(Verify("*.DISABLED_job_*", expected, 0,
+ std::vector<const char*>{"-j", "2", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_help) {
@@ -800,41 +823,33 @@ TEST_F(SystemTests, verify_repeat) {
std::string expected =
"Note: Google Test filter = *.DISABLED_order_*\n"
"[==========] Running 3 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_order_3\n"
- "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_2\n"
- "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_1\n"
- "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n"
"\n"
"Repeating all tests (iteration 2) . . .\n"
"\n"
"[==========] Running 3 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_order_3\n"
- "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_2\n"
- "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_1\n"
- "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n"
"\n"
"Repeating all tests (iteration 3) . . .\n"
"\n"
"[==========] Running 3 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_order_3\n"
- "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_2\n"
- "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_order_1\n"
- "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_order_1 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
uint64_t time_ns = NanoTime();
ASSERT_NO_FATAL_FAILURE(
- Verify("*.DISABLED_order_*", expected, 0, std::vector<const char*>{"--gtest_repeat=3"}));
+ Verify("*.DISABLED_order_*", expected, 0,
+ std::vector<const char*>{"--gtest_repeat=3", "--no_gtest_format"}));
time_ns = NanoTime() - time_ns;
// Make sure that the total test time is about 18 seconds.
double seconds = double(time_ns) / 1000000000;
@@ -849,7 +864,7 @@ TEST_F(SystemTests, verify_repeat) {
TEST_F(SystemTests, verify_results_as_tests_finish) {
// This test verifies that test output comes out as the test finishes.
Exec(std::vector<const char*>{"--gtest_filter=*.DISABLED_order_*",
- "--gtest_also_run_disabled_tests", "-j20"});
+ "--gtest_also_run_disabled_tests", "-j20", "--no_gtest_format"});
std::string output;
std::vector<char> buffer(4096);
@@ -864,7 +879,7 @@ TEST_F(SystemTests, verify_results_as_tests_finish) {
buffer[bytes] = '\0';
output += buffer.data();
// See if the output has come out now.
- if (output.find("[ OK ] SystemTests.DISABLED_order_2") != std::string::npos) {
+ if (output.find("[ OK ] SystemTests.DISABLED_order_2") != std::string::npos) {
uint64_t test_ns = NanoTime() - time_ns;
double test_sec = double(test_ns) / 1000000000;
// This should happen after 3 seconds, but before 4.5 seconds.
@@ -991,15 +1006,14 @@ TEST_F(SystemTests, verify_disabled_not_displayed_with_no_tests) {
}
TEST_F(SystemTests, verify_disabled) {
- std::vector<const char*> args{"--gtest_filter=*always_pass", "-j2"};
+ std::vector<const char*> args{"--gtest_filter=*always_pass", "-j2", "--no_gtest_format"};
ASSERT_NO_FATAL_FAILURE(ExecAndCapture(args));
ASSERT_EQ(0, exitcode_) << "Test output:\n" << raw_output_;
std::string expected =
"Note: Google Test filter = *always_pass\n"
"[==========] Running 1 test from 1 test suite (2 jobs).\n"
- "[ RUN ] SystemTests.always_pass\n"
- "[ OK ] SystemTests.always_pass (XX ms)\n"
+ "[ OK ] SystemTests.always_pass (XX ms)\n"
"[==========] 1 test from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 1 test.\n"
"\n"
@@ -1009,15 +1023,15 @@ TEST_F(SystemTests, verify_disabled) {
}
TEST_F(SystemTests, verify_disabled_color) {
- std::vector<const char*> args{"--gtest_filter=*always_pass", "-j2", "--gtest_color=yes"};
+ std::vector<const char*> args{"--gtest_filter=*always_pass", "-j2", "--gtest_color=yes",
+ "--no_gtest_format"};
ASSERT_NO_FATAL_FAILURE(ExecAndCapture(args));
ASSERT_EQ(0, exitcode_) << "Test output:\n" << raw_output_;
std::string expected =
"\x1B[0;33mNote: Google Test filter = *always_pass\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 1 test from 1 test suite (2 jobs).\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTests.always_pass\n"
- "\x1B[0;32m[ OK ]\x1B[m SystemTests.always_pass (XX ms)\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTests.always_pass (XX ms)\n"
"\x1B[0;32m[==========]\x1B[m 1 test from 1 test suite ran. (XX ms total)\n"
"\x1B[0;32m[ PASSED ]\x1B[m 1 test.\n"
"\n"
@@ -1063,7 +1077,7 @@ TEST_F(SystemTests, verify_SIGINT) {
TEST_F(SystemTests, verify_SIGQUIT) {
// Verify that SIGQUIT prints all of the running tests.
Exec(std::vector<const char*>{"--gtest_filter=*.DISABLED_job*", "--gtest_also_run_disabled_tests",
- "-j20"});
+ "-j20", "--no_gtest_format"});
// It is expected that all of the tests will be sleeping so nothing will
// complete by the time the signal is sent.
sleep(1);
@@ -1093,12 +1107,9 @@ TEST_F(SystemTests, verify_SIGQUIT) {
" SystemTests.DISABLED_job_1 (elapsed time XX ms)\n"
" SystemTests.DISABLED_job_2 (elapsed time XX ms)\n"
" SystemTests.DISABLED_job_3 (elapsed time XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_2\n"
- "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_3\n"
- "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_job_1\n"
- "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_2 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_3 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_job_1 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n",
sanitized_output_);
@@ -1108,7 +1119,7 @@ TEST_F(SystemTests, verify_SIGQUIT) {
TEST_F(SystemTests, verify_SIGQUIT_after_test_finish) {
// Verify that SIGQUIT prints all of the tests after a test finishes.
Exec(std::vector<const char*>{"--gtest_filter=*.DISABLED_sigquit_*",
- "--gtest_also_run_disabled_tests", "-j20"});
+ "--gtest_also_run_disabled_tests", "-j20", "--no_gtest_format"});
// It is expected that one tests will have finished, but the rest will still
// be running.
sleep(1);
@@ -1134,15 +1145,12 @@ TEST_F(SystemTests, verify_SIGQUIT_after_test_finish) {
ASSERT_EQ(
"Note: Google Test filter = *.DISABLED_sigquit_*\n"
"[==========] Running 3 tests from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_sigquit_no_sleep\n"
- "[ OK ] SystemTests.DISABLED_sigquit_no_sleep (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_sigquit_no_sleep (XX ms)\n"
"List of current running tests:\n"
" SystemTests.DISABLED_sigquit_sleep_5 (elapsed time XX ms)\n"
" SystemTests.DISABLED_sigquit_sleep_6 (elapsed time XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_sigquit_sleep_5\n"
- "[ OK ] SystemTests.DISABLED_sigquit_sleep_5 (XX ms)\n"
- "[ RUN ] SystemTests.DISABLED_sigquit_sleep_6\n"
- "[ OK ] SystemTests.DISABLED_sigquit_sleep_6 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_sigquit_sleep_5 (XX ms)\n"
+ "[ OK ] SystemTests.DISABLED_sigquit_sleep_6 (XX ms)\n"
"[==========] 3 tests from 1 test suite ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n",
sanitized_output_);
@@ -1197,89 +1205,74 @@ TEST_F(SystemTests, verify_memory) {
TEST_F(SystemTests, verify_sharding) {
std::string expected =
- "Output Sorted\n"
"Note: Google Test filter = SystemTestsShard*.DISABLED*\n"
"Note: This is test shard 1 of 4\n"
"[==========] Running 3 tests from 3 test suites (20 jobs).\n"
- "[ RUN ] SystemTestsShard1.DISABLED_case1_test1\n"
- "[ OK ] SystemTestsShard1.DISABLED_case1_test1 (XX ms)\n"
- "[ RUN ] SystemTestsShard2.DISABLED_case2_test1\n"
- "[ OK ] SystemTestsShard2.DISABLED_case2_test1 (XX ms)\n"
- "[ RUN ] SystemTestsShard3.DISABLED_case3_test1\n"
- "[ OK ] SystemTestsShard3.DISABLED_case3_test1 (XX ms)\n"
+ "[ OK ] SystemTestsShard1.DISABLED_case1_test1 (XX ms)\n"
+ "[ OK ] SystemTestsShard2.DISABLED_case2_test1 (XX ms)\n"
+ "[ OK ] SystemTestsShard3.DISABLED_case3_test1 (XX ms)\n"
"[==========] 3 tests from 3 test suites ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "4", 1));
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "0", 1));
- ASSERT_NO_FATAL_FAILURE(VerifySortedOutput("SystemTestsShard*.DISABLED*", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("SystemTestsShard*.DISABLED*", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
expected =
- "Output Sorted\n"
"Note: Google Test filter = SystemTestsShard*.DISABLED*\n"
"Note: This is test shard 2 of 4\n"
"[==========] Running 3 tests from 3 test suites (20 jobs).\n"
- "[ RUN ] SystemTestsShard1.DISABLED_case1_test2\n"
- "[ OK ] SystemTestsShard1.DISABLED_case1_test2 (XX ms)\n"
- "[ RUN ] SystemTestsShard2.DISABLED_case2_test2\n"
- "[ OK ] SystemTestsShard2.DISABLED_case2_test2 (XX ms)\n"
- "[ RUN ] SystemTestsShard3.DISABLED_case3_test2\n"
- "[ OK ] SystemTestsShard3.DISABLED_case3_test2 (XX ms)\n"
+ "[ OK ] SystemTestsShard1.DISABLED_case1_test2 (XX ms)\n"
+ "[ OK ] SystemTestsShard2.DISABLED_case2_test2 (XX ms)\n"
+ "[ OK ] SystemTestsShard3.DISABLED_case3_test2 (XX ms)\n"
"[==========] 3 tests from 3 test suites ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "1", 1));
- ASSERT_NO_FATAL_FAILURE(VerifySortedOutput("SystemTestsShard*.DISABLED*", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("SystemTestsShard*.DISABLED*", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
expected =
- "Output Sorted\n"
"Note: Google Test filter = SystemTestsShard*.DISABLED*\n"
"Note: This is test shard 3 of 4\n"
"[==========] Running 3 tests from 3 test suites (20 jobs).\n"
- "[ RUN ] SystemTestsShard1.DISABLED_case1_test3\n"
- "[ OK ] SystemTestsShard1.DISABLED_case1_test3 (XX ms)\n"
- "[ RUN ] SystemTestsShard2.DISABLED_case2_test3\n"
- "[ OK ] SystemTestsShard2.DISABLED_case2_test3 (XX ms)\n"
- "[ RUN ] SystemTestsShard3.DISABLED_case3_test3\n"
- "[ OK ] SystemTestsShard3.DISABLED_case3_test3 (XX ms)\n"
+ "[ OK ] SystemTestsShard1.DISABLED_case1_test3 (XX ms)\n"
+ "[ OK ] SystemTestsShard2.DISABLED_case2_test3 (XX ms)\n"
+ "[ OK ] SystemTestsShard3.DISABLED_case3_test3 (XX ms)\n"
"[==========] 3 tests from 3 test suites ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "2", 1));
- ASSERT_NO_FATAL_FAILURE(VerifySortedOutput("SystemTestsShard*.DISABLED*", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("SystemTestsShard*.DISABLED*", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
expected =
- "Output Sorted\n"
"Note: Google Test filter = SystemTestsShard*.DISABLED*\n"
"Note: This is test shard 4 of 4\n"
"[==========] Running 3 tests from 3 test suites (20 jobs).\n"
- "[ RUN ] SystemTestsShard1.DISABLED_case1_test4\n"
- "[ OK ] SystemTestsShard1.DISABLED_case1_test4 (XX ms)\n"
- "[ RUN ] SystemTestsShard2.DISABLED_case2_test4\n"
- "[ OK ] SystemTestsShard2.DISABLED_case2_test4 (XX ms)\n"
- "[ RUN ] SystemTestsShard3.DISABLED_case3_test4\n"
- "[ OK ] SystemTestsShard3.DISABLED_case3_test4 (XX ms)\n"
+ "[ OK ] SystemTestsShard1.DISABLED_case1_test4 (XX ms)\n"
+ "[ OK ] SystemTestsShard2.DISABLED_case2_test4 (XX ms)\n"
+ "[ OK ] SystemTestsShard3.DISABLED_case3_test4 (XX ms)\n"
"[==========] 3 tests from 3 test suites ran. (XX ms total)\n"
"[ PASSED ] 3 tests.\n";
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "3", 1));
- ASSERT_NO_FATAL_FAILURE(VerifySortedOutput("SystemTestsShard*.DISABLED*", expected, 0));
+ ASSERT_NO_FATAL_FAILURE(Verify("SystemTestsShard*.DISABLED*", expected, 0,
+ std::vector<const char*>{"--no_gtest_format"}));
}
TEST_F(SystemTests, verify_sharding_color) {
std::string expected =
- "Output Sorted\n"
"\x1B[0;33mNote: Google Test filter = SystemTestsShard*.DISABLED*\x1B[m\n"
"\x1B[0;33mNote: This is test shard 1 of 4\x1B[m\n"
"\x1B[0;32m[==========]\x1B[m Running 3 tests from 3 test suites (20 jobs).\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTestsShard1.DISABLED_case1_test1\n"
- "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard1.DISABLED_case1_test1 (XX ms)\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTestsShard2.DISABLED_case2_test1\n"
- "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard2.DISABLED_case2_test1 (XX ms)\n"
- "\x1B[0;32m[ RUN ]\x1B[m SystemTestsShard3.DISABLED_case3_test1\n"
- "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard3.DISABLED_case3_test1 (XX ms)\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard1.DISABLED_case1_test1 (XX ms)\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard2.DISABLED_case2_test1 (XX ms)\n"
+ "\x1B[0;32m[ OK ]\x1B[m SystemTestsShard3.DISABLED_case3_test1 (XX ms)\n"
"\x1B[0;32m[==========]\x1B[m 3 tests from 3 test suites ran. (XX ms total)\n"
"\x1B[0;32m[ PASSED ]\x1B[m 3 tests.\n";
ASSERT_NE(-1, setenv("GTEST_TOTAL_SHARDS", "4", 1));
ASSERT_NE(-1, setenv("GTEST_SHARD_INDEX", "0", 1));
- ASSERT_NO_FATAL_FAILURE(VerifySortedOutput("SystemTestsShard*.DISABLED*", expected, 0,
- std::vector<const char*>{"--gtest_color=yes"}));
+ ASSERT_NO_FATAL_FAILURE(
+ Verify("SystemTestsShard*.DISABLED*", expected, 0,
+ std::vector<const char*>{"--gtest_color=yes", "--no_gtest_format"}));
}
TEST_F(SystemTests, verify_sharding_error) {
@@ -1301,22 +1294,6 @@ TEST_F(SystemTests, verify_sharding_error_color) {
std::vector<const char*>{"--gtest_color=yes"}));
}
-TEST_F(SystemTests, verify_gtest_flagfile) {
- TemporaryFile tf;
- ASSERT_TRUE(android::base::WriteStringToFile("--gtest_print_time=0\n", tf.path));
- std::string flagfile("--gtest_flagfile=");
- flagfile += tf.path;
- std::string expected =
- "Note: Google Test filter = *.DISABLED_pass\n"
- "[==========] Running 1 test from 1 test suite (20 jobs).\n"
- "[ RUN ] SystemTests.DISABLED_pass\n"
- "[ OK ] SystemTests.DISABLED_pass\n"
- "[==========] 1 test from 1 test suite ran. (XX ms total)\n"
- "[ PASSED ] 1 test.\n";
- ASSERT_NO_FATAL_FAILURE(
- Verify("*.DISABLED_pass", expected, 0, std::vector<const char*>{flagfile.c_str()}));
-}
-
// These tests are used by the verify_disabled tests.
TEST_F(SystemTests, always_pass) {}
@@ -1463,43 +1440,6 @@ TEST_F(SystemTests, DISABLED_skip_with_message) {
GTEST_SKIP() << "This is a skip message";
}
-TEST_F(SystemTests, DISABLED_skip_with_output_before) {
- printf("This is the message before the skip message\n");
- GTEST_SKIP() << "This is the skip message";
-}
-
-// Do not optimize this call away so that the print after the skip
-// will actually occur.
-void AvoidSkipStopping(int tag = 0) __attribute__((optnone)) {
- if (tag == 0) {
- GTEST_SKIP() << "This is the skip message";
- } else {
- GTEST_SKIP() << "This is the skip message " << std::to_string(tag);
- }
-}
-
-TEST_F(SystemTests, DISABLED_skip_with_output_after) {
- AvoidSkipStopping();
- printf("This is the message after the skip message\n");
-}
-
-TEST_F(SystemTests, DISABLED_skip_with_skipped_line) {
- printf("\nSkipped\n");
- AvoidSkipStopping(1);
- printf("Skipped\n");
- AvoidSkipStopping(2);
- printf("Skipped\n");
-}
-
-TEST_F(SystemTests, DISABLED_skip_multiple) {
- printf("This is not a skip message 1\n");
- AvoidSkipStopping(1);
- printf("This is not a skip message 2\n");
- AvoidSkipStopping(2);
- AvoidSkipStopping(3);
- printf("This is not a skip message 4\n");
-}
-
class DISABLED_SystemTestsXfail : public ::testing::Test {};
TEST_F(DISABLED_SystemTestsXfail, xfail_fail) {
@@ -1569,29 +1509,21 @@ TEST(SystemTestsShard1, DISABLED_case1_test3) {}
TEST(SystemTestsShard1, DISABLED_case1_test4) {}
-TEST(SystemTestsShard2, DISABLED_case2_test1) {
-}
+TEST(SystemTestsShard2, DISABLED_case2_test1) {}
-TEST(SystemTestsShard2, DISABLED_case2_test2) {
-}
+TEST(SystemTestsShard2, DISABLED_case2_test2) {}
-TEST(SystemTestsShard2, DISABLED_case2_test3) {
-}
+TEST(SystemTestsShard2, DISABLED_case2_test3) {}
-TEST(SystemTestsShard2, DISABLED_case2_test4) {
-}
+TEST(SystemTestsShard2, DISABLED_case2_test4) {}
-TEST(SystemTestsShard3, DISABLED_case3_test1) {
-}
+TEST(SystemTestsShard3, DISABLED_case3_test1) {}
-TEST(SystemTestsShard3, DISABLED_case3_test2) {
-}
+TEST(SystemTestsShard3, DISABLED_case3_test2) {}
-TEST(SystemTestsShard3, DISABLED_case3_test3) {
-}
+TEST(SystemTestsShard3, DISABLED_case3_test3) {}
-TEST(SystemTestsShard3, DISABLED_case3_test4) {
-}
+TEST(SystemTestsShard3, DISABLED_case3_test4) {}
} // namespace gtest_extras
} // namespace android