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

Support expected output in compile-time failure test #1

Open
ldionne opened this issue Jun 7, 2017 · 5 comments
Open

Support expected output in compile-time failure test #1

ldionne opened this issue Jun 7, 2017 · 5 comments

Comments

@ldionne
Copy link

ldionne commented Jun 7, 2017

For example, I want to be able to check that a specific error message is emitted (a static_assert, say). The way I do that right now is by putting the following in the source file:

// in foo.cpp
int main() {
  // MESSAGE[Incomplete definition of your concept map]
  auto const& map = dyno::complete_concept_map<Fooable, int>(dyno::concept_map<Fooable, int>);
}

I then create a compile_fail test for foo.cpp and that checks whether there's an expected message. See https://github.com/ldionne/dyno/blob/master/cmake/CompileFailTest.cmake for an implementation.

@pfultz2
Copy link
Member

pfultz2 commented Jun 7, 2017

I think this can be accomplished with the PASS_REGULAR_EXPRESSION or FAIL_REGULAR_EXPRESSION, but let me create a test for this use case.

@ldionne
Copy link
Author

ldionne commented Jun 7, 2017

I don't think it works (I remember trying this first), and it's convenient to put the error message in the source file, close to the line where the error happens. If you don't put any message, it just checks for failure.

@pfultz2
Copy link
Member

pfultz2 commented Jun 7, 2017

I don't think it works

That looks like what you do in the link you sent.

it's convenient to put the error message in the source file

Yea, I can add option to parse the output from the source file.

@ldionne
Copy link
Author

ldionne commented Jun 7, 2017

That looks like what you do in the link you sent.

Sure, but there I don't say WILL_FAIL, I just say PASS_REGULAR_EXPRESSION. And if I don't want any message, I need to specify WILL_FAIL instead. This is backwards, and that's why I think it's nice to have this encapsulated in something like bcm_test.

@pfultz2
Copy link
Member

pfultz2 commented Jun 7, 2017

I actually don't see it as backwards. However, I do see it very useful to add a feature to parse this from the source files.

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