science/dimod: Fix tests

This commit is contained in:
Yuri Victorovich 2022-08-27 10:50:29 -07:00
parent 59884b3044
commit 5b8dd2d0c6
5 changed files with 54 additions and 2 deletions

View file

@ -8,9 +8,12 @@ COMMENT= DWave: Shared API for QUBO/Ising samplers
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
TEST_DEPENDS= catch>0:devel/catch
USES= compiler:c++11-lang pkgconfig
USE_GITHUB= yes
GH_ACCOUNT= dwavesystems
GH_TUPLE= catchorg:Catch2:f0dc4d9:catch/testscpp/Catch2
NO_BUILD= yes
NO_ARCH= yes
@ -26,7 +29,7 @@ do-install:
cd ${WRKSRC}/dimod/include && \
${COPYTREE_SHARE} dimod ${STAGEDIR}${PREFIX}/include
do-test: # tests fail to compile, see https://github.com/dwavesystems/dimod/issues/1238
do-test:
@cd ${WRKSRC}/testscpp && ${SETENV} ${MAKE_ENV} ${MAKE}
.include <bsd.port.mk>

View file

@ -0,0 +1,18 @@
--- testscpp/Makefile.orig 2022-08-16 14:45:27 UTC
+++ testscpp/Makefile
@@ -13,12 +13,12 @@ coverage:
rm baseline.info test.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
-tests: test_main.out
+tests: test_main
./test_main
test_main: test_main.cpp
- g++ -std=c++11 -Wall -Werror -c test_main.cpp
- g++ -std=c++11 -Wall -Werror test_main.o tests/*.cpp -o test_main -I $(SRC)
+ g++ $(CXXFLAGS) `pkg-config --cflags catch2` -std=c++11 -Wall -c test_main.cpp
+ g++ $(CXXFLAGS) `pkg-config --cflags --libs catch2` -std=c++11 -Wall test_main.o tests/*.cpp -o test_main -I $(SRC)
catch2:
git submodule init

View file

@ -0,0 +1,9 @@
--- testscpp/test_main.cpp.orig 2022-08-27 15:45:50 UTC
+++ testscpp/test_main.cpp
@@ -1,5 +1,5 @@
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
-#include "Catch2/single_include/catch2/catch.hpp"
+#include <catch2/catch.hpp>
/*
The purpose of this file is to include Catch's main(). Tests can be found inside tests directory.

View file

@ -0,0 +1,11 @@
--- testscpp/tests/test_quadratic_model.cpp.orig 2022-08-27 15:54:59 UTC
+++ testscpp/tests/test_quadratic_model.cpp
@@ -14,7 +14,7 @@
#include <iostream>
-#include "../Catch2/single_include/catch2/catch.hpp"
+#include <catch2/catch.hpp>
#include "dimod/quadratic_model.h"
namespace dimod {

View file

@ -0,0 +1,11 @@
--- testscpp/tests/test_utils.cpp.orig 2022-08-27 15:49:35 UTC
+++ testscpp/tests/test_utils.cpp
@@ -15,7 +15,7 @@
#include <iostream>
#include <random>
-#include "../Catch2/single_include/catch2/catch.hpp"
+#include <catch2/catch.hpp>
#include "dimod/utils.h"
namespace dimod {