Skip to content

Commit

Permalink
Integrate gumbo_parser with gtest.
Browse files Browse the repository at this point in the history
This adds the support to build with gtest submodule through gyp+ninja.

To generate the new ninja files, run:
$ gyp --depth=. gumbo_parser.gyp

To build use the following command line:
$ ninja -C out/Default gumbo_parser_unittests

To run use this command line:
$ out/Default/gump_parser_unittests

Signed-off-by: Thiago Farina <tfarina@chromium.org>
  • Loading branch information
tfarina committed Sep 14, 2013
1 parent 1fbc93b commit 484e490
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "testdata"]
path = testdata
url = https://github.com/html5lib/html5lib-tests.git
[submodule "third_party/gtest"]
path = third_party/gtest
url = https://chromium.googlesource.com/external/googletest/
133 changes: 133 additions & 0 deletions gtest.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{
'targets': [
{
'target_name': 'gtest',
'type': 'static_library',
'include_dirs': [
'third_party/gtest',
'third_party/gtest/include',
],
'link_settings': {
'ldflags': ['-lpthread'],
},
'dependencies': [
'gtest_prod',
],
'sources': [
'third_party/gtest/include/gtest/gtest-death-test.h',
'third_party/gtest/include/gtest/gtest-message.h',
'third_party/gtest/include/gtest/gtest-param-test.h',
'third_party/gtest/include/gtest/gtest-printers.h',
'third_party/gtest/include/gtest/gtest-spi.h',
'third_party/gtest/include/gtest/gtest-test-part.h',
'third_party/gtest/include/gtest/gtest-typed-test.h',
'third_party/gtest/include/gtest/gtest.h',
'third_party/gtest/include/gtest/gtest_pred_impl.h',
'third_party/gtest/include/gtest/internal/gtest-death-test-internal.h',
'third_party/gtest/include/gtest/internal/gtest-filepath.h',
'third_party/gtest/include/gtest/internal/gtest-internal.h',
'third_party/gtest/include/gtest/internal/gtest-linked_ptr.h',
'third_party/gtest/include/gtest/internal/gtest-param-util-generated.h',
'third_party/gtest/include/gtest/internal/gtest-param-util.h',
'third_party/gtest/include/gtest/internal/gtest-port.h',
'third_party/gtest/include/gtest/internal/gtest-string.h',
'third_party/gtest/include/gtest/internal/gtest-tuple.h',
'third_party/gtest/include/gtest/internal/gtest-type-util.h',
'third_party/gtest/src/gtest-all.cc',
'third_party/gtest/src/gtest-death-test.cc',
'third_party/gtest/src/gtest-filepath.cc',
'third_party/gtest/src/gtest-internal-inl.h',
'third_party/gtest/src/gtest-port.cc',
'third_party/gtest/src/gtest-printers.cc',
'third_party/gtest/src/gtest-test-part.cc',
'third_party/gtest/src/gtest-typed-test.cc',
'third_party/gtest/src/gtest.cc',
],
'sources!': [
'third_party/gtest/src/gtest-all.cc', # Not needed by our build.
],
'conditions': [
['OS == "mac" or OS == "ios"', {
'sources': [
'gtest_mac.h',
'gtest_mac.mm',
'platform_test_mac.mm'
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
],
},
}],
['OS=="win" and (MSVS_VERSION=="2012" or MSVS_VERSION=="2012e")', {
'defines': [
'_VARIADIC_MAX=10',
],
'direct_dependent_settings': {
'defines': [
'_VARIADIC_MAX=10',
],
},
}],
],
'direct_dependent_settings': {
'defines': [
'UNIT_TEST',
],
'include_dirs': [
'third_party/gtest/include', # So that gtest headers can find themselves.
],
'target_conditions': [
['_type=="executable"', {
'test': 1,
'conditions': [
['OS=="mac"', {
'run_as': {
'action????': ['${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}'],
},
}],
['OS=="win"', {
'run_as': {
'action????': ['$(TargetPath)', '--gtest_print_time'],
},
}],
],
}],
],
'msvs_disabled_warnings': [4800],
},
},
{
'target_name': 'gtest_main',
'type': 'static_library',
'dependencies': [
'gtest',
],
'sources': [
'third_party/gtest/src/gtest_main.cc',
],
},
{
'target_name': 'gtest_prod',
'toolsets': ['host', 'target'],
'type': 'none',
'sources': [
'third_party/gtest/include/gtest/gtest_prod.h',
],
},
],
}
27 changes: 26 additions & 1 deletion gumbo_parser.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

{
'targets': [
Expand Down Expand Up @@ -46,5 +45,31 @@
'src/vector.h',
],
},
{
'target_name': 'gumbo_parser_unittests',
'type': 'executable',
'dependencies': [
'gtest.gyp:gtest',
'gtest.gyp:gtest_main',
'gumbo_parser',
],
'include_dirs': [
'.',
'..',
'src',
],
'sources': [
'tests/attribute.cc',
'tests/char_ref.cc',
'tests/parser.cc',
'tests/string_buffer.cc',
'tests/string_piece.cc',
'tests/test_utils.cc',
'tests/test_utils.h',
'tests/tokenizer.cc',
'tests/utf8.cc',
'tests/vector.cc',
],
},
],
}
4 changes: 2 additions & 2 deletions tests/attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <stdlib.h>
#include <string.h>

#include "gtest/gtest.h"
#include "vector.h"
#include "test_utils.h"
#include "third_party/gtest/include/gtest/gtest.h"
#include "vector.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion tests/char_ref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <string.h>

#include "test_utils.h"
#include "third_party/gtest/include/gtest/gtest.h"
#include "utf8.h"
#include "gtest/gtest.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion tests/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <string>

#include "test_utils.h"
#include "gtest/gtest.h"
#include "third_party/gtest/include/gtest/gtest.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion tests/string_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <stdlib.h>
#include <string.h>

#include "gtest/gtest.h"
#include "test_utils.h"
#include "third_party/gtest/include/gtest/gtest.h"
#include "util.h"

namespace {
Expand Down
2 changes: 1 addition & 1 deletion tests/string_piece.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <stdlib.h>
#include <string.h>

#include "gtest/gtest.h"
#include "parser.h"
#include "test_utils.h"
#include "third_party/gtest/include/gtest/gtest.h"
#include "util.h"

namespace {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "gumbo.h"
#include "parser.h"
#include "gtest/gtest.h"
#include "third_party/gtest/include/gtest/gtest.h"

inline std::string ToString(const GumboStringPiece& str) {
return std::string(str.data, str.length);
Expand Down
3 changes: 1 addition & 2 deletions tests/tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <stdio.h>

#include "test_utils.h"

#include "gtest/gtest.h"
#include "third_party/gtest/include/gtest/gtest.h"

extern const char* kGumboTagNames[];

Expand Down
2 changes: 1 addition & 1 deletion tests/utf8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "gumbo.h"
#include "parser.h"
#include "test_utils.h"
#include "gtest/gtest.h"
#include "third_party/gtest/include/gtest/gtest.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion tests/vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <stdlib.h>
#include <string.h>

#include "gtest/gtest.h"
#include "test_utils.h"
#include "third_party/gtest/include/gtest/gtest.h"

namespace {

Expand Down
1 change: 1 addition & 0 deletions third_party/gtest
Submodule gtest added at 1cb04a

0 comments on commit 484e490

Please sign in to comment.