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

Changed from google test to catch #961

Merged
merged 5 commits into from Oct 29, 2018
Merged

Changed from google test to catch #961

merged 5 commits into from Oct 29, 2018

Conversation

teseoch
Copy link
Collaborator

@teseoch teseoch commented Oct 19, 2018

Still missing to port INSTANTIATE_TEST_CASE_P

Check all that apply (change to [x])

  • All changes meet libigl style-guidelines.
  • Adds new .cpp file.
  • Adds corresponding unit test.
  • Adds corresponding python binding.
  • This is a minor change.

Copy link
Contributor

@alecjacobson alecjacobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. We can't merge until all tests are ported.


SET(TEST_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
list(APPEND CMAKE_MODULE_PATH ${LIBIGL_EXTERNAL}/Catch2/contrib)
INCLUDE_DIRECTORIES(${TEST_ROOT_DIR})
Copy link
Collaborator

@jdumas jdumas Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the TEST_ROOT_DIR and the include_directory can go away now. Or at least should use an interface target like the tutorials.


# Process code in each subdirectories: add in decreasing order of complexity
# (last added will run first and those should be the fastest tests)
IF(LIBIGL_WITH_MOSEK)
ADD_SUBDIRECTORY(${TEST_ROOT_DIR}/include/igl/mosek)
file(GLOB TEST_SRC_FILES ${TEST_ROOT_DIR}/include/igl/mosek/*.cpp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${TEST_ROOT_DIR}/ is just . in this case, can be removed.

file(GLOB TEST_INC_FILES ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.h ${TEST_ROOT_DIR}/include/igl/copyleft/boolean/*.inl ${TEST_ROOT_DIR}/include/igl/copyleft/cgal/*.inl)
target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES})

target_link_libraries(libigl_tests PUBLIC igl::igl::cgal)
Copy link
Collaborator

@jdumas jdumas Oct 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be target_link_libraries(libigl_tests PUBLIC igl::cgal)

@@ -31,32 +31,32 @@ TEST(avg_edge_length, cube)
double avg;

avg = igl::avg_edge_length(V,F);
ASSERT_NEAR((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.), avg, epsilon);
REQUIRE (avg == Approx ((12.*sqrt(side_sq) + 6.*sqrt(diag_sq))/(12.+6.)).margin( epsilon));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the space between the macro and the parenthesis (to keep it consistent).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part was autogenerated with a script. There might be a lot of cases like that. I dont think it is worth to time investment

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find tests/ -exec sed -i 's/REQUIRE (/REQUIRE(/g' {} \; (may need to escape the ().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On mac you need sed -i "" 's/...' instead.

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 22, 2018

I fixed the couple of stuff in the cmake and reneabled the test with parameters.

With respect to the old version, it generates only 1 test case per set of parameters. I think it makes more sense.

@danielepanozzo
Copy link
Contributor

Mmm it seems to me that all tests have been ported (except bbw on windows which has some issues, but the test passes on mac and linux). @teseoch could you confirm? If that's the case I think we should merge this ASAP and polish it later. This PR is blocking all the other ones that require unit tests.

@alecjacobson
Copy link
Contributor

alecjacobson commented Oct 23, 2018 via email

@jdumas
Copy link
Collaborator

jdumas commented Oct 23, 2018

There's only one other PRs (for embree). But the documentation on the website for the unit tests is a bit outdated (it still refers to the old repo).

@alecjacobson
Copy link
Contributor

alecjacobson commented Oct 23, 2018 via email

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 23, 2018

I have used this script to convert gtest into catch2 testes
MigrateFromGoogleTestToCatch.py.zip

@danielepanozzo
Copy link
Contributor

This looks good to me and the script is a good way to convert old tests. @alecjacobson can we merge? I would like to enable the testing on windows which depends on this PR.

@jdumas
Copy link
Collaborator

jdumas commented Oct 24, 2018

Enabling the testing on Windows is independent from this PR, it's just a matter of setting proper flags in the CMake.

@fwilliams
Copy link
Collaborator

Can we merge #952 (which uses Google Test) before we merge this PR?

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 24, 2018

@alecjacobson can you review your review?

@@ -134,10 +134,10 @@ function(igl_download_triangle)
endfunction()

## Google test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of date comment.

@qnzhou
Copy link
Collaborator

qnzhou commented Oct 26, 2018

I also have some unit tests that I want to create and push, but maybe it is better to wait until this pr is merged?

@jdumas
Copy link
Collaborator

jdumas commented Oct 26, 2018

It'd make sense to merge this one first and then convert existing PRs and use Catch2 for writing new tests.

@qnzhou
Copy link
Collaborator

qnzhou commented Oct 26, 2018

Also, catch2 has the interesting tag feature. Currently, we are using the same tag, [igl], for most test cases. We could create some convention on tagging unit tests so it is easier to run a specific subset of tests.

@jdumas
Copy link
Collaborator

jdumas commented Oct 26, 2018

Agreed. Can have one tag per module for now (core, cgal, embree, etc.).

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 26, 2018

i am using the suite name for the different modules eg TEST_CASE("CSGTree: extrusion", "[igl/copyleft/cgal]")

shall we merge?

@alecjacobson
Copy link
Contributor

@teseoch does that script work for TEST and TEST_P ?

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 29, 2018

@alecjacobson no the script dosent work with TEST_P.

To change the TEST_P you need to move the content of the TEST_P in a lambda like const auto test_case = [](const std::string &param), then call test_common::run_test_cases(test_common::all_meshes(), test_case); where the first parameter is the stuff inside INSTANTIATE_TEST_CASE_P.

You can look at the this file:
https://github.com/libigl/libigl/pull/961/files#diff-10f6cbc342547d20dcb837dc856f9912
to see the small changes

@alecjacobson
Copy link
Contributor

Is it possible to script this? There are some new tests that need to be converted.

@jdumas
Copy link
Collaborator

jdumas commented Oct 29, 2018

Unless you have >10 new tests that use TEST_P, it might be faster to convert them by hand. The script converts the normal TEST though.

@teseoch
Copy link
Collaborator Author

teseoch commented Oct 29, 2018

can we merge before pushing new tests?

@alecjacobson alecjacobson merged commit 7f7551a into libigl:dev Oct 29, 2018
@teseoch teseoch deleted the catch2 branch October 29, 2018 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants