Improve test/README.md sync
authorNeal H. Walfield <neal@pep.foundation>
Sat, 23 Nov 2019 19:47:08 +0100
branchsync
changeset 4216de70d8f412cf
parent 4215 7285293cdd79
child 4217 738d4cbc5af5
Improve test/README.md

- Document an even easier way to use google test on Debian.

- Add a note about --gtest_break_on_failure.
test/README.md
     1.1 --- a/test/README.md	Sat Nov 23 19:42:21 2019 +0100
     1.2 +++ b/test/README.md	Sat Nov 23 19:47:08 2019 +0100
     1.3 @@ -41,27 +41,29 @@
     1.4  
     1.5  ##### Debian and Ubuntu (and derivatives)
     1.6  
     1.7 -Thanks to Erik Smistad for this starting point (condensed from [Getting Started
     1.8 -with Google Test On
     1.9 -Ubuntu](https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/)):
    1.10 +Using the libgtest-dev is easy, but not straightforward.
    1.11 +Unfortunately, the version of google test in Debian Buster is too old:
    1.12 +it's version 1.8 and we require version 1.9.  Version 1.9 is available
    1.13 +in Debian Testing, but it is built with g++ 9.0, which is ABI
    1.14 +incompatible with binaries built with g++ 8.0, which is in Debian
    1.15 +stable.  Specifically, gcc has changed the semantics of std::string
    1.16 +with C++11 and using g++ 8.0 results in the errors like the following:
    1.17  
    1.18 -  1. Install the packages `cmake` and `libgtest-dev` from the repository. This
    1.19 -  will install the gtest source files to `/usr/src/gtest`. You'll still need to
    1.20 -  compile the code and link the library files to be able to use them.
    1.21 +    undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()'
    1.22  
    1.23 -  2. Compile the source files:
    1.24 -  ```
    1.25 -  cd /usr/src/gtest
    1.26 -  sudo cmake CMakeLists.txt
    1.27 -  sudo make
    1.28 -  ```
    1.29 +It's possible to install g++ 9.0 from testing to get the test suite
    1.30 +working, but that breaks other things (at least for me -Neal).
    1.31 +Instead, the easiest thing to do it to rebuild gtest for Debian
    1.32 +Stable.  This is straightforward:
    1.33  
    1.34 -  3. Copy/symlink the libraries to the library location of your choice (here,
    1.35 -  it's `/usr/lib`, hence the `sudo`, but as long as it's in your library path,
    1.36 -  it shouldn't matter where you stick it):
    1.37 -  ```
    1.38 -  sudo cp *.a /usr/lib
    1.39 -  ```
    1.40 +  $ sudo apt install build-essential cmake debhelper
    1.41 +  $ apt source -t testing libgtest-dev
    1.42 +  $ cd googletest-1.9.0.20190831
    1.43 +  $ dpkg-buildpackage -us -uc
    1.44 +  ...
    1.45 +  $ sudo dpkg -i googletest_1.9.0.20190831-1_amd64.deb libgtest-dev_1.9.0.20190831-1_amd64.deb
    1.46 +
    1.47 +That's it.
    1.48  
    1.49  ##### MacOS
    1.50  
    1.51 @@ -197,6 +199,9 @@
    1.52    gdb --args ./EngineTests --gtest_filter=TestSuiteName.test_function_name
    1.53    ```
    1.54  
    1.55 +When debugging a failing test, use '--gtest_break_on_failure' to have
    1.56 +gtest automatically break into the debugger where the assertion fails.
    1.57 +
    1.58  # Creating new tests
    1.59  
    1.60  Script next on the agenda...