Moodle
  1. Moodle
  2. MDL-37640

Zip unit tests failing under Windows

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.5
    • Component/s: Unit tests
    • Labels:
    • Rank:
      47333

      Description

      When running the unit tests under Windows, the tests in lib\filestorage\tests\zip_packer_test.php fail at a specific point, claiming permission problems...

      D:\xampp\htdocs\master_integration>phpunit -v --debug lib\filestorage\tests\zip_
      packer_test.php
      PHPUnit 3.7.9 by Sebastian Bergmann.
      
      Configuration read from D:\xampp\htdocs\master_integration\phpunit.xml
      
      
      Starting test 'zip_packer_testcase::test_get_packer'.
      .
      Starting test 'zip_packer_testcase::test_list_files'.
      .
      Starting test 'zip_packer_testcase::test_archive_to_pathname'.
      .
      Starting test 'zip_packer_testcase::test_archive_to_storage'.
      .
      Starting test 'zip_packer_testcase::test_extract_to_pathname'.
      .
      Starting test 'zip_packer_testcase::test_extract_to_pathname_onlyfiles'.
      .
      Starting test 'zip_packer_testcase::test_extract_to_storage'.
      .
      Starting test 'zip_packer_testcase::test_add_files'.
      ES
      Warning: mkdir(): Permission denied in D:\xampp\htdocs\master_integration\lib\se
      tuplib.php on line 1213
      
      Fatal error: Uncaught exception 'invalid_dataroot_permissions' with message 'Inv
      alid permissions detected in $CFG->dataroot directory, administrator has to fix
      permissions. (D:\xampp\Data\master_integration_MySQL_phpunit/temp/ can not be cr
      eated, check permissions.)' in D:\xampp\htdocs\master_integration\lib\setuplib.p
      hp:1215
      Stack trace:
      #0 D:\xampp\htdocs\master_integration\lib\setuplib.php(1288): make_writable_dire
      ctory('D:\xampp\Data\m...', true)
      #1 D:\xampp\htdocs\master_integration\lib\testing\classes\util.php(599): make_te
      mp_directory('')
      #2 D:\xampp\htdocs\master_integration\lib\phpunit\classes\util.php(195): testing
      _util::reset_dataroot()
      #3 D:\xampp\htdocs\master_integration\lib\phpunit\classes\advanced_testcase.php(
      331): phpunit_util::reset_all_data()
      #4 [internal function]: advanced_testcase::tearDownAfterClass()
      #5 D:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php(756): call_user_func(Array)
      
      #6 D:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php(346): PHPUnit_Framework_TestS
      uite->run(Object(PHPUnit_Framework_Test in D:\xampp\htdocs\master_integration\li
      b\setuplib.php on line 1215
      

      Even though a permission error is reported, I don't believe that is the case. I'm not sure exactly what's going on, but looking at the directory involved, there's no permission stopping this test in the specified directory.

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Raj was kind enough to verify this error under Windows.

          Show
          Michael de Raadt added a comment - Raj was kind enough to verify this error under Windows.
          Hide
          Petr Škoda added a comment -

          Hmm, if you get this type of permission error Moodle zipping can not work. Please double check the permissions for current user in the phpunit dataroot.

          Show
          Petr Škoda added a comment - Hmm, if you get this type of permission error Moodle zipping can not work. Please double check the permissions for current user in the phpunit dataroot.
          Hide
          Petr Škoda added a comment -

          rehmm, maybe some open file handle somewhere

          Show
          Petr Škoda added a comment - rehmm, maybe some open file handle somewhere
          Hide
          Petr Škoda added a comment -

          Could you please try the patched testcase? I hope I found it, but I do not have windows test setup, sorry.

          Show
          Petr Škoda added a comment - Could you please try the patched testcase? I hope I found it, but I do not have windows test setup, sorry.
          Hide
          Michael de Raadt added a comment -

          Hi, Petr.

          I added those statements, but I am still getting the same result. There is one very minor change: instead of ES before the error message, it now only reports E.

          I'm still confident this is not a permission issue. Removed the phpunit directory for the instance and set it up again. I only ran this set of tests. Before the tests start there is a temp directory. After the tests fail, there is no temp directory.

          Show
          Michael de Raadt added a comment - Hi, Petr. I added those statements, but I am still getting the same result. There is one very minor change: instead of ES before the error message, it now only reports E. I'm still confident this is not a permission issue. Removed the phpunit directory for the instance and set it up again. I only ran this set of tests. Before the tests start there is a temp directory. After the tests fail, there is no temp directory.
          Hide
          Tim Hunt added a comment -

          +1 this fixes the unit tests on Windows for me.

          Show
          Tim Hunt added a comment - +1 this fixes the unit tests on Windows for me.
          Hide
          Petr Škoda added a comment -

          Thanks a lot Tim!

          Show
          Petr Škoda added a comment - Thanks a lot Tim!
          Hide
          Sam Hemelryk added a comment -

          Thanks Petr - nice and easy integrated now.

          Show
          Sam Hemelryk added a comment - Thanks Petr - nice and easy integrated now.
          Hide
          Michael de Raadt added a comment -

          This now works under Windows. I'm leaving this for Damyon to test under Linux.

          Show
          Michael de Raadt added a comment - This now works under Windows. I'm leaving this for Damyon to test under Linux.
          Hide
          Damyon Wiese added a comment -

          Tests on master pass under linux. Thanks!

          Show
          Damyon Wiese added a comment - Tests on master pass under linux. Thanks!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          A brilliant future is awaiting us out there, better with your code. Let's look towards the future together, this is now closed.

          (and won't be revisiting it unless some regression is found)

          Thanks and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - A brilliant future is awaiting us out there, better with your code. Let's look towards the future together, this is now closed. (and won't be revisiting it unless some regression is found) Thanks and ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: