From 90b067ce0d9aaf5a2bb7bb56505ba163522a334d Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Sun, 22 Sep 2019 19:43:42 +0200 Subject: [PATCH] Scratch running in travis. Modern C++ is too difficult to run in travis/ --- .travis.yml | 39 ----------------------------------- 2019/CMakeLists.txt | 6 +++--- 2019/README.md | 28 +++++++++++++++++++++++-- 2019/tests/test_solutions.cpp | 6 ++++-- 4 files changed, 33 insertions(+), 46 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 71dbe1d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: cpp -dist: bionic -sudo: true - -matrix: - include: - - addons: - apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-bionic-8 - packages: - - clang-8 - - libc++-8-dev - - libc++abi-8-dev - - libboost-filesystem-dev - - libboost-program-options-dev - - libgtest-dev - env: - - MATRIX_EVAL="CC=clang-8 && CXX=clang++-8" - - -before_install: - - eval "$MATRIX_EVAL" - -# Install GTest properly since it is only available as a static library. -install: - - mkdir -p ~/gtest_build - - pushd ~/gtest_build - - cmake /usr/src/gtest -DBUILD_SHARED_LIBS=true - - make && sudo make install - - popd - -# Custom directory, for the correct year -before_script: - - cd 2019 - -# CMake build -script: cmake . && make && make test diff --git a/2019/CMakeLists.txt b/2019/CMakeLists.txt index 6edf706..5dea4ae 100644 --- a/2019/CMakeLists.txt +++ b/2019/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(aoc2019) -find_package(Boost REQUIRED COMPONENTS program_options filesystem) +find_package(Boost REQUIRED COMPONENTS program_options) find_package(GTest REQUIRED) add_library(AoCSolutions src/implementations.hpp src/implementations.cpp src/day01.cpp src/days.hpp) @@ -14,9 +14,9 @@ target_link_libraries(runner AoCSolutions Boost::program_options) add_executable(unit_tests tests/test_solutions.cpp) target_compile_features(unit_tests PUBLIC cxx_std_17) -target_link_libraries(unit_tests AoCSolutions Boost::filesystem GTest::GTest GTest::Main) +target_link_libraries(unit_tests AoCSolutions GTest::GTest GTest::Main) target_compile_definitions(unit_tests PRIVATE "TEST_SAMPLES_DIR=\"${CMAKE_SOURCE_DIR}/tests/samples\"") target_include_directories(unit_tests PRIVATE "${CMAKE_SOURCE_DIR}/src") enable_testing() -gtest_discover_tests(unit_tests) +gtest_discover_tests(unit_tests NO_PRETTY_VALUES) diff --git a/2019/README.md b/2019/README.md index dc723dd..160afe3 100644 --- a/2019/README.md +++ b/2019/README.md @@ -1,8 +1,32 @@ # Advent of Code 2019 -[![Build Status](https://travis-ci.org/bertptrs/adventofcode.svg?branch=master)](https://travis-ci.org/bertptrs/adventofcode) - This project contains my implementations for Advent of Code 2019. The goal is to create reasonably fast C++ implementations in readable and ergonomic C++. At the end of the contest, I will probably do a write- up of some sorts. + + +## How to compile + +Install the dependencies: + +- [GTest](https://github.com/google/googletest) **Note:** this project + by default tries to dynamically link GTest, and the Ubuntu packages + only provide a statically linked archive. You may need to compile it + for yourself. +- [Boost.Program_options](https://www.boost.org/doc/libs/1_71_0/doc/html/program_options.html) + +``` +mkdir build && cd build +cmake .. +make +``` + +You can then use the generated executable `runner`. + +## Running tests + +Tests can be executed with `make test`. The `tests` folder contains a +`samples` folder. This folder contains pairs of `XX-Y-something.in` and +`XX-Y-something.out`, which will be taken as the expected input and +output of the implementations. You can add your own samples to this mix. diff --git a/2019/tests/test_solutions.cpp b/2019/tests/test_solutions.cpp index 6a9cd6b..620c003 100644 --- a/2019/tests/test_solutions.cpp +++ b/2019/tests/test_solutions.cpp @@ -2,9 +2,11 @@ #include #include +#include #include +#include +#include #include -#include #include #include "implementations.hpp" @@ -93,7 +95,7 @@ TEST_P(SolutionsTest, TestExpectedOutcome) { static std::vector get_samples() { std::vector samples; - for (const auto &entry : boost::filesystem::directory_iterator(TEST_SAMPLES_DIR)) { + for (const auto &entry : std::filesystem::directory_iterator(TEST_SAMPLES_DIR)) { if (entry.path().filename().extension() == ".in") { samples.push_back(entry.path().string()); }