mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Scratch running in travis.
Modern C++ is too difficult to run in travis/
This commit is contained in:
39
.travis.yml
39
.travis.yml
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
# Advent of Code 2019
|
||||
|
||||
[](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.
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <charconv>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include "implementations.hpp"
|
||||
|
||||
@@ -93,7 +95,7 @@ TEST_P(SolutionsTest, TestExpectedOutcome) {
|
||||
|
||||
static std::vector<std::string> get_samples() {
|
||||
std::vector<std::string> 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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user