Hello community;
We are on the point to add unit tests for the i-MSCP backend. If you want help us, feel free to fork the 1.2.x branch and do some PR.
How to process exactly?
For now, we want cover the lilbraries which are stored inside the engine/PerlLib/iMSCP directory. We've already added several unit tests for the iMSCP::Dir library. You can find them by looking at https://github.com/i-MSCP/imsc…st/Perl/Test/iMSCP/Dir.pm
How to run unit tests manually?
You can run the unit tests as follow
If all goes well (all tests are ok), you must get a result such as:
- Running unit tests from Test::iMSCP::Dir...ok 1 - require iMSCP::Dir;ok 2 - iMSCP::Dir::getFiles() die on missing dirname parameterok 3 - iMSCP::Dir::getFiles() die if cannot open dirnameok 4 - iMSCP::Dir::getFiles() return expected filenamesok 5 - iMSCP::Dir::getFiles() return expected filtered file typeok 6 - iMSCP::Dir::getDirs() die on missing dirname parameterok 7 - iMSCP::Dir::getDirs() die if cannot open dirnameok 8 - iMSCP::Dir::getDirs() return expected dirnamesok 9 - iMSCP::Dir::getAll() die on missing dirname parameterok 10 - iMSCP::Dir::getAll() die if cannot open dirnameok 11 - iMSCP::Dir::getAll() return expected dirnames and filenamesok 12 - iMSCP::Dir::isEmpty() die on missing dirname parameterok 13 - iMSCP::Dir::isEmpty() die if cannot open dirnameok 14 - iMSCP::Dir::isEmpty() return false if dirname is not emptyok 15 - iMSCP::Dir::make() die on missing dirname attributeok 16 - iMSCP::Dir::make() die if dirname already exists as fileok 17 - iMSCP::Dir::make() can create dirok 18 - iMSCP::Dir::make() can create pathok 19 - iMSCP::Dir::remove() die on missing dirname parameterok 20 - iMSCP::Dir::remove() can remove dirok 21 - iMSCP::Dir::remove() can remove path1..21
but if something fail (a test fail), you must get a result such as:
- Running unit tests from Test::iMSCP::Dir...
- ok 1 - require iMSCP::Dir;
- ok 2 - iMSCP::Dir::getFiles() die on missing dirname parameter
- ok 3 - iMSCP::Dir::getFiles() die if cannot open dirname
- ok 4 - iMSCP::Dir::getFiles() return expected filenames
- ok 5 - iMSCP::Dir::getFiles() return expected filtered file type
- ok 6 - iMSCP::Dir::getDirs() die on missing dirname parameter
- ok 7 - iMSCP::Dir::getDirs() die if cannot open dirname
- ok 8 - iMSCP::Dir::getDirs() return expected dirnames
- ok 9 - iMSCP::Dir::getAll() die on missing dirname parameter
- ok 10 - iMSCP::Dir::getAll() die if cannot open dirname
- ok 11 - iMSCP::Dir::getAll() return expected dirnames and filenames
- ok 12 - iMSCP::Dir::isEmpty() die on missing dirname parameter
- ok 13 - iMSCP::Dir::isEmpty() die if cannot open dirname
- ok 14 - iMSCP::Dir::isEmpty() return false if dirname is not empty
- ok 15 - iMSCP::Dir::make() die on missing dirname attribute
- ok 16 - iMSCP::Dir::make() die if dirname already exists as file
- not ok 17 - iMSCP::Dir::make() can create dir
- # Failed test 'iMSCP::Dir::make() can create dir'
- # at /usr/local/src/imscp/test/Perl/Test/iMSCP/Dir.pm line 303.
- ok 18 - iMSCP::Dir::make() can create path
- ok 19 - iMSCP::Dir::remove() die on missing dirname parameter
- ok 20 - iMSCP::Dir::remove() can remove dir
- ok 21 - iMSCP::Dir::remove() can remove path
- 1..21
- # Looks like you failed 1 test of 21.
Be aware that for now, it is assumed that your imscp archve is stored under the /usr/local/src directory.
The unit tests are run automatically on every commit and/or PR (pull request). Any pull request causing a build failure won't be accepted.
Thanks you for your help.