-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Get unit tests building again. #8360
Get unit tests building again. #8360
Conversation
line_test compiles, runs and seems to be working, player_test compiles and runs, but crashes during initialization like so: The problem seems to be that ACTIVE_WORLD_OPTIONS isn't getting initialized. |
@kevingranade I was considering trying to add Google Test and Google Mock support. It would probably have to be included as source and compiled along with any unit tests in order to support all of the cross platform stuff. Would you be open to that, or are you opposed to adding that dependency? gtest and gmock are some of the easiest to use of the c++ testing frameworks IMO, and well supported. |
I'm not a fan of adding dependencies, but since testing isn't mandatory for building, this could be a reasonable exception. If you make a PR with some working and useful tests to get the ball rolling, I can't see turning it down. |
I guess it's really the mocking frameworks that are more differentiated than the testing frameworks themselves. I don't have more than a passing familiarity with Catch, does it support mocking? Being able to break internal dependencies (and external dependencies) with mocks makes testing complicated stuff an order of magnitude easier. |
ec0abae
to
f48f788
Compare
Refreshed again, this should build on any platform dda can build on in the first place since Catch is pulled into the repository, and it has some reasonable tests now. |
@@ -14,9 +14,10 @@ SOURCE_OBJS = $(patsubst %,../$(ODIR)/%,$(filter-out main.o,$(_OBJS))) | |||
|
|||
ODIR := obj | |||
|
|||
LDFLAGS += -L. -ltap++ -lboost_regex -lpthread | |||
LDFLAGS += -L. |
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.
On my system, I need to add -lrt
to get clock_gettime
.
Good to go I think, the player temperature test still doesn't work, but the right fix for that is breaking the player/game/map dependency thicket, and that's going to take some time. |
Anybody? I can guarantee it's not going to break anything >_< |
I've held off on this because I'm not familiar enough with unit tests to properly mergetest it. If nobody else does so before then, I'll attempt to mergetest it in a few days. |
If you use make, it's just:
make tests
tests/test_name1
Tests/test_name2
This reminds me, I should add a test build target to the C::B project file.
Slightly more depth:
The unit tests are micro-programs that run pieces of game code and check
that the results are what we expect, I pulled in a test framework to make
them a little easier to write. You can write your own test harness and
test runner, but it's a pain.
Future plan
Ideally we start having decent coverage of parts of the code that change a
lot and/or are prone to breakage, and we can run them as a first step in
checking out a new PR and when we make our own changes.
|
Get unit tests building again.
Reverse some of the bitrot of the minimal unit tests.
I'm looking into some header-only unit test frameworks to include so that people don't have to grab a dependency to build/run the unit tests. Recommendations are welcome.
The front runner at the moment is https://github.com/philsquared/Catch