Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Hopefully the final change to make the tests run on jenkins.

Updated test suite to use a local directory.
This is due to the fact, that a given --bootstrap file is not available to *.phpt-Tests.
Also removed the CACHE_LITE_ERROR_DIE which is no longer testable with PHPt-Tests as the no longer generic path in the error message cannot be replaced.
  • Loading branch information...
commit c1260db5da0a038263dd60a3e77ec102284b9e5c 1 parent f096550
@coderbyheart coderbyheart authored
View
1  tests/Cache_Lite_File_classical.phpt
@@ -8,6 +8,7 @@ require_once 'tmpdir.inc';
require_once 'cache_lite_file_base.inc';
$master = tmpDir() . '/' . 'foobar.masterfile';
+
$options = array(
'cacheDir' => tmpDir() . '/',
'lifeTime' => 60,
View
13 tests/Cache_Lite_error2.phpt
@@ -7,8 +7,9 @@ require_once 'callcache.inc';
require_once 'tmpdir.inc';
require_once 'cache_lite_base.inc';
+$tmpdir = tmpDir() . '31451992gjhgjh'. '/'; # I hope there will be no directory with that silly name
$options = array(
- 'cacheDir' => tmpDir() . '31451992gjhgjh'. '/', # I hope there will be no directory with that silly name
+ 'cacheDir' => $tmpdir,
'lifeTime' => 60,
'errorHandlingAPIBreak' => true
);
@@ -23,21 +24,21 @@ multipleCallCache();
==> First call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-PEAR_ERROR : Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
+PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> Second call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-PEAR_ERROR : Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
+PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> Third call (cache should be hit)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-PEAR_ERROR : Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
+PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
@@ -47,14 +48,14 @@ Done !
==> Fourth call (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-PEAR_ERROR : Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
+PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277 (#-1)
Done !
==> #5 Call with another id (cache should be missed)
Cache Missed !
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-PEAR_ERROR : Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_07eeaa82211be6c3335603523dbea0a3 (#-1)
+PEAR_ERROR : Cache_Lite : Unable to write cache file : <cachedir>/31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_07eeaa82211be6c3335603523dbea0a3 (#-1)
Done !
View
25 tests/Cache_Lite_error3.phpt
@@ -1,25 +0,0 @@
---TEST--
-Cache_Lite::Cache_Lite (error3)
---FILE--
-<?php
-
-require_once 'callcache.inc';
-require_once 'tmpdir.inc';
-require_once 'cache_lite_base.inc';
-
-$options = array(
- 'cacheDir' => tmpDir() . '31451992gjhgjh'. '/', # I hope there will be no directory with that silly name
- 'lifeTime' => 60,
- 'pearErrorMode' => CACHE_LITE_ERROR_DIE
-);
-
-$Cache_Lite = new Cache_Lite($options);
-multipleCallCache();
-
-?>
---GET--
---POST--
---EXPECT--
-==> First call (cache should be missed)
-Cache Missed !
-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Cache_Lite : Unable to write cache file : /tmp31451992gjhgjh/cache_c21f969b5f03d33d43e04f8f136e7682_e9982ec5ca981bd365603623cf4b2277
View
4 tests/callcache.inc
@@ -25,7 +25,9 @@ function callCache($id, $type = 'string') {
}
$res = $Cache_Lite->save($data);
if (is_object($res)) {
- echo "\nPEAR_ERROR : " . $res->getMessage() . " (#" . $res->getCode() . ")\n";
+ $message = $res->getMessage();
+ $message = str_replace(tmpDir(), '<cachedir>/', $message); // Remove system specific cache dir
+ echo "\nPEAR_ERROR : " . $message . " (#" . $res->getCode() . ")\n";
} else {
if (!($res)) {
echo "\nError when saving cache !\n";
View
19 tests/jenkins.inc.php
@@ -1,19 +0,0 @@
-<?php
-
-/**
- * This file is included when running the tests on Jenkins where
- * there is no write access to the system temp dir
- *
- * @author Markus Tacker <tacker@php.net>
- */
-
-define('TEST_TMP_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'tmp');
-
-// Make sure temp dir exists
-if (!is_dir(TEST_TMP_DIR)) {
- mkdir(TEST_TMP_DIR);
-}
-
-register_shutdown_function(function() {
- exec('rm -rf ' . TEST_TMP_DIR);
-});
View
74 tests/tmpdir.inc
@@ -1,26 +1,24 @@
<?php
-/*
- * This code is taken from PEAR/File from Michael Wallner <mike@php.net>
- * to avoid an extra dependency for a single function.
- *
- * LICENSE: This source file is subject to version 3.0 of the PHP license
- * that is available through the world-wide-web at the following URI:
- * http://www.php.net/license/3_0.txt. If you did not receive a copy of
- * the PHP License and are unable to obtain it through the web, please
- * send a note to license@php.net so we can mail you a copy immediately.
+/**
+ * @author Markus Tacker <tacker@php.net>
+ */
+
+/**
+ * @const String Temp dir for cache files
*/
-
-require_once 'PEAR.php';
-define('FILE_WIN32', defined('OS_WINDOWS') ? OS_WINDOWS : !strncasecmp(PHP_OS, 'win', 3));
+define('TEST_TMP_DIR_DEFAULT', __DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR);
/**
* Returns a directory to use for temp files.
*
- * Returns the temp directory according to either the constant TEST_TMP_DIR (if defined),
- * sys_get_temp_dir() (if available) or the TMP, TMPDIR, TEMP env variables.
- * If these are not set it will also check for the existence of /tmp, %WINDIR%\temp
+ * The dir is now hard coded to a local dir to make the tests runnable
+ * under jenkins where there is no write access to the system temp dir.
*
+ * The reason for this solution is, that with phpt files a given
+ * --bootstrap file is ignored.
+ *
+ * @author Markus Tacker <tacker@php.net>*
* @static
* @access public
* @return string The system tmp directory
@@ -28,39 +26,15 @@ define('FILE_WIN32', defined('OS_WINDOWS') ? OS_WINDOWS : !strncasecmp(PHP_OS, '
function tmpDir()
{
if (defined('TEST_TMP_DIR')) return TEST_TMP_DIR;
- if (function_exists('sys_get_temp_dir')) return call_user_func('sys_get_temp_dir');
- if (FILE_WIN32) {
- if (isset($_ENV['TEMP'])) {
- return $_ENV['TEMP'];
- }
- if (isset($_ENV['TMP'])) {
- return $_ENV['TMP'];
- }
- if (isset($_ENV['windir'])) {
- return $_ENV['windir'] . '\\temp';
- }
- if (isset($_ENV['SystemRoot'])) {
- return $_ENV['SystemRoot'] . '\\temp';
- }
- if (isset($_SERVER['TEMP'])) {
- return $_SERVER['TEMP'];
- }
- if (isset($_SERVER['TMP'])) {
- return $_SERVER['TMP'];
- }
- if (isset($_SERVER['windir'])) {
- return $_SERVER['windir'] . '\\temp';
- }
- if (isset($_SERVER['SystemRoot'])) {
- return $_SERVER['SystemRoot'] . '\\temp';
- }
- return '\temp';
- }
- if (isset($_ENV['TMPDIR'])) {
- return $_ENV['TMPDIR'];
- }
- if (isset($_SERVER['TMPDIR'])) {
- return $_SERVER['TMPDIR'];
- }
- return '/tmp';
+ return TEST_TMP_DIR_DEFAULT;
}
+
+// Create directory if not exists
+if (!is_dir(tmpDir())) mkdir(tmpDir());
+
+// Clean up afterwards
+register_shutdown_function(function()
+{
+ exec('rm -rf ' . tmpDir());
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.