Skip to content

Add restriction for unique test names#1422

Merged
rok-cesnovar merged 46 commits intodevelopfrom
feature/check-unique-test-name
Nov 29, 2019
Merged

Add restriction for unique test names#1422
rok-cesnovar merged 46 commits intodevelopfrom
feature/check-unique-test-name

Conversation

@rok-cesnovar
Copy link
Member

Summary

Fixes #1387

This PR adds the restriction of having unique names for TEST() and TEST_F() across the entire test/unit folder. It does so by adding a check to runChecks.py that looks for duplicates in all test/unit/*_test.cpp files.

Developers can verify they have not introduced non-unique names by running python runChecks.py.

The first commit will be the python script only. That way we can see the errors on Jenkins to verify that it works OK there. Then I will merge the cleanup branch that fixes all the errors.

Tests

/

Side Effects

/

Checklist

@rok-cesnovar
Copy link
Member Author

You can check how the error look like on Jenkins https://jenkins.mc-stan.org/blue/organizations/jenkins/Math%20Pipeline/detail/PR-1422/1/pipeline/

An example:

Tests or test fixtures with non-unqiue names found in test/unit:

(MathMatrix, matrix_exp_pade_1x1) in files:
	test/unit/math/rev/mat/fun/matrix_exp_pade_test.cpp
	test/unit/math/fwd/mat/fun/matrix_exp_pade_test.cpp
	test/unit/math/prim/mat/fun/matrix_exp_pade_test.cpp
(MathMatrix, matrix_exp_multiply_exception) in files:
	test/unit/math/rev/mat/fun/matrix_exp_multiply_test.cpp
	test/unit/math/prim/mat/fun/matrix_exp_multiply_test.cpp
(ErrorHandlingScalar, CheckNonnegative_nan) in files:
	test/unit/math/prim/scal/err/check_nonnegative_test.cpp
	test/unit/math/prim/arr/err/check_nonnegative_test.cpp
(MathMeta, value_type) in files:
	test/unit/math/rev/scal/meta/child_type_test.cpp
	test/unit/math/fwd/scal/meta/child_type_test.cpp
	test/unit/math/prim/scal/meta/child_type_test.cpp
	test/unit/math/prim/arr/meta/value_type_test.cpp
	test/unit/math/mix/scal/meta/child_type_test.cpp

@rok-cesnovar
Copy link
Member Author

This one is going to be a pain to review because this touches A LOT of files
So to help out here are the changes that are not just renaming tests:

  • 39395b2 removes unused tests that were behind #if 0
  • 8ecff0a deletes a test file that was never used (fma.hpp cant be triggered) and adds non-duplicates tests to fma_test.cpp
  • c80b13e removes duplicate tests

The rest just rename tests. I tried to make some of the generic labels like MathMatrix more specific with at least MathMatrixRevScal or something along those lines.

@rok-cesnovar
Copy link
Member Author

rok-cesnovar commented Oct 25, 2019

Also this will probably cause merge issues with @bob-carpenter's efforts on the test framework. I am also happy to hold off on this PR until that gets merged.

# Conflicts:
#	test/unit/math/prim/mat/fun/log_determinant_ldlt_test.cpp
#	test/unit/math/prim/mat/fun/matrix_exp_pade_test.cpp
#	test/unit/math/prim/mat/fun/matrix_exp_test.cpp
# Conflicts:
#	test/unit/math/prim/mat/fun/matrix_exp_multiply_test.cpp
#	test/unit/math/prim/mat/fun/scale_matrix_exp_multiply_test.cpp
#	test/unit/math/rev/mat/fun/scale_matrix_exp_multiply_test.cpp
Copy link
Contributor

@t4c1 t4c1 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 mostly fine, just some nitpicking from me.

rok-cesnovar and others added 5 commits November 25, 2019 14:03
Co-Authored-By: Tadej Ciglarič <tadej.c@gmail.com>
Co-Authored-By: Tadej Ciglarič <tadej.c@gmail.com>
Co-Authored-By: Tadej Ciglarič <tadej.c@gmail.com>
Co-Authored-By: Tadej Ciglarič <tadej.c@gmail.com>
Co-Authored-By: Tadej Ciglarič <tadej.c@gmail.com>
@rok-cesnovar rok-cesnovar requested a review from t4c1 November 25, 2019 13:27
@rok-cesnovar
Copy link
Member Author

Thanks for the python script comments! I think I addressed everything.

t4c1
t4c1 previously approved these changes Nov 25, 2019
Copy link
Contributor

@t4c1 t4c1 left a comment

Choose a reason for hiding this comment

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

Looks good.

@rok-cesnovar
Copy link
Member Author

There were some additional non-unique tests that were found after the merge. The push dismissed the review :/

Copy link
Contributor

@t4c1 t4c1 left a comment

Choose a reason for hiding this comment

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

Looks good.

@stan-buildbot
Copy link
Contributor

(stat_comp_benchmarks/benchmarks/gp_pois_regr/gp_pois_regr.stan, 1.01)
(stat_comp_benchmarks/benchmarks/low_dim_corr_gauss/low_dim_corr_gauss.stan, 1.01)
(stat_comp_benchmarks/benchmarks/irt_2pl/irt_2pl.stan, 0.99)
(stat_comp_benchmarks/benchmarks/pkpd/one_comp_mm_elim_abs.stan, 0.96)
(stat_comp_benchmarks/benchmarks/eight_schools/eight_schools.stan, 1.04)
(stat_comp_benchmarks/benchmarks/gp_regr/gp_regr.stan, 0.99)
(stat_comp_benchmarks/benchmarks/arK/arK.stan, 1.0)
(performance.compilation, 1.03)
(stat_comp_benchmarks/benchmarks/low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan, 1.0)
(stat_comp_benchmarks/benchmarks/low_dim_gauss_mix/low_dim_gauss_mix.stan, 1.0)
(stat_comp_benchmarks/benchmarks/sir/sir.stan, 1.01)
(stat_comp_benchmarks/benchmarks/pkpd/sim_one_comp_mm_elim_abs.stan, 1.02)
(stat_comp_benchmarks/benchmarks/garch/garch.stan, 1.01)
(stat_comp_benchmarks/benchmarks/gp_regr/gen_gp_data.stan, 0.98)
(stat_comp_benchmarks/benchmarks/arma/arma.stan, 1.0)
Result: 1.00333709785
Commit hash: 8795ab4

Copy link
Member

@syclik syclik left a comment

Choose a reason for hiding this comment

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

+1 from me.

@syclik
Copy link
Member

syclik commented Nov 28, 2019

@rok-cesnovar, somehow the tests haven't passed. Can you kick this off again?

Also, with this PR, has this been integrated into the continuous integration?

@rok-cesnovar
Copy link
Member Author

Yeah, some upstream tests timeouted or something weird. Restarted now.

These checks are part of runChecks.py that is run with make test-math-dependencies (https://github.com/stan-dev/math/blob/develop/Jenkinsfile#L131). Those are run in the first phases of a Jenkins tests.

An example of what the check does on develop (develop when I started this PR to be exact) is given here:
https://jenkins.mc-stan.org/blue/organizations/jenkins/Math%20Pipeline/detail/PR-1422/1/pipeline/

@rok-cesnovar
Copy link
Member Author

@serban-nicusor-toptal sorry to bother you again, this seems like a weird failure. It might be some issue I caused on this PR, but I am seeing no errors printed: https://jenkins.mc-stan.org/blue/organizations/jenkins/Math%20Pipeline/detail/PR-1422/33/pipeline

Thanks!

@serban-nicusor-toptal
Copy link
Contributor

serban-nicusor-toptal commented Nov 28, 2019

Fixed, was trying to run on the new windows machine. It was looking for an agent and it picked the new one because I didn't restrict it.

@stan-buildbot
Copy link
Contributor

(stat_comp_benchmarks/benchmarks/gp_pois_regr/gp_pois_regr.stan, 1.0)
(stat_comp_benchmarks/benchmarks/low_dim_corr_gauss/low_dim_corr_gauss.stan, 1.0)
(stat_comp_benchmarks/benchmarks/irt_2pl/irt_2pl.stan, 1.0)
(stat_comp_benchmarks/benchmarks/pkpd/one_comp_mm_elim_abs.stan, 1.06)
(stat_comp_benchmarks/benchmarks/eight_schools/eight_schools.stan, 1.05)
(stat_comp_benchmarks/benchmarks/gp_regr/gp_regr.stan, 0.99)
(stat_comp_benchmarks/benchmarks/arK/arK.stan, 0.99)
(performance.compilation, 1.03)
(stat_comp_benchmarks/benchmarks/low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan, 1.01)
(stat_comp_benchmarks/benchmarks/low_dim_gauss_mix/low_dim_gauss_mix.stan, 1.01)
(stat_comp_benchmarks/benchmarks/sir/sir.stan, 1.02)
(stat_comp_benchmarks/benchmarks/pkpd/sim_one_comp_mm_elim_abs.stan, 1.06)
(stat_comp_benchmarks/benchmarks/garch/garch.stan, 1.0)
(stat_comp_benchmarks/benchmarks/gp_regr/gen_gp_data.stan, 1.01)
(stat_comp_benchmarks/benchmarks/arma/arma.stan, 1.0)
Result: 1.01668932471
Commit hash: 8795ab4

@rok-cesnovar rok-cesnovar merged commit 601cba9 into develop Nov 29, 2019
@rok-cesnovar rok-cesnovar deleted the feature/check-unique-test-name branch November 29, 2019 18:11
@rok-cesnovar rok-cesnovar mentioned this pull request Dec 31, 2019
5 tasks
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

Successfully merging this pull request may close these issues.

Suggestion: enforce unique GoogleTest names

7 participants