Skip to content

Add CLEAN section to some IO tests #10081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ext/standard/tests/file/file_get_contents_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ echo "\n-- Testing with empty file --\n";

create_files($file_path, 1, "empty", 0755, 100, "w", "file", 1, "byte");
var_dump( file_get_contents($file_path."/file1.tmp") );
delete_files($file_path, 1);

echo "\n*** Done ***";
?>
--CLEAN--
<?php
$file_path = __DIR__;
include($file_path."/file.inc");
delete_files($file_path, 1);
?>
--EXPECT--
*** Testing the basic functionality of the file_get_contents() function ***
-- Testing with simple valid data file --
Expand Down
7 changes: 6 additions & 1 deletion ext/standard/tests/file/file_get_contents_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ set_include_path($newpath);
runtest();
teardown_include_path();
chdir("..");
rmdir($thisTestDir);


function runtest() {
Expand All @@ -36,6 +35,12 @@ function runtest() {
unlink($secondFile);
}

?>
--CLEAN--
<?php
// TODO Clean up tmp files
$thisTestDir = "fileGetContentsVar1.dir";
rmdir($thisTestDir);
?>
--EXPECT--
*** Testing file_get_contents() : variation ***
Expand Down
7 changes: 6 additions & 1 deletion ext/standard/tests/file/file_get_contents_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ set_include_path($newpath);
runtest();
teardown_include_path();
chdir("..");
rmdir($thisTestDir);


function runtest() {
Expand All @@ -37,6 +36,12 @@ function runtest() {
unlink($scriptLocFile);
}

?>
--CLEAN--
<?php
$thisTestDir = "FileGetContentsVar2.dir";
// TODO Clean up tmp files?
rmdir($thisTestDir);
?>
--EXPECT--
*** Testing file_get_contents() : variation ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ for($i = 0; $i<count($allDirs); $i++) {
var_dump(file_get_contents($dir."\\".$filename));
}

unlink($absFile);
chdir($old_dir_path);
rmdir($absSubDir);
rmdir($absMainDir);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$mainDir = "fileGetContentsVar7私はガラスを食べられます.dir";
$subDir = "fileGetContentsVar7Sub私はガラスを食べられます";
$absMainDir = __DIR__."/".$mainDir;
$absSubDir = $absMainDir."/".$subDir;
$filename = 'FileGetContentsVar7.tmp';
$absFile = $absSubDir.'/'.$filename;
unlink($absFile);
rmdir($absSubDir);
rmdir($absMainDir);
?>
--EXPECTF--
*** Testing file_get_contents() : variation ***

Expand Down
15 changes: 12 additions & 3 deletions ext/standard/tests/file/file_get_contents_variation7-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ for($i = 0; $i<count($allDirs); $i++) {
var_dump(file_get_contents($dir."\\".$filename));
}

unlink($absFile);
chdir($old_dir_path);
rmdir($absSubDir);
rmdir($absMainDir);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$mainDir = "fileGetContentsVar7.dir";
$subDir = "fileGetContentsVar7Sub";
$absMainDir = __DIR__."/".$mainDir;
$absSubDir = $absMainDir."/".$subDir;
$filename = 'FileGetContentsVar7.tmp';
$absFile = $absSubDir.'/'.$filename;
unlink($absFile);
rmdir($absSubDir);
rmdir($absMainDir);
?>
--EXPECTF--
*** Testing file_get_contents() : variation ***

Expand Down
13 changes: 11 additions & 2 deletions ext/standard/tests/file/file_get_contents_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,20 @@ for($i = 0; $i<count($allDirs); $i++) {
}

chdir($old_dir_path);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$mainDir = "fileGetContentsVar7.dir";
$subDir = "fileGetContentsVar7Sub";
$absMainDir = __DIR__."/".$mainDir;
$absSubDir = $absMainDir."/".$subDir;
$filename = 'FileGetContentsVar7.tmp';
$absFile = $absSubDir.'/'.$filename;
unlink($absFile);
rmdir($absSubDir);
rmdir($absMainDir);

echo "\n*** Done ***\n";
?>
--EXPECTF--
*** Testing file_get_contents() : variation ***
Expand Down
10 changes: 8 additions & 2 deletions ext/standard/tests/file/file_get_contents_variation9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ var_dump(file_get_contents($chainlink));
var_dump(file_get_contents($softlink));
var_dump(file_get_contents($hardlink));

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$filename = __DIR__.'/fileGetContentsVar9.tmp';
$softlink = __DIR__.'/fileGetContentsVar9.SoftLink';
$hardlink = __DIR__.'/fileGetContentsVar9.HardLink';
$chainlink = __DIR__.'/fileGetContentsVar9.ChainLink';
unlink($chainlink);
unlink($softlink);
unlink($hardlink);
unlink($filename);

echo "\n*** Done ***\n";
?>
--EXPECT--
*** Testing file_get_contents() : variation ***
Expand Down
7 changes: 5 additions & 2 deletions ext/standard/tests/file/file_put_contents.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ try {
echo $e->getMessage(), "\n";
}

@unlink($file);

echo "Done\n";
?>
--CLEAN--
<?php
$file = __DIR__."/file_put_contents.txt";
unlink($file);
?>
--EXPECT--
file_put_contents(): supplied resource is not a valid stream resource
bool(false)
Expand Down
6 changes: 5 additions & 1 deletion ext/standard/tests/file/file_put_contents_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ file_put_contents($filename, $data);
echo filesize($filename)."\n";
readfile($filename);
echo "\n";
unlink($filename);


?>
--CLEAN--
<?php
$filename = "FilePutContentsVar1.tmp";
unlink($filename);
?>
--EXPECT--
*** Testing file_put_contents() : variation ***
Expand Down
6 changes: 5 additions & 1 deletion ext/standard/tests/file/file_put_contents_variation2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ foreach($inputs as $key =>$value) {
file_put_contents($filename, $value);
readfile($filename);
};
unlink($filename);

?>
--CLEAN--
<?php
$filename = __DIR__ . '/fwriteVar5.tmp';
unlink($filename);
?>
--EXPECT--
*** Testing file_put_contents() : usage variation ***
Expand Down
9 changes: 7 additions & 2 deletions ext/standard/tests/file/file_put_contents_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ runtest();

teardown_include_path();
chdir("..");
rmdir($thisTestDir);


function runtest() {
global $filename;
Expand All @@ -35,6 +33,13 @@ function runtest() {
unlink($filename);
}

?>
--CLEAN--
<?php
$thisTestDir = basename(__FILE__, ".clean.php") . ".dir";
$filename = basename(__FILE__, ".clean.php") . ".tmp";
@unlink($filename);
rmdir($thisTestDir);
?>
--EXPECT--
File in include path
Expand Down
12 changes: 10 additions & 2 deletions ext/standard/tests/file/file_put_contents_variation5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Dave Kelsey <d_kelsey@uk.ibm.com>
<?php


$thisTestDir = __DIR__ . '/' .basename(__FILE__, ".php") . ".directory";
$thisTestDir = __DIR__ . '/' .basename(__FILE__, ".php") . ".dir";
mkdir($thisTestDir);
chdir($thisTestDir);

Expand All @@ -25,7 +25,6 @@ set_include_path(";; ; ;c:\\rubbish");
runtest();

chdir(__DIR__);
rmdir($thisTestDir);


function runtest() {
Expand All @@ -41,6 +40,15 @@ function runtest() {
}
}
?>
--CLEAN--
<?php
$thisTestDir = __DIR__ . '/' . basename(__FILE__, ".clean.php") . ".dir";
$filename = basename(__FILE__, ".clean.php") . ".tmp";
$scriptLocFile = __DIR__."/".$filename;
@unlink($filename);
@unlink($scriptLocFile);
rmdir($thisTestDir);
?>
--EXPECT--
File written in working directory
File written in working directory
Expand Down
8 changes: 7 additions & 1 deletion ext/standard/tests/file/file_put_contents_variation6.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ runtest();

teardown_include_path();
chdir("..");
rmdir($thisTestDir);


function runtest() {
Expand All @@ -40,6 +39,13 @@ function runtest() {
unlink($filename);
}

?>
--CLEAN--
<?php
$thisTestDir = basename(__FILE__, ".clean.php") . ".dir";
$filename = basename(__FILE__, ".clean.php") . ".tmp";
@unlink($filename);
rmdir($thisTestDir);
?>
--EXPECT--
*** Testing file_put_contents() : variation ***
Expand Down
14 changes: 12 additions & 2 deletions ext/standard/tests/file/file_put_contents_variation7-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,21 @@ for($i = 0; $i<count($allDirs); $i++) {
}

chdir($old_dir_path);
rmdir($absSubDir);
rmdir($absMainDir);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$mainDir = "filePutContentsVar7.dir";
$subDir = "filePutContentsVar7Sub";
$absMainDir = __DIR__."/".$mainDir;
$absSubDir = $absMainDir."/".$subDir;
$filename = 'FileGetContentsVar7.tmp';
$absFile = $absSubDir.'/'.$filename;
@unlink($absFile);
rmdir($absSubDir);
rmdir($absMainDir);
?>
--EXPECTF--
*** Testing file_put_contents() : usage variation ***

Expand Down
14 changes: 12 additions & 2 deletions ext/standard/tests/file/file_put_contents_variation7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ for($i = 0; $i<count($allDirs); $i++) {
}

chdir($old_dir_path);
rmdir($absSubDir);
rmdir($absMainDir);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$mainDir = "filePutContentsVar7.dir";
$subDir = "filePutContentsVar7Sub";
$absMainDir = __DIR__."/".$mainDir;
$absSubDir = $absMainDir."/".$subDir;
$filename = 'FileGetContentsVar7.tmp';
$absFile = $absSubDir.'/'.$filename;
@unlink($absFile);
rmdir($absSubDir);
rmdir($absMainDir);
?>
--EXPECTF--
*** Testing file_put_contents() : usage variation ***

Expand Down
7 changes: 6 additions & 1 deletion ext/standard/tests/file/file_put_contents_variation8.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ for( $i=0; $i<count($names_arr); $i++ ) {
echo get_class($e) . ': ' . $e->getMessage(), "\n";
}
}
rmdir($dir);

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$dir = __DIR__ . '/file_put_contents_variation8';
// TODO Cleanup temp files?
rmdir($dir);
?>
--EXPECTF--
*** Testing file_put_contents() : usage variation ***
-- Iteration 0 --
Expand Down
17 changes: 11 additions & 6 deletions ext/standard/tests/file/file_put_contents_variation9.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ file_put_contents($filename,"");
link($filename, $hardlink);
run_test($hardlink);

unlink($chainlink);
unlink($softlink);
unlink($hardlink);
unlink($filename);


function run_test($file) {
$data = "Here is some data";
$extra = ", more data";
Expand All @@ -49,6 +43,17 @@ function run_test($file) {

echo "\n*** Done ***\n";
?>
--CLEAN--
<?php
$filename = __DIR__.'/filePutContentsVar9.tmp';
$softlink = __DIR__.'/filePutContentsVar9.SoftLink';
$hardlink = __DIR__.'/filePutContentsVar9.HardLink';
$chainlink = __DIR__.'/filePutContentsVar9.ChainLink';
unlink($chainlink);
unlink($softlink);
unlink($hardlink);
unlink($filename);
?>
--EXPECT--
*** Testing file_put_contents() : usage variation ***
int(17)
Expand Down
11 changes: 7 additions & 4 deletions ext/standard/tests/file/file_variation5-win32-mb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ chdir($script_directory);
$test_dirname = basename(__FILE__, ".php") . "私はガラスを食べられますtestdir";
mkdir($test_dirname);

$filepath = __FILE__ . ".tmp";
$filepath = __DIR__ . '/file_variation_5.tmp';
$filename = basename($filepath);
$fd = fopen($filepath, "w+");
fwrite($fd, "Line 1\nLine 2\nLine 3");
Expand All @@ -31,10 +31,13 @@ chdir($test_dirname);
var_dump(file("../$filename"));
chdir($script_directory);

chdir($script_directory);
unlink($filepath);
?>
--CLEAN--
<?php
$test_dirname = basename(__FILE__, ".clean.php") . "私はガラスを食べられますtestdir";
$filepath = __DIR__ . '/file_variation_5.tmp';
rmdir($test_dirname);

unlink($filepath);
?>
--EXPECT--
file() on a path containing .. and .
Expand Down
Loading