Browse Source

minimal documentation, slight Makefile fix

google-ENGINE-325-testing
parent
commit
154281fdec
3 changed files with 65 additions and 14 deletions
  1. +6
    -3
      test/Makefile
  2. +59
    -0
      test/README.md
  3. +0
    -11
      test/README.txt

+ 6
- 3
test/Makefile View File

@ -5,9 +5,12 @@
HERE:=$(CURDIR)
# Presumably can be changed in local.conf by putting this here?
GTEST_DIR:=googletest/googletest
GTEST_PL_DIR:=googletest/gtest-parallel
include ../Makefile.conf
GTEST_DIR:=googletest/googletest
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
DEPS:=$(OBJS:.o=.d)
@ -106,11 +109,11 @@ gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
${CXX} ${CXXFLAGS} $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -isystem $(GTEST_DIR)/include -o $@ -c $<
test: all
$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
$(TEST_CMD_PFX) $(TEST_DEBUGGER) python3 $(GTEST_PL_DIR)/gtest_parallel.py ./$(TARGET)
clean:
$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
$(RM) gtest_main.o gtest-all.o
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)


+ 59
- 0
test/README.md View File

@ -0,0 +1,59 @@
# Building the Engine Test Suite
## Caveat, before you begin
Right now, the engine tests only function on \*nix-like systems (including MacOS). (Conversion to Windows will require, at the very least, looking at some of the file-handling code.) If you want to fix this, start by looking in Engine.cc in the test/src directory!
## Requirements
In addition to the engine requirements, you will need:
* cmake
* python3
## Preparing to build
The Engine test suite now requires (at least) two additional pieces to run - **googletest** and **gtest-parallel**. You will note that I give specific instructions about where to put these, because that is what I have tried and tested. That does NOT mean other things won’t work; I simply haven’t tried them. So without further ado…
### googletest
**googletest** is an XUnit testing framework we are now using in place of cpptest. Unlike a lot of other testing frameworks, it’s recommended that you compile and link the test code directly within your project. These instructions do with with **cmake**. If you can manage it with **bazel** instead, more power to you ;)
So. To get things started.
In the directory of your choice (default, if you don’t want to change **local.conf** - specifically **GTEST\_DIR** - is the test directory (this one, presumably)):
1. git clone https://github.com/google/googletest.git
2. cd googletest
3. cmake .
4. make
(Note that this hasn’t been tested in other directories, so I am presuming the Makefile works as is, but I could be wrong)
### gtest-parallel
### Again, in the directory of your choice (if you want to use the Makefile out of the box, you should, while still in the googletest directory, do the following):
1. git clone https://github.com/google/gtest-parallel.git
2. If using a different directory, please change **GTEST\_PL\_DIR** to indicate where **gtest-parallel.py** is located.
## Building the test suite
Presuming the above works, then from the top test directory, simply run make.
# Running the Engine Test Suite
If you simply want to run the suite and see what tests fail, either:
1. make test OR
2. python3 \<path to gtest-parallel.py\> ./EngineTests
To run individual tests, especially for debugging purposes:
1. Blah, and, for example,
2. {lldb ./EngineTests some-blah-args-here}
# Creating new tests
Script next on the agenda...

+ 0
- 11
test/README.txt View File

@ -1,11 +0,0 @@
DOCUMENTATION AND CLEANUP FORTHCOMING.
Engine tests now require libcpptest - if you have compilation failures using your distribution's lib (I'm looking at you, Ubuntu), please download the source at http://cpptest.sourceforge.net/, compile, and run.
New test creation requires python 3.x.
Notes:
- TEST_ASSERT is a macro and does not always behave 100% the way you'd expect. Note the following:
* 1. If used in if/else blocks, make sure the blocks are guarded, or weird things happen.
* 2. If performing comparisons, please parenthesise liberally - bitwise operations being compared to 0 should always be parenthesised before comparison

Loading…
Cancel
Save