summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 20:46:21 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 20:46:21 +0000
commit5d42633876f05084c16c0d0be13460230af3e3ec (patch)
tree9b76a716492b079348296db355651b9dad64f4d5
parente860d4df29efebdb22e76e625b0a08d4b507f3e9 (diff)
downloadchromium_src-5d42633876f05084c16c0d0be13460230af3e3ec.zip
chromium_src-5d42633876f05084c16c0d0be13460230af3e3ec.tar.gz
chromium_src-5d42633876f05084c16c0d0be13460230af3e3ec.tar.bz2
fix base test harness to work on mac. fix command_line unit tests to match what windows expects. fix base xcode project to separate building and running unit tests into two targets.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@593 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.xcodeproj/project.pbxproj59
-rw-r--r--base/command_line.cc8
-rw-r--r--base/command_line_unittest.cc8
-rw-r--r--base/test_suite.h18
4 files changed, 85 insertions, 8 deletions
diff --git a/base/base.xcodeproj/project.pbxproj b/base/base.xcodeproj/project.pbxproj
index 05caab8..e402f6a 100644
--- a/base/base.xcodeproj/project.pbxproj
+++ b/base/base.xcodeproj/project.pbxproj
@@ -19,6 +19,18 @@
name = All;
productName = All;
};
+ E49F1A870E4CDB4500386AEC /* Run UnitTests */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = E49F1A8F0E4CDB5400386AEC /* Build configuration list for PBXAggregateTarget "Run UnitTests" */;
+ buildPhases = (
+ E49F1A860E4CDB4500386AEC /* ShellScript */,
+ );
+ dependencies = (
+ E49F1AB00E4CDB8A00386AEC /* PBXTargetDependency */,
+ );
+ name = "Run UnitTests";
+ productName = "Run UnitTests";
+ };
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
@@ -149,6 +161,9 @@
E49F197C0E4CBDF400386AEC /* stack_container_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = E491165C0E48A51E001EE8C3 /* stack_container_unittest.cc */; };
E49F19A40E4CBFE900386AEC /* sys_string_conversions_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C5F480E4B6BF900679E8F /* sys_string_conversions_mac.cc */; };
E49F1A330E4CCCF200386AEC /* command_line.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4A133490E37A41D00110AA2 /* command_line.cc */; };
+ E49F1A390E4CCD6400386AEC /* command_line_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = E45A2B5A0E479A1900DB1196 /* command_line_unittest.cc */; };
+ E49F1A5E0E4CD6E200386AEC /* run_all_unittests.cc in Sources */ = {isa = PBXBuildFile; fileRef = E49F1A5D0E4CD6E200386AEC /* run_all_unittests.cc */; };
+ E49F1A7B0E4CD99D00386AEC /* icu_util.cc in Sources */ = {isa = PBXBuildFile; fileRef = 825403110D92D1E80006B936 /* icu_util.cc */; };
E4A133440E37A3C400110AA2 /* string_escape.cc in Sources */ = {isa = PBXBuildFile; fileRef = E4A133420E37A3C400110AA2 /* string_escape.cc */; };
E4A133450E37A3C400110AA2 /* string_escape.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A133430E37A3C400110AA2 /* string_escape.h */; };
E4A1334C0E37A41D00110AA2 /* command_line.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A1334A0E37A41D00110AA2 /* command_line.h */; };
@@ -297,6 +312,13 @@
remoteGlobalIDString = 82C262C30DCF9411005CFE91;
remoteInfo = icudatastatic;
};
+ E49F1AAF0E4CDB8A00386AEC /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 825402AA0D92D0C60006B936 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = E49F18BE0E4CBAC200386AEC;
+ remoteInfo = UnitTest;
+ };
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -492,6 +514,7 @@
E49115F30E47B496001EE8C3 /* at_exit_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = at_exit_unittest.cc; sourceTree = "<group>"; };
E491165C0E48A51E001EE8C3 /* stack_container_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stack_container_unittest.cc; sourceTree = "<group>"; };
E49F18BF0E4CBAC200386AEC /* UnitTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = UnitTest; sourceTree = BUILT_PRODUCTS_DIR; };
+ E49F1A5D0E4CD6E200386AEC /* run_all_unittests.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = run_all_unittests.cc; sourceTree = "<group>"; };
E4A133420E37A3C400110AA2 /* string_escape.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string_escape.cc; sourceTree = "<group>"; };
E4A133430E37A3C400110AA2 /* string_escape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_escape.h; sourceTree = "<group>"; };
E4A133490E37A41D00110AA2 /* command_line.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = command_line.cc; sourceTree = "<group>"; };
@@ -645,6 +668,7 @@
8254035D0D92D27C0006B936 /* resource_util.h */,
8254035E0D92D27C0006B936 /* revocable_store.cc */,
8254035F0D92D27C0006B936 /* revocable_store.h */,
+ E49F1A5D0E4CD6E200386AEC /* run_all_unittests.cc */,
7B5AD60D0D9DD8050012BCF1 /* scoped_cftyperef.h */,
825403610D92D27C0006B936 /* scoped_ptr.h */,
825403620D92D27C0006B936 /* sha2.cc */,
@@ -925,7 +949,6 @@
buildPhases = (
E49F18BC0E4CBAC200386AEC /* Sources */,
E49F18BD0E4CBAC200386AEC /* Frameworks */,
- E49F19B30E4CC0DC00386AEC /* ShellScript */,
);
buildRules = (
);
@@ -981,6 +1004,7 @@
825403B00D92D2E50006B936 /* base_gfx */,
825404020D92D3340006B936 /* All */,
E49F18BE0E4CBAC200386AEC /* UnitTest */,
+ E49F1A870E4CDB4500386AEC /* Run UnitTests */,
);
};
/* End PBXProject section */
@@ -1073,7 +1097,7 @@
/* End PBXReferenceProxy section */
/* Begin PBXShellScriptBuildPhase section */
- E49F19B30E4CC0DC00386AEC /* ShellScript */ = {
+ E49F1A860E4CDB4500386AEC /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -1181,6 +1205,9 @@
E49F197C0E4CBDF400386AEC /* stack_container_unittest.cc in Sources */,
E49F19A40E4CBFE900386AEC /* sys_string_conversions_mac.cc in Sources */,
E49F1A330E4CCCF200386AEC /* command_line.cc in Sources */,
+ E49F1A390E4CCD6400386AEC /* command_line_unittest.cc in Sources */,
+ E49F1A5E0E4CD6E200386AEC /* run_all_unittests.cc in Sources */,
+ E49F1A7B0E4CD99D00386AEC /* icu_util.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1227,6 +1254,11 @@
name = icudatastatic;
targetProxy = E49F18CE0E4CBAED00386AEC /* PBXContainerItemProxy */;
};
+ E49F1AB00E4CDB8A00386AEC /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = E49F18BE0E4CBAC200386AEC /* UnitTest */;
+ targetProxy = E49F1AAF0E4CDB8A00386AEC /* PBXContainerItemProxy */;
+ };
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
@@ -1434,6 +1466,20 @@
};
name = Release;
};
+ E49F1A880E4CDB4500386AEC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = UnitTest;
+ };
+ name = Debug;
+ };
+ E49F1A890E4CDB4500386AEC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ PRODUCT_NAME = UnitTest;
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -1482,6 +1528,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ E49F1A8F0E4CDB5400386AEC /* Build configuration list for PBXAggregateTarget "Run UnitTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ E49F1A880E4CDB4500386AEC /* Debug */,
+ E49F1A890E4CDB4500386AEC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = 825402AA0D92D0C60006B936 /* Project object */;
diff --git a/base/command_line.cc b/base/command_line.cc
index 6556abd..57d1b12 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -55,7 +55,12 @@ using namespace std;
// Since we use a lazy match, make sure that longer versions (like L"--")
// are listed before shorter versions (like L"-") of similar prefixes.
+#if defined(OS_WIN)
const wchar_t* const CommandLine::kSwitchPrefixes[] = {L"--", L"-", L"/"};
+#elif defined(OS_POSIX)
+// POSIX shells don't use slash as a switch since they mark absolute paths
+const wchar_t* const CommandLine::kSwitchPrefixes[] = {L"--", L"-"};
+#endif
const wchar_t CommandLine::kSwitchValueSeparator[] = L"=";
@@ -139,9 +144,8 @@ class CommandLine::Data {
}
#elif defined(OS_POSIX) // Does the actual parsing of the command line.
void Init(int argc, const char* argv[]) {
- if (argc <= 1)
+ if (argc < 1)
return;
-
program_ = base::SysNativeMBToWide(argv[0]);
command_line_string_ = program_;
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 6a0a62c..ae619d5 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -49,11 +49,11 @@ TEST(CommandLineTest, CommandLineConstructor) {
L"\"in the time of submarines...\"");
#elif OS_POSIX
const char* argv[] = {"program", "--foo=", "-bAr",
- "/Spaetzel=pierogi /Baz flim",
- "--other-switches=\"--dog=canine --cat=feline\"",
+ "-Spaetzel=pierogi", "-Baz", "flim",
+ "--other-switches=--dog=canine --cat=feline",
"-spaetzle=Crepe", "-=loosevalue", "flan",
- "--input-translation=\"45\"--output-rotation",
- "\"in the time of submarines...\""};
+ "--input-translation=45--output-rotation",
+ "in the time of submarines..."};
CommandLine cl(arraysize(argv), argv);
#endif
EXPECT_FALSE(cl.command_line_string().empty());
diff --git a/base/test_suite.h b/base/test_suite.h
index a021339..c9b0f12 100644
--- a/base/test_suite.h
+++ b/base/test_suite.h
@@ -34,14 +34,22 @@
// instantiate this class in your main function and call its Run method to run
// any gtest based tests that are linked into your executable.
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include "base/command_line.h"
#include "base/debug_on_start.h"
#include "base/icu_util.h"
#include "base/logging.h"
+#if defined(OS_WIN)
+// TODO(pinkerton): re-enable this when MessageLoop can be included by
+// non-windows platforms.
#include "base/message_loop.h"
#include "base/multiprocess_test.h"
+#endif
#include "testing/gtest/include/gtest/gtest.h"
class TestSuite {
@@ -51,16 +59,19 @@ class TestSuite {
}
virtual ~TestSuite() {
+#if defined(OS_WIN)
// Flush any remaining messages. This ensures that any accumulated Task
// objects get destroyed before we exit, which avoids noise in purify
// leak-test results.
message_loop_.Quit();
message_loop_.Run();
+#endif
}
int Run() {
Initialize();
+#if defined(OS_WIN)
// Check to see if we are being run as a client process.
std::wstring client_func =
parsed_command_line_.GetSwitchValue(kRunClientProcess);
@@ -77,6 +88,7 @@ class TestSuite {
return func();
return -1;
}
+#endif
return RUN_ALL_TESTS();
}
@@ -86,6 +98,7 @@ class TestSuite {
FAIL() << str;
}
+#if defined(OS_WIN)
// Disable crash dialogs so that it doesn't gum up the buildbot
virtual void SuppressErrorDialogs() {
UINT new_flags = SEM_FAILCRITICALERRORS |
@@ -96,20 +109,25 @@ class TestSuite {
UINT existing_flags = SetErrorMode(new_flags);
SetErrorMode(existing_flags | new_flags);
}
+#endif
virtual void Initialize() {
+#if defined(OS_WIN)
// In some cases, we do not want to see standard error dialogs.
if (!IsDebuggerPresent() &&
!parsed_command_line_.HasSwitch(L"show-error-dialogs")) {
SuppressErrorDialogs();
logging::SetLogAssertHandler(UnitTestAssertHandler);
}
+#endif
icu_util::Initialize();
}
CommandLine parsed_command_line_;
+#if defined(OS_WIN)
MessageLoop message_loop_;
+#endif
};
#endif // BASE_TEST_SUITE_H__