我的单元测试在Travis CI上失败,但不在本地。
https://travis-ci.org/humanmade/backupwordpress/jobs/43609663#L362
错误讯息:
1) testBackupPathTestCase::testMergeExistingPath
RuntimeException: Error writing to file. (/tmp/wordpress/wp-content/backupwordpress- a74dcf0e84-backups/.schedule-test-merge-existing-path-running)
测试在这里:
https://github.com/humanmade/backupwordpress/blob/hmbkp-path/tests/other/testBackupPath.php#L135
以下函数抛出该异常:
/**
* Set the status of the running backup
*
* @access public
*
* @param string $message
*
* @return void
*/
public function set_status( $message ) {
$status = json_encode( (object) array(
'filename' => $this->get_archive_filename(),
'started' => $this->get_schedule_running_start_time(),
'status' => $message,
) );
if ( false === @file_put_contents( $this->get_schedule_running_path(), $status ) ) {
throw new RuntimeException( sprintf( __( 'Error writing to file. (%s)', 'backpwordpress' ), $this->get_schedule_running_path() ) );
}
}
请在此处查看完整课程:
https://github.com/humanmade/backupwordpress/blob/hmbkp-path/classes/class-schedule.php#L838
如何确定CI环境导致的错误或代码中的错误?