Skip to content
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

Tips for running the automated tests #122

Open
julianharty opened this issue Oct 30, 2024 · 0 comments
Open

Tips for running the automated tests #122

julianharty opened this issue Oct 30, 2024 · 0 comments

Comments

@julianharty
Copy link
Contributor

Context

This project includes automated tests written using a main program rather than using a unit testing framework. Here's how to build and run these tests.

Clean before you start

Run make clean when switching to make the project and make the tests otherwise the make will fail either because there are multiple main functions available to the linker, or none.

  • make clean && make test to make the tests
  • make clean && make to make the program after making the tests

** More info**
A compilation flag of NO_MAIN is defined when the tests are compiled. When the project is clean the program's main is excluded and a separate one used for testing is included during the make process. If the make target changes between test and not building the tests then there is no dependency that causes the program's main to be recompiled with the current value of the compilation flag/without the compilation flag. Running the clean removes the object files for any main and means the next make command performs as intended.

Running the tests

Currently when make test runs it actually runs the tests silently and deletes the test program it created. If you'd like to see the tests run and/or capture a log of the test run, one way is to edit the Makefile along the following lines:

# Create a temporary folder for the output
mkdir tests/logs

# Edit the test target in the main Makefile to redirect the output of running the main generated to run the tests
cd tests/ && $(MAKE) && ./main > ./logs/tests.log && $(MAKE) clean

Note: the main program is still deleted as the final step in this make process, remove the final && $(MAKE) clean if you'd like to run the tests again afterwards.

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

No branches or pull requests

1 participant