i-MSCP backend - Unit tests

  • 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

    Shell-Script
    1. # cd /usr/local/src/imscp# perl ./test/perlunit.pl


    If all goes well (all tests are ok), you must get a result such as:


    Shell-Script
    1. 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:



    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.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • get:

    Code
    1. 1..20
    2. Can't locate iMSCP/Dir.pm in @INC (you may need to install the iMSCP::Dir module) (@INC contains: /usr/local/src/imscp/engine/PerlLib /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/x86_64-linux-gnu/perl5/5.20 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) at engine/PerlLib/test/iMSCP/DirTests.pm line 5.
    3. BEGIN failed--compilation aborted at engine/PerlLib/test/iMSCP/DirTests.pm line 5.
    4. # Looks like your test exited with 2 before it could output anything.
  • @Cool, I'm fixing that on the travis branch atm ;) I'll update the first thread once done.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • @Cool


    You can retry now with 1.2.x branch. My previous posts were updated accordingly ;)
    Normally, all should be ok now. At least, Travic CI seem happy:


    Shell-Script
    1. -imscp-bot/#i-mscp-dev- [imscp] nuxwin pushed 1 new commit to 1.2.x: https://github.com/i-MSCP/imscp/commit/a7db623db6105365792fde12401d438a066526ad
    2. -imscp-bot/#i-mscp-dev- imscp/1.2.x a7db623 Laurent Declercq: Fixed: Travis CI
    3. * travis-ci (~travis-ci@ec2-23-20-159-253.compute-1.amazonaws.com) a rejoint #i-mscp-dev
    4. <travis-ci> i-MSCP/imscp#15 (1.2.x - a7db623 : Laurent Declercq): The build passed.
    5. <travis-ci> Change view : https://github.com/i-MSCP/imscp/compare/6d7e5d231d47...a7db623db610
    6. <travis-ci> Build details : https://travis-ci.org/i-MSCP/imscp/builds/72657826
    7. * travis-ci (~travis-ci@ec2-23-20-159-253.compute-1.amazonaws.com) a quitté #i-mscp-dev

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206