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

Splitting templated test across different translation units #238

Closed
jh0x opened this issue May 19, 2019 · 1 comment
Closed

Splitting templated test across different translation units #238

jh0x opened this issue May 19, 2019 · 1 comment

Comments

@jh0x
Copy link

jh0x commented May 19, 2019

Description

I am trying to split a heavy to compile test (https://github.com/jh0x/intern/tree/master/test) across several translation units to speed up the compilation. Turns out that in the final binary only one set (from one TU) of tests is fired.

Steps to reproduce

main.cpp:

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

t.h

#include <doctest/doctest.h>
TEST_CASE_TEMPLATE_DEFINE("foo", T, test_id)
{
    T t = 1;
    REQUIRE(t == 1);
}

t0.cpp

#include "t.h"
TEST_CASE_TEMPLATE_INVOKE(test_id, int);

t1.cpp

#include "t.h"
TEST_CASE_TEMPLATE_INVOKE(test_id, long);

After compiling, linking and running 1 test case is invoked.

Alternatively, if we did only this instead:
t.cpp

#include "t.h"

TEST_CASE_TEMPLATE_INVOKE(test_id, int);
TEST_CASE_TEMPLATE_INVOKE(test_id, long);

Two test cases are getting invoked.

Extra information

  • doctest version: b6dbff7 (2.3.2)
  • Operating System: Fedora 29, X64
  • Compiler+version: clang version 7.0.1 (Fedora 7.0.1-6.fc29), g++ (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)
@onqtam
Copy link
Member

onqtam commented May 20, 2019

Thanks for reporting! I reproduced it with MSVC as well. I'll look into it asap. curiously if we add a single blank line in one of the 2 source files before the INVOKE call it works properly.

onqtam added a commit that referenced this issue Jun 2, 2019
…re the proper thing is instantiated + now the location of the test file is where it gets instantiated and not where the template was defined
@onqtam onqtam closed this as completed in d5d67f3 Jun 2, 2019
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

2 participants