TBD...
- Docker
- Google Test and Google Mock
- C++20
- clang-format (recommended minimum ver. 17)
- OpenSSL
find . -name '*.cpp' -or -name '*.hpp' | xargs clang-format --verbose -style=file -i
# run once after repo download if permission problem occurs
chmod +x ./clang-fmt-all.sh
# run from the top of workspace directory
./clang-fmt-all.sh
docker build -t desktop-business-application .
docker run -it --entrypoint /bin/bash desktop-business-application
docker run -it --entrypoint="/application/bin/desktop-business-app-tests" desktop-business-application
After building test target locally we can run all tests:
cd bin
./desktop-business-app-tests
Or we can limit testing to some tests according to our needs (finding best phrase in our test code like test-case name), for example:
cd bin
./desktop-business-app-tests --gtest_filter="*ReceptionistTestFixture*"
xhost +local:docker
docker run --net=host -e DISPLAY=$DISPLAY desktop-business-application
Example of installing valgrind
on ubuntu:
sudo apt install valgrind
After building tests for example one can run valgrind on tests:
cd bin
valgrind --leak-check=full ./desktop-business-app-tests
If we want to limit our output somehow, we can find a best identification string in our test's name and use it like this:
valgrind --leak-check=full ./desktop-business-app-tests --gtest_filter="*Association*"
Two scripts are provided for convenience of building "backend" and "tests" targets (they might require privilages adding):
- clean build of backend
./backend_clean_build.sh
Please note that this makes clean build of backend, so if you have just minor changes it might be more convenient to rebuild manually. This will not rebuild external_libraries from scratch if they exist and there is no version change.
- clean build of tests with previous clean build of backend
./tests_and_backend_clean_build.sh
Please note that this makes clean build of backend and test, so if you have just minor changes or just tests-changes for example might be more convenient to rebuild manually. This will not rebuild external_libraries from scratch if they exist and there is no version change.
After building test targets, ctest running all the tests can be run in 2 ways:
- from
build
directory, simply using commandctest
- from main desktop-app-folder via script
I recommend using script. It is tailored to print main info and just failed tests
./ctest_run.sh
We can mount a local directory (volume) to Docker container. This way any changes we make locally will immediately be reflected in the conatiner without need to rebuild the image every time.
To work with it follow steps:
- Run script run_container.sh Now you should have working container, which is detached and is running in the background. You can check it using command:
docker ps
You should see output as follows:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
37383cccbce3 desktop-business-app "tail -f /dev/null" 5 hours ago Up 43 minutes desktop-business-app
- Enter docker container To enter docker container use docker exec command
docker exec -it desktop-business-app /bin/bash
Now you should be inside docker container named desktop-business-app. You can add them to your .bashrc file. I recommand adding aliases to speed up work
alias doe="docker exec -it desktop-business-app /bin/bash"
alias domake="docker exec desktop-business-app make -C /application/build"
alias dotest="docker exec desktop-business-app ctest --test-dir /application/build"