[GTK] Build and run TestWebKitAPI unit tests
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 16:48:18 +0000 (16:48 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 16:48:18 +0000 (16:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84325

Reviewed by Philippe Normand.

.:

* GNUmakefile.am: Include makefiles to build gtest and
TestWebKitAPI. Add BUILDING_WEBKIT2__ macro to compilation when
building WebKit2.

Source/ThirdParty:

* gtest/GNUmakefile.am: Added.

Tools:

We only build WTF unit tests for now. WebKit2 tests will be
enabled in a follow up patch.

* Scripts/run-gtk-tests:
(TestRunner): Add TestWebKitAPI/WTF to the list of directories
containing unit tests.
(TestRunner._run_test_glib): Run glib tests using gtester.
(TestRunner._run_test_google): Run google tests.
(TestRunner._run_test): Use _run_test_glib or _run_test_google
depending on whether given test is glib or google test
* TestWebKitAPI/GNUmakefile.am: Added.
* TestWebKitAPI/config.h: Use #ifdef instead of # to fix a compile
warning with -Wundef. Include WebKit2 headers only when building
WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115075 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
GNUmakefile.am
Source/ThirdParty/ChangeLog
Source/ThirdParty/gtest/GNUmakefile.am [new file with mode: 0644]
Tools/ChangeLog
Tools/Scripts/run-gtk-tests
Tools/TestWebKitAPI/GNUmakefile.am [new file with mode: 0644]
Tools/TestWebKitAPI/config.h

index 6bf293c..4e47253 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Build and run TestWebKitAPI unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=84325
+
+        Reviewed by Philippe Normand.
+
+        * GNUmakefile.am: Include makefiles to build gtest and
+        TestWebKitAPI. Add BUILDING_WEBKIT2__ macro to compilation when
+        building WebKit2.
+
 2012-04-24  Charles Wei  <charles.wei@torchmobile.com.cn>
 
         [BlackBerry] Input Range element expects mouse events
index 75ca1e2..97b99cb 100644 (file)
@@ -148,6 +148,11 @@ global_cppflags += \
        -DBUILDING_GTK__=1 \
        -DWTF_CHANGES
 
+if ENABLE_WEBKIT2
+global_cppflags += \
+       -DBUILDING_WEBKIT2__=1
+endif
+
 # For the Gtk port we want to use XP_UNIX both in X11 and Mac
 if !TARGET_WIN32
 global_cppflags += \
@@ -265,6 +270,8 @@ include Source/WebKit2/GNUmakefile.am
 include Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
 include Tools/MiniBrowser/gtk/GNUmakefile.am
 include Tools/WebKitTestRunner/GNUmakefile.am
+include Source/ThirdParty/gtest/GNUmakefile.am
+include Tools/TestWebKitAPI/GNUmakefile.am
 # [GTK] Refactor the translations now that we have webkit2
 # https://bugs.webkit.org/show_bug.cgi?id=55153
 
index e29a975..63a14da 100644 (file)
@@ -1,3 +1,12 @@
+2012-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Build and run TestWebKitAPI unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=84325
+
+        Reviewed by Philippe Normand.
+
+        * gtest/GNUmakefile.am: Added.
+
 2012-03-30  David Barr  <davidbarr@chromium.org>
 
         Split up top-level .gitignore and .gitattributes
diff --git a/Source/ThirdParty/gtest/GNUmakefile.am b/Source/ThirdParty/gtest/GNUmakefile.am
new file mode 100644 (file)
index 0000000..dbda858
--- /dev/null
@@ -0,0 +1,72 @@
+
+noinst_LTLIBRARIES += \
+       Libraries/libgtest.la \
+       Libraries/libgtest_main.la
+
+Libraries_libgtest_la_SOURCES = \
+       Source/ThirdParty/gtest/include/gtest/gtest.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-death-test.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-message.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-param-test.h \
+       Source/ThirdParty/gtest/include/gtest/gtest_pred_impl.h \
+       Source/ThirdParty/gtest/include/gtest/gtest_prod.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-spi.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-test-part.h \
+       Source/ThirdParty/gtest/include/gtest/gtest-typed-test.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-death-test-internal.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-filepath.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-internal.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-linked_ptr.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-param-util-generated.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-param-util.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-port.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-string.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-tuple.h \
+       Source/ThirdParty/gtest/include/gtest/internal/gtest-type-util.h \
+       Source/ThirdParty/gtest/src/gtest-all.cc
+
+# Use -isystem gcc flag so that gcc considers gtest headers as system headers.
+# We need this to avoid a lot of compile warnings due to -Wundef.
+# See http://code.google.com/p/googletest/issues/detail?id=258
+Libraries_libgtest_la_CPPFLAGS = \
+       $(global_cppflags) \
+       $(javascriptcore_cppflags) \
+       -isystem $(srcdir)/Source/ThirdParty/gtest \
+       -isystem $(srcdir)/Source/ThirdParty/gtest/include \
+       -I$(srcdir)/Source/WTF \
+       -I$(srcdir)/Source/ThirdParty/gtest \
+       -I$(srcdir)/Source/ThirdParty/gtest/include
+
+Libraries_libgtest_la_CXXFLAGS = -DGTEST_HAS_PTHREAD=1
+Libraries_libgtest_la_LIBADD = \
+       -lpthread
+
+Libraries_libgtest_main_la_SOURCES = \
+       Source/ThirdParty/gtest/src/gtest_main.cc
+
+Libraries_libgtest_main_la_CPPFLAGS = \
+       $(global_cppflags) \
+       $(javascriptcore_cppflags) \
+       -isystem $(srcdir)/Source/ThirdParty/gtest \
+       -isystem $(srcdir)/Source/ThirdParty/gtest/include \
+       -I$(srcdir)/Source/WTF \
+       -I$(srcdir)/Source/ThirdParty/gtest \
+       -I$(srcdir)/Source/ThirdParty/gtest/include
+
+Libraries_libgtest_main_la_LIBADD = \
+       -lpthread
+
+Libraries_libgtest_main_la_CXXFLAGS = -DGTEST_HAS_PTHREAD=1
+
+# gtest source files that we don't compile directly.  They are
+# #included by gtest-all.cc.
+GTEST_SRC = \
+       Source/ThirdParty/gtest/src/gtest.cc \
+       Source/ThirdParty/gtest/src/gtest-death-test.cc \
+       Source/ThirdParty/gtest/src/gtest-filepath.cc \
+       Source/ThirdParty/gtest/src/gtest-internal-inl.h \
+       Source/ThirdParty/gtest/src/gtest-port.cc \
+       Source/ThirdParty/gtest/src/gtest-test-part.cc \
+       Source/ThirdParty/gtest/src/gtest-typed-test.cc
+
+EXTRA_DIST += $(GTEST_SRC)
index 0eb74c9..9f77c4c 100644 (file)
@@ -1,3 +1,25 @@
+2012-04-24  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        [GTK] Build and run TestWebKitAPI unit tests
+        https://bugs.webkit.org/show_bug.cgi?id=84325
+
+        Reviewed by Philippe Normand.
+
+        We only build WTF unit tests for now. WebKit2 tests will be
+        enabled in a follow up patch.
+
+        * Scripts/run-gtk-tests:
+        (TestRunner): Add TestWebKitAPI/WTF to the list of directories
+        containing unit tests.
+        (TestRunner._run_test_glib): Run glib tests using gtester.
+        (TestRunner._run_test_google): Run google tests.
+        (TestRunner._run_test): Use _run_test_glib or _run_test_google
+        depending on whether given test is glib or google test
+        * TestWebKitAPI/GNUmakefile.am: Added.
+        * TestWebKitAPI/config.h: Use #ifdef instead of # to fix a compile
+        warning with -Wundef. Include WebKit2 headers only when building
+        WebKit2.
+
 2012-04-24  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
 
         [Qt][WK2] Convert touch-point area
index 7776788..5efa637 100755 (executable)
@@ -44,7 +44,7 @@ class SkippedTest:
 
 class TestRunner:
 
-    TEST_DIRS = [ "unittests", "WebKit2APITests" ]
+    TEST_DIRS = [ "unittests", "WebKit2APITests", "TestWebKitAPI/WTF" ]
 
     SKIPPED = [
         SkippedTest("unittests/testdownload",
@@ -238,7 +238,7 @@ class TestRunner:
         # Run only skipped tests.
         return skipped is not None
 
-    def _run_test(self, test):
+    def _run_test_glib(self, test):
         tester_command = ['gtester']
         if self._options.verbose:
             tester_command.append('--verbose')
@@ -248,6 +248,23 @@ class TestRunner:
 
         return not self._create_process(tester_command, env=self._test_env).wait()
 
+    def _run_test_google(self, test):
+        tester_command = [test, "--gtest_throw_on_failure"]
+        skipped_tests_cases = self._test_cases_to_skip(test)
+        if skipped_tests_cases:
+            tester_command.append("--gtest_filter=-%s" % ":".join(skipped_tests_cases))
+
+        return not self._create_process(tester_command, env=self._test_env).wait()
+
+    def _run_test(self, test):
+        if "unittests" in test or "WebKit2APITests" in test:
+            return self._run_test_glib(test)
+
+        if "TestWebKitAPI" in test:
+            return self._run_test_google(test)
+
+        return False
+
     def run_tests(self):
         if not self._tests:
             sys.stderr.write("ERROR: tests not found in %s.\n" % (self._programs_path))
diff --git a/Tools/TestWebKitAPI/GNUmakefile.am b/Tools/TestWebKitAPI/GNUmakefile.am
new file mode 100644 (file)
index 0000000..dc74b60
--- /dev/null
@@ -0,0 +1,94 @@
+TEST_PROGS += \
+       Programs/TestWebKitAPI/WTF/TestCheckedArithmeticOperations \
+       Programs/TestWebKitAPI/WTF/TestFunctional \
+       Programs/TestWebKitAPI/WTF/TestHashMap \
+       Programs/TestWebKitAPI/WTF/TestRedBlackTree \
+       Programs/TestWebKitAPI/WTF/TestStringBuilder \
+       Programs/TestWebKitAPI/WTF/TestStringOperators \
+       Programs/TestWebKitAPI/WTF/TestTemporaryChange \
+       Programs/TestWebKitAPI/WTF/TestVectorBasic \
+       Programs/TestWebKitAPI/WTF/TestVector \
+       Programs/TestWebKitAPI/WTF/TestVectorReverse
+
+noinst_PROGRAMS += $(TEST_PROGS)
+
+# Use -isystem gcc flag so that gcc considers gtest headers as system headers.
+# We need this to avoid a lot of compile warnings due to -Wundef.
+# See http://code.google.com/p/googletest/issues/detail?id=258
+testwebkitapi_wtf_tests_cppflags = \
+       -isystem $(srcdir)/Source/ThirdParty/gtest/include \
+       -I$(srcdir)/Tools/TestWebKitAPI \
+       -I$(srcdir)/Source/ThirdParty/gtest/include \
+       -I$(top_builddir)/DerivedSources/WebKit2/include \
+       $(global_cppflags) \
+       $(javascriptcore_cppflags)
+
+testwebkitapi_wtf_tests_ldadd = \
+       Libraries/libgtest.la \
+       Libraries/libgtest_main.la \
+       libWTF.la
+
+testwebkitapi_wtf_tests_ldflags = \
+       -no-install \
+       -no-fast-install
+
+Programs_TestWebKitAPI_WTF_TestCheckedArithmeticOperations_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp
+Programs_TestWebKitAPI_WTF_TestCheckedArithmeticOperations_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestCheckedArithmeticOperations_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestCheckedArithmeticOperations_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestFunctional_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/Functional.cpp
+Programs_TestWebKitAPI_WTF_TestFunctional_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestFunctional_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestFunctional_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestHashMap_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/HashMap.cpp
+Programs_TestWebKitAPI_WTF_TestHashMap_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestHashMap_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestHashMap_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestRedBlackTree_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/RedBlackTree.cpp
+Programs_TestWebKitAPI_WTF_TestRedBlackTree_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestRedBlackTree_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestRedBlackTree_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestStringBuilder_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp
+Programs_TestWebKitAPI_WTF_TestStringBuilder_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestStringBuilder_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestStringBuilder_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestStringOperators_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/StringOperators.cpp
+Programs_TestWebKitAPI_WTF_TestStringOperators_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestStringOperators_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestStringOperators_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestTemporaryChange_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/TemporaryChange.cpp
+Programs_TestWebKitAPI_WTF_TestTemporaryChange_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestTemporaryChange_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestTemporaryChange_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestVectorBasic_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/VectorBasic.cpp
+Programs_TestWebKitAPI_WTF_TestVectorBasic_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestVectorBasic_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestVectorBasic_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestVector_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/Vector.cpp
+Programs_TestWebKitAPI_WTF_TestVector_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestVector_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestVector_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
+Programs_TestWebKitAPI_WTF_TestVectorReverse_SOURCES = \
+       Tools/TestWebKitAPI/Tests/WTF/VectorReverse.cpp
+Programs_TestWebKitAPI_WTF_TestVectorReverse_CPPFLAGS = $(testwebkitapi_wtf_tests_cppflags)
+Programs_TestWebKitAPI_WTF_TestVectorReverse_LDADD = $(testwebkitapi_wtf_tests_ldadd)
+Programs_TestWebKitAPI_WTF_TestVectorReverse_LDFLAGS = $(testwebkitapi_wtf_tests_ldflags)
+
index b26a547..4ffcb8b 100644 (file)
@@ -29,7 +29,7 @@
 #include <runtime/JSExportMacros.h>
 #endif
 
-#if __APPLE__
+#if defined(__APPLE__) && __APPLE__
 
 #ifdef __OBJC__
 #import <Cocoa/Cocoa.h>
@@ -43,7 +43,7 @@
 
 #include <stdint.h>
 
-#if !PLATFORM(CHROMIUM)
+#if !PLATFORM(CHROMIUM) || (PLATFORM(GTK) && defined(BUILDING_WEBKIT2__))
 #include <WebKit2/WebKit2.h>
 #endif