You are here

class TravisLogEventListener in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 tests/src/TravisLogEventListener.php \Drupal\Tests\search_api_solr\TravisLogEventListener

Hierarchy

Expanded class hierarchy of TravisLogEventListener

File

tests/src/TravisLogEventListener.php, line 13

Namespace

Drupal\Tests\search_api_solr
View source
class TravisLogEventListener implements TestListener {

  /**
   * @var bool
   */
  protected $errors;
  public function addWarning(Test $test, Warning $e, $time) {
    $this->errors = TRUE;
    file_put_contents(TRAVIS_BUILD_DIR . '/solr.error.log', printf("Warning while running test '%s'.\n", $test
      ->getName()), FILE_APPEND | LOCK_EX);
  }
  public function addError(Test $test, \Exception $e, $time) {
    $this->errors = TRUE;
    file_put_contents(TRAVIS_BUILD_DIR . '/solr.error.log', printf("Error while running test '%s'.\n", $test
      ->getName()), FILE_APPEND | LOCK_EX);
  }
  public function addFailure(Test $test, AssertionFailedError $e, $time) {
    $this->errors = TRUE;
    file_put_contents(TRAVIS_BUILD_DIR . '/solr.error.log', printf("Test '%s' failed.\n", $test
      ->getName()), FILE_APPEND | LOCK_EX);
  }
  public function addIncompleteTest(Test $test, \Exception $e, $time) {
  }
  public function addRiskyTest(Test $test, \Exception $e, $time) {
  }
  public function addSkippedTest(Test $test, \Exception $e, $time) {
  }
  public function startTest(Test $test) {

    // In case of a runtime error in the previous test, keep the log.
    if (file_exists(TRAVIS_BUILD_DIR . '/solr.query.log')) {
      file_put_contents(TRAVIS_BUILD_DIR . '/solr.error.log', file_get_contents(TRAVIS_BUILD_DIR . '/solr.query.log'), FILE_APPEND | LOCK_EX);
    }
    $this->errors = FALSE;
  }
  public function endTest(Test $test, $time) {
    if (file_exists(TRAVIS_BUILD_DIR . '/solr.query.log')) {
      if ($this->errors) {
        file_put_contents(TRAVIS_BUILD_DIR . '/solr.error.log', file_get_contents(TRAVIS_BUILD_DIR . '/solr.query.log'), FILE_APPEND | LOCK_EX);
      }
      unlink(TRAVIS_BUILD_DIR . '/solr.query.log');
    }
  }
  public function startTestSuite(TestSuite $suite) {
  }
  public function endTestSuite(TestSuite $suite) {
  }

}

Members