/** * Ensure reports directory exists, empty, and has write permissions * * @throws \Magento\Framework\Exception */ public function cleanupReports() { $reportDir = $this->_config->getReportDir(); try { $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); if ($filesystemAdapter->isExists($reportDir)) { $filesystemAdapter->deleteDirectory($reportDir); } } catch (\Magento\Framework\Filesystem\FilesystemException $e) { if (file_exists($reportDir)) { throw new \Magento\Framework\Exception("Cannot cleanup reports directory '{$reportDir}'."); } } mkdir($reportDir, 0777, true); }
/** * Returns unique report file for the scenario. * Used in order to generate unique report file paths for different scenarios that are represented by same files. * * @param \Magento\TestFramework\Performance\Scenario $scenario * @return string */ protected function _getScenarioReportFile(\Magento\TestFramework\Performance\Scenario $scenario) { $basePath = $this->_config->getReportDir() . '/' . pathinfo($scenario->getFile(), PATHINFO_FILENAME); $iteration = 1; do { $suffix = $iteration == 1 ? '' : '_' . $iteration; $reportFile = $basePath . $suffix . '.jtl'; $iteration++; } while (isset($this->_reportFiles[$reportFile])); $this->_reportFiles[$reportFile] = true; return $reportFile; }
public function testGetReportDir() { $expectedReportDir = __DIR__ . '/_files/report'; $this->assertEquals($expectedReportDir, $this->_object->getReportDir()); }