Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-46644

PHP unit test error caused in Windows with SQL Server attempting to remove locked log file

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.1
    • Fix Version/s: None
    • Component/s: Questions, Unit tests
    • Labels:
    • Affected Branches:
      MOODLE_27_STABLE
    • Epic Link:

      Description

      When running unit tests on Windows while using SQL Server, an error occurs during or after the test "core_questionlib_testcase::test_altering_tag_instance_context".

      In an attempt to clean up, there is a recursive deletion of the temp directory, but a log file seems to be locked and is not able to be deleted. This has the effect of causing errors in many of the subsequent unit tests.

      It's odd that this happens with the SQL Server driver, but not with other drivers.

      I don't believe this is a random timing issue with the Windows file system as it happens consistently and at the same point each time.

      I was able to debug the unit test and force a stack trace.

      ...
      Starting test 'core_questionlib_testcase::test_match_grade_options'.
      .
      Starting test 'core_questionlib_testcase::test_altering_tag_instance_context'.
      E
      Warning: unlink(D:\xampp\data\master_integration_MSSQL_phpunit/temp/backup/e38f40aaf2e8266e9baf0a3739c43399.log): Permission denied in D:\xampp\htdocs\master_integration\lib\moodlelib.php on line 9054
       
      #0  remove_dir() called at [D:\xampp\htdocs\master_integration\lib\moodlelib.php:9052]
      #1  remove_dir() called at [D:\xampp\htdocs\master_integration\lib\testing\classes\util.php:720]
      #2  testing_util::reset_dataroot() called at [D:\xampp\htdocs\master_integration\lib\phpunit\classes\util.php:229]
      #3  phpunit_util::reset_all_data() called at [D:\xampp\htdocs\master_integration\lib\phpunit\classes\advanced_testcase.php:449]
      #4  advanced_testcase::tearDownAfterClass()
      #5  call_user_func() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\Framework\TestSuite.php:760]
      #6  PHPUnit_Framework_TestSuite->run() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\Framework\TestSuite.php:709]
      #7  PHPUnit_Framework_TestSuite->run() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\Framework\TestSuite.php:709]
      #8  PHPUnit_Framework_TestSuite->run() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\TextUI\TestRunner.php:350]
      #9  PHPUnit_TextUI_TestRunner->doRun() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\TextUI\Command.php:176]
      #10 PHPUnit_TextUI_Command->run() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\PHPUnit\TextUI\Command.php:129]
      #11 PHPUnit_TextUI_Command::main() called at [D:\xampp\htdocs\master_integration\vendor\phpunit\phpunit\composer\bin\phpunit:63]
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: