Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
test: fix bugs found on travis, remove linux clang compiler tests (#13)
Browse files Browse the repository at this point in the history
* tests: add more compilers to travis

* tets: fix coverage compiler vars

* fix cmakelists, add dtor tests
  • Loading branch information
ayazhafiz committed Jan 3, 2019
1 parent d43f952 commit 7527ce9
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 65 deletions.
23 changes: 3 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: cpp

dist: xenial

matrix:
include:

Expand All @@ -19,26 +21,7 @@ matrix:
- MATRIX_EVAL="CMAKE_OPTIONS=-DCOVERAGE=ON && CC=gcc-7 && CXX=g++-7"

# Linux: clang

- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-4.0
packages:
- clang-4.0
env:
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"

- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
# this keeps failing for some reason, so it's ignored for now

# Linux: gcc

Expand Down
89 changes: 52 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,67 @@ include_directories(./include)

# Define the source files and dependencies for the executable
set(SOURCE_FILES
src/css.cpp
src/display.cpp
src/dom.cpp
src/layout.cpp
src/style.cpp
src/parser/parser.cpp
src/parser/css.cpp
src/parser/html.cpp
src/renderer/canvas.cpp
src/visitor/printer.cpp
)
src/css.cpp
src/display.cpp
src/dom.cpp
src/layout.cpp
src/style.cpp
src/parser/parser.cpp
src/parser/css.cpp
src/parser/html.cpp
src/renderer/canvas.cpp
src/visitor/printer.cpp
)
set(TEST_FILES
tests/css.cpp
tests/display.cpp
tests/dom.cpp
tests/layout.cpp
tests/main.cpp
tests/style.cpp
tests/parser/css.cpp
tests/parser/html.cpp
tests/renderer/canvas.cpp
tests/visitor/printer.cpp
)
tests/css.cpp
tests/display.cpp
tests/dom.cpp
tests/layout.cpp
tests/main.cpp
tests/style.cpp
tests/parser/css.cpp
tests/parser/html.cpp
tests/renderer/canvas.cpp
tests/visitor/printer.cpp
)
set(APP_FILES
src/main.cpp
)
src/main.cpp
)

# tests
find_package(Threads)
add_executable(${PROJECT_NAME}-test ${SOURCE_FILES} ${TEST_FILES})
target_compile_options(${PROJECT_NAME}-test PRIVATE ${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -pedantic -pedantic-errors -g)
target_link_libraries(${PROJECT_NAME}-test PRIVATE gtest ${CMAKE_THREAD_LIBS_INIT})
# set compile flags
if (MSVC)
set(PROJ_COMPILE_OPTS /std:c++17 /W4 /WX /EHsc)

# coverage
if (COVERAGE)
target_compile_options(${PROJECT_NAME}-test PRIVATE --coverage)
target_link_libraries(${PROJECT_NAME}-test PRIVATE --coverage)
endif ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od")

# VS 2017 removed tr1
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
else()
set(PROJ_COMPILE_OPTS -std=c++17 -Wall -Werror -Wextra -pedantic -pedantic-errors -g)
set(EXEC_COMPILE_OPTS -Wno-keyword-macro) # Magick++ error
set(EXEC_COMPILE_OPTS ${EXEC_COMPILE_OPTS} -march=native -O2 -pipe)
endif()

# sherpa_41 executable
if (EXECUTABLE)
# sherpa_41 executable
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${APP_FILES})
add_definitions( -DMAGICKCORE_QUANTUM_DEPTH=16 )
add_definitions( -DMAGICKCORE_HDRI_ENABLE=0 )
find_package(ImageMagick COMPONENTS Magick++)
include_directories(${ImageMagick_INCLUDE_DIRS})
target_compile_options(${PROJECT_NAME} PRIVATE ${CMAKE_CXX_FLAGS} -std=c++17)
target_compile_options(${PROJECT_NAME} PRIVATE ${CMAKE_CXX_FLAGS} ${PROJ_COMPILE_OPTS} ${EXEC_COMPILE_OPTS})
target_link_libraries(${PROJECT_NAME} ${ImageMagick_LIBRARIES})
endif()
endif()

# tests
find_package(Threads)
add_executable(${PROJECT_NAME}-test ${SOURCE_FILES} ${TEST_FILES})
target_compile_options(${PROJECT_NAME}-test PRIVATE ${CMAKE_CXX_FLAGS} ${PROJ_COMPILE_OPTS})
target_link_libraries(${PROJECT_NAME}-test PRIVATE gtest ${CMAKE_THREAD_LIBS_INIT})

# coverage
if (COVERAGE)
target_compile_options(${PROJECT_NAME}-test PRIVATE --coverage -O0)
target_link_libraries(${PROJECT_NAME}-test PRIVATE --coverage)
endif ()
23 changes: 23 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '{build}'

image: Visual Studio 2017

platform:
- x64
- x86

configuration:
- Debug
- Release

install:
- git submodule update --init --recursive

before_build:
- cmake -DEXECUTABLE="OFF" -DCMAKE_CXX_FLAGS="/std:c++17" -G "Visual Studio 15 2017 Win64" .

build:
project: $(APPVEYOR_BUILD_FOLDER)\$(APPVEYOR_PROJECT_NAME).sln

test_script:
- '%APPVEYOR_BUILD_FOLDER%\%CONFIGURATION%\sherpa_41-test.exe'
6 changes: 3 additions & 3 deletions include/dom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class Node {

/**
* Determines whether the Node is of specified type
* @param tag tag to match
* @return whether Node is of `tag` type
* @param cand tag to match
* @return whether Node is of `cand` type
*/
bool is(const std::string & tag) const;
bool is(const std::string & cand) const;

/**
* Returns the tag name of the Node
Expand Down
2 changes: 2 additions & 0 deletions include/parser/css.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "../css.hpp"
#include "parser/parser.hpp"

#include <cctype>

/**
* CSS Parser, parsing text into a style sheet represented using the CSS module.
*
Expand Down
8 changes: 4 additions & 4 deletions src/dom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ DOM::Node::~Node() = default;

/**
* Determines whether the Node is of specified type
* @param tag tag to match
* @return whether Node is of `tag` type
* @param cand tag to match
* @return whether Node is of `cand` type
*/
bool DOM::Node::is(const std::string & tag) const {
return tagName() == tag;
bool DOM::Node::is(const std::string & cand) const {
return tagName() == cand;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/parser/css.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "parser.cpp"

#include <algorithm>
#include <functional>

/**
Expand Down
2 changes: 2 additions & 0 deletions src/parser/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "parser.cpp"

#include <cctype>

/**
* Creates an HTML Parser
* @param html HTML to parse
Expand Down
2 changes: 1 addition & 1 deletion tests/css.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TEST_F(CSSTest, DeclarationCtorDtor) {
}

TEST_F(CSSTest, RuleCtorDtor) {
Rule rule(PrioritySelectorSet, DeclarationSet);
Rule rule((PrioritySelectorSet()), (DeclarationSet()));
}

TEST_F(CSSTest, StyleSheetCtorDtor) {
Expand Down

0 comments on commit 7527ce9

Please sign in to comment.