Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.16-p0: Tests fail to build: "EQUAL" "1" Unknown arguments specified #250

Closed
yurivict opened this issue Oct 14, 2021 · 10 comments
Closed

Comments

@yurivict
Copy link

CMake Error at /usr/local/lib/cmake/doctest/doctestAddTests.cmake:60 (if):
  if given arguments:

    "EQUAL" "1"

  Unknown arguments specified
@Dobiasd
Copy link
Owner

Dobiasd commented Oct 14, 2021

Thanks for reporting the error.

Can you provide the steps needed to reproduce it, ideally as a Dockerfile?

@yurivict
Copy link
Author

Docker doesn't support FreeBSD yet.

The problem occurs in the FreeBSD port devel/functionalplus. This is the script that is run:

/bin/mkdir -p /disk-samsung/freebsd-ports/devel/functionalplus/work/.build/test && cd /disk-samsung/freebsd-ports/devel/functionalplus/work/.build/test && \
        \
        /usr/bin/env XDG_DATA_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CONFIG_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CACHE_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work/.cache HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work PATH=/disk-samsung/freebsd-ports/devel/functionalplus/work/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin SHELL=/bin/sh CONFIG_SHELL=/bin/sh /usr/local/bin/cmake -DCMAKE_C_COMPILER:STRING=cc -DCMAKE_CXX_COMPILER:STRING=c++ -DCMAKE_C_FLAGS:STRING=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing  -DCMAKE_C_FLAGS_DEBUG:STRING=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing  -DCMAKE_C_FLAGS_RELEASE:STRING=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing  -DCMAKE_CXX_FLAGS:STRING=-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer   -DCMAKE_CXX_FLAGS_DEBUG:STRING=-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer   -DCMAKE_CXX_FLAGS_RELEASE:STRING=-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer   -DCMAKE_EXE_LINKER_FLAGS:STRING= -fstack-protector-strong  -DCMAKE_MODULE_LINKER_FLAGS:STRING= -fstack-protector-strong  -DCMAKE_SHARED_LINKER_FLAGS:STRING= -fstack-protector-strong  -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DCMAKE_BUILD_TYPE:STRING=Release -DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -GNinja /disk-samsung/freebsd-ports/devel/functionalplus/work/FunctionalPlus-0.2.16-p0/test && \
        \
        /usr/bin/env NINJA_STATUS=[%p %s/%t]  XDG_DATA_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CONFIG_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CACHE_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work/.cache HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work PATH=/disk-samsung/freebsd-ports/devel/functionalplus/work/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES DESTDIR=/disk-samsung/freebsd-ports/devel/functionalplus/work/stage PREFIX=/usr/local LOCALBASE=/usr/local CC=cc CFLAGS=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing  CPP=cpp CPPFLAGS=-fno-omit-frame-pointer LDFLAGS= -fstack-protector-strong  LIBS= CXX=c++ CXXFLAGS=-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer   MANPREFIX=/usr/local BSD_INSTALL_PROGRAM=install  -s -m 555 BSD_INSTALL_LIB=install  -s -m 0644 BSD_INSTALL_SCRIPT=install  -m 555 BSD_INSTALL_DATA=install  -m 0644 BSD_INSTALL_MAN=install  -m 444 ninja -v all && \
        \
        /usr/bin/env NINJA_STATUS=[%p %s/%t]  XDG_DATA_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CONFIG_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work XDG_CACHE_HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work/.cache HOME=/disk-samsung/freebsd-ports/devel/functionalplus/work PATH=/disk-samsung/freebsd-ports/devel/functionalplus/work/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES DESTDIR=/disk-samsung/freebsd-ports/devel/functionalplus/work/stage PREFIX=/usr/local LOCALBASE=/usr/local CC=cc CFLAGS=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector-strong -fno-strict-aliasing  CPP=cpp CPPFLAGS=-fno-omit-frame-pointer LDFLAGS= -fstack-protector-strong  LIBS= CXX=c++ CXXFLAGS=-O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -fno-strict-aliasing -fno-omit-frame-pointer   MANPREFIX=/usr/local BSD_INSTALL_PROGRAM=install  -s -m 555 BSD_INSTALL_LIB=install  -s -m 0644 BSD_INSTALL_SCRIPT=install  -m 555 BSD_INSTALL_DATA=install  -m 0644 BSD_INSTALL_MAN=install  -m 444 ninja -v test

@Dobiasd
Copy link
Owner

Dobiasd commented Oct 15, 2021

Ah, ok. 👍

As a workaround for installing FunctionalPlus, of course you can simply copy the FunctionalPlus header files to your target directory without invoking CMake at all.

Apart from that, I currently can only guess: Maybe the CMake version can be updated, and that would help. 😬

@yurivict
Copy link
Author

cmake-3.21.4 is used, which is almost the latest.

/usr/local/lib/cmake/doctest/doctestAddTests.cmake has these relevant lines:

...
set(add_labels ${TEST_ADD_LABELS})
...
if(${add_labels} EQUAL 1)
...

The last line fails.

Is TEST_ADD_LABELS supposed to be defined by the project?

@Dobiasd
Copy link
Owner

Dobiasd commented Nov 27, 2021

Does building (i.e. installing) FunctionalPlus work when you don't build/run the tests, i.e., without needing doctest?

If the problem is only with doctest, maybe you can reproduce the problem with doctest alone and ask in its repo.


Edit: To answer your question ("Is TEST_ADD_LABELS supposed to be defined by the project?": I don't know. 😬

@tbreslein
Copy link

I got the same error only when building the tests, using FunctionalPlus outside of that works fine.

I also got that error in a different side project where I wanted to try doctest, where FunctionalPlus wasn't a dependency. So this seems to be an issue isolated to doctest.

@Dobiasd
Copy link
Owner

Dobiasd commented Nov 28, 2021

In case anybody of you guys opens an issue in the doctest repo, it would be cool if you could post the link here, so future readers of this can easily find it. 🙂

@tbreslein
Copy link

Yep, I will, once I figure out a minimal example for that supposed bug. The super minimal example in their tutorial works, but something breaks in my setup in the aforementioned side project (that doesn't involve FunctionalPlus).

Tbf, it could still be that some thing isn't set correctly in the doctest setup in this library, and that the source of that error is the same that I see in my other side project. In that case I guess this could still be considered a bug in FunctionalPlus, and I see if I can fix it same way I'm going to fix it in that other project,

@tbreslein
Copy link

Quick update: Reproduced the bug, found the issue with my setup, and found the related Github issue.

The problem is the doctest_discover_tests CMake function that is exported by doctest's CMake module.

Just for completeness sake, this is the CMake file:

cmake_minimum_required(VERSION 3.20)
project(doctestest LANGUAGES CXX VERSION 0.0.1)

#######################################
# Conan Block BEGIN
#######################################

# setup conan.cmake if it does not exist
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake"
                EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
                TLS_VERIFY ON)
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_configure(
    REQUIRES
        doctest/2.4.6
    GENERATORS
        cmake_paths
        cmake_find_package
    )

conan_cmake_autodetect(settings)

# download deps in conanfile.txt
conan_cmake_install(PATH_OR_REFERENCE .
    BUILD missing
    REMOTE conancenter
    SETTINGS ${settings}
    )

# add paths of conan managed packages
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

#######################################
# Conan Block END
#######################################

find_package(doctest REQUIRED)
include(doctest)

add_executable(tests main.cpp)
target_compile_features(tests PRIVATE cxx_std_17)
target_link_libraries(tests PRIVATE doctest::doctest)
doctest_discover_tests(tests)

And this is the source file:

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>

int factorial(int number) {
  return number <= 1 ? number : factorial(number - 1) * number;
}

TEST_CASE("testing the factorial function") {
  CHECK(factorial(1) == 1);
  CHECK(factorial(2) == 2);
  CHECK(factorial(3) == 6);
  CHECK(factorial(10) == 3628800);
}

As I said, the culprit is the line doctest_discover_tests, if I leave that out, the file compiles and runs fine. But it seems this is a known issue in doctest version 2.4.6, here's the issue in their repo: doctest/doctest#524

This is fixed in their dev branch, and the bug's been introduced in 2.4.6, so it runs fine in 2.4.5 (I just tested that too). The only consequence for FunctionalPlus then is that, at least in some circumstances, it cannot be doctest'ed with doctest version 2.4.6 specifically. Dunno if that should be noted anywhere.

So indeed this wasn't a FunctionalPlus issue, or at least not directly.

@Dobiasd
Copy link
Owner

Dobiasd commented Nov 29, 2021

Thanks a lot for doing all this digging work. 👍

I've just added a remark to the docs about not using doctest 2.4.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants