-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
C++11 Regular Expressions #41
Conversation
I must admit that I didn't intend for those regular expressions tests to be comprehensive. (Given I was fixing a memory leak by adopting RAII semantics, I mostly wanted the test to check that.) |
@ckennelly, that's OK. I just don't want to break the project if I start adding in changes 😨 |
CMake has a few built in modules, one of which is (At the moment, I'm a bit envious of Google Test's glob/wildcard-style filtering: https://code.google.com/p/googletest/source/browse/trunk/src/gtest.cc#444) |
On #29: unfortunately there was a first round of comments which I addressed/answered and then the review thread died out. And I went on vacation and stuff and didn't ping the thread. I guess it would be good to revive it. On |
@pleroy, that's alright, sometimes people get busy! Hoping to revive the Windows port. Dropping the Regarding @dominichamon objection I think he saw some issues with the matching of the regular expressions. This could have been an issue with the For now I'm just trying to get issue #30 solved so I can move on to the Windows building. Just need a shout out on what I should do. From @ckennelly comments above:
I'll try to do 1 and 2 today but may slip until after the weekend. As the regex is basically the I'm actually quite keen to keep the |
@mattyclarkson: For testing, I'd suggest to make sure that you can select various groups of tests in |
@pleroy, thanks, will look into it! |
The current commits do the following:
RFC |
set(CMAKE_CXX_FLAGS "-Wall -Werror -pedantic-errors --std=c++0x") | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-fno-strict-aliasing -O3 -DNDEBUG") | ||
|
||
# Set OS | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
add_definitions(-DOS_MACOSX) | ||
add_definitions(-DOS_MACOSX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The {{benchmark_filter}} option was originally meant to match the googletest {{gtest_filter}} option, but that is more of a glob than a regex, iirc. I'm actually ok with anything here that works consistently across versions. The most common filter I use is "prefix_.*" to run a subset of benchmarks. That should work everywhere. |
I think this is ready for merge, if everyone is happy with it. |
I'll rebase this in the morning off |
This is rebased on |
Hold on before merging - the regular expression is matching correctly but the |
It might be the default which would need to be '.*' now.
|
@dominichamon, have submitted a fix for that. That does mean that you now have to write a filter that is an exact regex match. Do you want me to make the |
I guess the |
This is expected by users coming from Google test so I think that would be
|
OK. Changed to |
Great! That's the problem that I had when i did the naive move to c++11 regex :) checking the patch now. |
@@ -4,17 +4,17 @@ project (benchmark) | |||
# Make sure we can import out CMake functions | |||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | |||
|
|||
# We need threads in this project | |||
# Resolve dependent packages | |||
find_package(Threads REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this now be in an 'if !c++11 ' block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well std::thread
still requires you to like -pthread
(well at least it did on gcc 4.7). I'll have a look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - if you don't have the find_package(Theads REQUIRED)
you get linker errors due to pthread
not being found. When I get around to doing some Windows porting I'll look into what this means on that platform. Looking at the FindThread.cmake
it looks like it doesn't really do much for Windows, but that'll be another problem for another day I guess!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right - because they use pthreads under the hood for implementation. This may not be necessary for all compiler/OS versions, but it probably is ok to leave in.
Rebased on |
there's a bug without your change: with your change, none of the following match
|
@dominichamon, |
I've pushed a set of tests to the It seems that |
#47 is merged |
Rebased on
POSIX regex,
Could you re-run on your box, to see if the tests pass and try some filters? |
Output from test/re_test:
Looking into it a bit further. Environment:
Same errors with:
|
Also:
|
OK, I haven't tested with |
Ah, the reason is that the |
9847dc5
to
e749b82
Compare
New commits fix this. They use I've fixed up the compiler flag tests as well as they weren't actually working. |
I checked |
Merged! Thanks! Now to dig into why clang doesn't like std::regex :( |
|
I haven't actually used
|
It is, but libstdc++ isn't. Or something. We could use libc++ if it is available but I'm not sure it is worth it.
|
Ah, understood. Problem for another day... On to the Windows porting!
|
I would like to get
benchmark
working on Windows. I see that #29 has done a lot of work in that respect but resulted in #30 about the replacement of theRegex
class withstd::regex
.This PR implements a C++11 backend to the
Regex
class that passes the unit tests. This is more to start a discussion of how to proceed with this branch.From what I can see
Regex
is only used in one place inbenchmark.cc
so theRegex
class could be dropped all together. However this is opposed by @dominichamonSo I need to make the unit tests much more thorough than what they are now. I'm not sure what strings I should be testing to make sure that the C++11 backend is actually doing the same thing (it uses the same
extended
matching flags).There are other issues here, whilst
__cplusplus >= 201103L
is the correct check to work out if we are in C++11 modegcc
4.7
and4.8
don't actually have<regex>
it only came in4.9
. So switching to just usingstd::regex
would result in dropping support for anything before4.9
. So a much better check would be for CMake to compile a snippet to work out if we have regular expressions and fallback to POSIX regular expressions as neccessary.Soooooo, where shall we go from here? I'm happy to put in as much effort as needed until
benchmark
builds from CMake for MinGW. VS should drop out nicely from this as CMake is awesome...but MSVC is crap so who knows what will happen there. Maybeclang
to the rescue 😉