Skip to content

Commit

Permalink
Remove special test builtins
Browse files Browse the repository at this point in the history
Summary:
We don't need special builtins to get the temp directory because
sys_get_temp_dir() does that already. Remove them all.

Reviewed By: paulbiss

Differential Revision: D45921075

fbshipit-source-id: 2f578392334da5b105652dcdba25e49c28ccc505
  • Loading branch information
ricklavoie authored and facebook-github-bot committed May 16, 2023
1 parent fcb5eaa commit 1b9165a
Show file tree
Hide file tree
Showing 443 changed files with 781 additions and 841 deletions.
1 change: 0 additions & 1 deletion hphp/system/php.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ hphp/system/php/date/dateperiod.php
hphp/system/php/date/datetime_funcs.php
hphp/system/php/dom/DOMException.php
hphp/system/php/file_system/Directory.php
hphp/system/php/file_system/hphp_test_tmpdir.ns.php
hphp/system/php/lang/Disposable.php
hphp/system/php/lang/ErrorException.php
hphp/system/php/lang/fun.ns.php
Expand Down
52 changes: 0 additions & 52 deletions hphp/system/php/file_system/hphp_test_tmpdir.ns.php

This file was deleted.

2 changes: 1 addition & 1 deletion hphp/test/quick/chdir_posix.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<<__EntryPoint>> function main(): void {
$origdir = getcwd();
$dirname = __SystemLib\hphp_test_tmppath('hhvm_chdir');
$dirname = sys_get_temp_dir().'/'.'hhvm_chdir';
mkdir($dirname);

var_dump(chdir($dirname));
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/quick/ext_pdo_fetchobject_no_class_name.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?hh

<<__EntryPoint>> function main(): void {
$tmp_sqlite = __SystemLib\hphp_test_tmppath('vmpdotest');
$tmp_sqlite = sys_get_temp_dir().'/'.'vmpdotest';
$source = "sqlite:$tmp_sqlite";
$db = new PDO($source);
$rows = $db->query('SELECT LENGTH("123456") as col;')->fetchObject();
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/quick/file_blank.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?hh
<<__EntryPoint>> function main(): void {
$fname = __SystemLib\hphp_test_tmppath('blank');
$fname = sys_get_temp_dir().'/'.'blank';
touch($fname);
var_dump(file($fname));
unlink($fname);
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/quick/file_rw.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?hh
<<__EntryPoint>> function main(): void {
$fname = __SystemLib\hphp_test_tmppath('data');
$fname = sys_get_temp_dir().'/'.'data';
$w = fopen($fname, "w");
$r = fopen($fname, "r");
printf("Read %d bytes\n", strlen(fread($r, 10)));
Expand Down
3 changes: 0 additions & 3 deletions hphp/test/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,8 @@ function hhvm_cmd(
$env["TERM"] = "dumb";
}

$env['HPHP_TEST_TMPDIR'] = Status::getTestTempDir($test);
$env['TMPDIR'] = Status::getTestTempDir($test);
$env['HPHP_TEST_SOCKETDIR'] = Status::getSocketDir();
$env['HPHP_TEST_SOURCE_FILE'] = $test;
if ($options->log) {
$env['TRACE'] = 'printir:2';
$env['HPHP_TRACE_FILE'] = $test . '.log';
Expand Down Expand Up @@ -4074,7 +4072,6 @@ function start_servers(
$prelude = <<<'EOT'
<?hh
<<__EntryPoint>> function UNIQUE_NAME_I_DONT_EXIST_IN_ANY_TEST(): void {
putenv("HPHP_TEST_TMPDIR=BASEDIR{$_SERVER['SCRIPT_NAME']}/temp");
putenv("TMPDIR=BASEDIR{$_SERVER['SCRIPT_NAME']}/temp");
putenv("HPHP_TEST_SOCKETDIR=$socket_dir");
}
Expand Down
4 changes: 2 additions & 2 deletions hphp/test/server/util/server_tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract final class ServerUtilServerTests {

<<__Memoize>>
public static function working_dir() {
return getenv('HPHP_TEST_TMPDIR') ?? sys_get_temp_dir();
return sys_get_temp_dir();
}

<<__Memoize>>
Expand Down Expand Up @@ -187,7 +187,7 @@ function getServerCmd($serverPort, $adminPort, $debugPort, $home, $root,
' -vServer.ExitOnBindFail=true' .
' --instance-id=' . $test_run_id .
' -vPageletServer.ThreadCount=5' .
' -vPidFile=' . escapeshellarg(__SystemLib\hphp_test_tmppath('www.pid')) .
' -vPidFile=' . escapeshellarg(sys_get_temp_dir().'/'.'www.pid') .
$portConfig . $srcRootConfig .
$includePathConfig . $sandboxHomeConfig . $adminPortConfig .
$debugPortConfig . $jitConfig . ' ' . $customArgs .
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/compilation/func-guards.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function setup() {
}
$text .= "class Y { const C = $i; }\n";

$file = __SystemLib\hphp_test_tmppath("$i.inc");
$file = sys_get_temp_dir().'/'."$i.inc";
file_put_contents($file, "<?hh $text");
include $file;
unlink($file);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"-vServer.SourceRoot=$(dirname "$HPHP_TEST_SOURCE_FILE")"
-vServer.SourceRoot=__DIR__
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<<__EntryPoint>>
function main_spl_file_object_fputcsv() {
$file = __SystemLib\hphp_test_tmppath('SplFileObject_fputcsv.csv');
$file = sys_get_temp_dir().'/'.'SplFileObject_fputcsv.csv';
$fo = new SplFileObject($file, 'w');

$list = darray [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<<__EntryPoint>>
function main_spl_file_object_fputcsv() {
$file = __SystemLib\hphp_test_tmppath('SplFileObject_fputcsv.csv');
$file = sys_get_temp_dir().'/'.'SplFileObject_fputcsv.csv';
$fo = new SplFileObject($file, 'w');

$list = darray [
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_error/error_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<<__EntryPoint>>
function main_error_log() {
$log_string = 'hello world';
$filename = __SystemLib\hphp_test_tmppath('errorlog_test');
$filename = sys_get_temp_dir().'/'.'errorlog_test';

error_log($log_string, 3, $filename);
$f = fopen($filename, 'r');
Expand Down
4 changes: 2 additions & 2 deletions hphp/test/slow/ext_file/predicates.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ function main_predicates() {

// in order to create a file outside the source tree but have a relative
// path to it, we need to chdir into the temporary directory
$tempfile = __SystemLib\hphp_test_tmppath('vmextfiletest');
$tempfile = sys_get_temp_dir().'/'.'vmextfiletest';
touch($tempfile);
chdir(__SystemLib\hphp_test_tmproot());
chdir(sys_get_temp_dir());
$relativetempfile = './vmextfiletest';
var_dump(is_file($relativetempfile));
var_dump(is_dir($relativetempfile));
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_hsl/ext_os_sockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
await do_test($sin);

print("\n\n***** Testing AF_UNIX server ***\n");
$path = __SystemLib\hphp_test_tmppath('sock');
$path = sys_get_temp_dir().'/'.'sock';
$sun = new _OS\sockaddr_un_pathname($path);
try {
await do_test($sun);
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_hsl/flock.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function try_lock(string $path, int $type): void {

<<__EntryPoint>>
function main(): void {
$path = __SystemLib\hphp_test_tmppath('hsl-os-flock');
$path = sys_get_temp_dir().'/'.'hsl-os-flock';
try {
$fd = _OS\open($path, _OS\O_CREAT | _OS\O_RDWR | _OS\O_EXCL, 0644);
print("Acquiring first exclusive lock\n");
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_hsl/mkdtemp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function main(): void {
// Supported number of 'X's varies by platform; only exactly 6 is portable.
// Builtin will error if an invalid pattern is given; leave enforcing
// portability (or not) up to the HSL.
$pattern = __SystemLib\hphp_test_tmproot().'ext_hsl-test-XXXXXX';
$pattern = sys_get_temp_dir().'/ext_hsl-test-XXXXXX';
$tmpdir = _OS\mkdtemp($pattern);
// All of these should be true
var_dump($tmpdir !== $pattern);
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_hsl/os_ftruncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<<__EntryPoint>>
function main(): void {
$temp = __SystemLib\hphp_test_tmppath('hsl_os_ftruncate');
$temp = sys_get_temp_dir().'/'.'hsl_os_ftruncate';
touch($temp);
$fd = _OS\open($temp, _OS\O_WRONLY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<<__EntryPoint>>
function main(): void {
$file = __SystemLib\hphp_test_tmppath('__tmp_rose.jpg');
$file = sys_get_temp_dir().'/'.'__tmp_rose.jpg';

$imagick = new Imagick('magick:rose');
$imagick->setImageFormat('jpg');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<<__EntryPoint>>
function main(): void {
$jpeg_file = __SystemLib\hphp_test_tmppath('imagick_test.jpg');
$png_file = __SystemLib\hphp_test_tmppath('imagick_test.png');
$jpeg_file = sys_get_temp_dir().'/'.'imagick_test.jpg';
$png_file = sys_get_temp_dir().'/'.'imagick_test.png';

$im = new Imagick ('magick:rose');
$im->writeImage ($jpeg_file);
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_pdo/errmode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<<__EntryPoint>>
function main_errmode() {
$db = __SystemLib\hphp_test_tmppath('errmode.php.sq3');
$db = sys_get_temp_dir().'/'.'errmode.php.sq3';

$pdo = new PDO("sqlite:$db");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
Expand Down
4 changes: 1 addition & 3 deletions hphp/test/slow/ext_spl_iterators/follow_symlink.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<<__EntryPoint>>
function main_follow_symlink() {
$p = __SystemLib\hphp_test_tmppath(
'recursivedirectoryiterator_followsymlink_test/'
);
$p = sys_get_temp_dir() . '/recursivedirectoryiterator_followsymlink_test/';

mkdir($p . "test/dir1", 0777, true);
touch($p . "test/dir1/file1.txt");
Expand Down
4 changes: 2 additions & 2 deletions hphp/test/slow/ext_sqlite3/ext_sqlite3.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function sumlen_fini($a) {

<<__EntryPoint>>
function main_ext_sqlite3() {
$db = new SQLite3(__SystemLib\hphp_test_tmppath(':memory:test'));
$db = new SQLite3(sys_get_temp_dir().'/'.':memory:test');
$db->exec("DROP TABLE IF EXISTS foo");
$db->exec("CREATE TABLE foo (bar STRING)");

Expand Down Expand Up @@ -89,7 +89,7 @@ function main_ext_sqlite3() {
VERIFY((int)SQLite3::version()['versionNumber'] > (int)3000000);

$db->close();
unlink(__SystemLib\hphp_test_tmppath(':memory:test'));
unlink(sys_get_temp_dir().'/'.':memory:test');

// Check that a PHP Exception is thrown for nonexistant databases
try {
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_sqlite3/sqlite3_null_byte.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
function main_sqlite3_null_byte() {
$file = '/etc/passwd'.chr(0).'asdf';

$db = __SystemLib\hphp_test_tmppath('example.db');
$db = sys_get_temp_dir().'/'.'example.db';

set_error_handler(function() use ($db) { unlink($db); return false; });

Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_xml/empty_write.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<<__EntryPoint>>
function main_empty_write() {
$fname = __SystemLib\hphp_test_tmppath('xmlout');
$fname = sys_get_temp_dir().'/'.'xmlout';
$writer = xmlwriter_open_uri($fname);
xmlwriter_flush($writer);
print file_exists($fname) ? "written\n" : "no file\n";
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_zip/can_manipulate_with_index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Create test ZIP file
<<__EntryPoint>>
function main_write_after_read_works() {
$tempfile = __SystemLib\hphp_test_tmppath('hello.zip');
$tempfile = sys_get_temp_dir().'/'.'hello.zip';
$zip_setup = new ZipArchive();
$zip_setup->open($tempfile, ZipArchive::OVERWRITE | ZipArchive::CREATE);
$zip_setup->addFromString('hello.txt', 'Value here');
Expand Down
2 changes: 1 addition & 1 deletion hphp/test/slow/ext_zip/write_after_read_works.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Create test ZIP file
<<__EntryPoint>>
function main_write_after_read_works() {
$tempfile = __SystemLib\hphp_test_tmppath('hello.zip');
$tempfile = sys_get_temp_dir().'/'.'hello.zip';
$zip_setup = new ZipArchive();
$zip_setup->open($tempfile, ZipArchive::OVERWRITE | ZipArchive::CREATE);
$zip_setup->addFromString('hello.txt', 'Old value here');
Expand Down
14 changes: 7 additions & 7 deletions hphp/test/slow/ext_zlib/hack_array/zip_archive_hack_array.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ function stat_targets(ZipArchive $zip): void {
<<__EntryPoint>>
function main() {
$zip = new ZipArchive();
$zip->open(__SystemLib\hphp_test_tmppath(ZIP_NAME), ZipArchive::CREATE);
$zip->open(sys_get_temp_dir().'/'.ZIP_NAME, ZipArchive::CREATE);
$zip->addGlob(__DIR__ . '/test_files/foo*', 0, OPTS);
$zip->addPattern('/b[io]ng/', __DIR__ . '/test_files', OPTS);
$zip->close();
$zip->open(__SystemLib\hphp_test_tmppath(ZIP_NAME));
$zip->open(sys_get_temp_dir().'/'.ZIP_NAME);
stat_archive($zip);
stat_targets($zip);
$zip->extractTo(__SystemLib\hphp_test_tmppath(OUTPUT_DIR), TARGETS);
var_dump(scandir(__SystemLib\hphp_test_tmppath(OUTPUT_DIR)));
$zip->extractTo(sys_get_temp_dir().'/'.OUTPUT_DIR, TARGETS);
var_dump(scandir(sys_get_temp_dir().'/'.OUTPUT_DIR));

// Cleanup
foreach (TARGETS as $target) {
unlink(__SystemLib\hphp_test_tmppath(OUTPUT_DIR . "/$target"));
unlink(sys_get_temp_dir().'/'.OUTPUT_DIR . "/$target");
}
rmdir(__SystemLib\hphp_test_tmppath(OUTPUT_DIR));
unlink(__SystemLib\hphp_test_tmppath(ZIP_NAME));
rmdir(sys_get_temp_dir().'/'.OUTPUT_DIR);
unlink(sys_get_temp_dir().'/'.ZIP_NAME);
}
14 changes: 7 additions & 7 deletions hphp/test/slow/ext_zlib/hack_array/zip_archive_no_hack_array.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ function stat_targets(ZipArchive $zip): void {
<<__EntryPoint>>
function main() {
$zip = new ZipArchive();
$zip->open(__SystemLib\hphp_test_tmppath(ZIP_NAME), ZipArchive::CREATE);
$zip->open(sys_get_temp_dir().'/'.ZIP_NAME, ZipArchive::CREATE);
$zip->addGlob(__DIR__ . '/test_files/foo*', 0, OPTS);
$zip->addPattern('/b[io]ng/', __DIR__ . '/test_files', OPTS);
$zip->close();
$zip->open(__SystemLib\hphp_test_tmppath(ZIP_NAME));
$zip->open(sys_get_temp_dir().'/'.ZIP_NAME);
stat_archive($zip);
stat_targets($zip);
$zip->extractTo(__SystemLib\hphp_test_tmppath(OUTPUT_DIR), TARGETS);
var_dump(scandir(__SystemLib\hphp_test_tmppath(OUTPUT_DIR)));
$zip->extractTo(sys_get_temp_dir().'/'.OUTPUT_DIR, TARGETS);
var_dump(scandir(sys_get_temp_dir().'/'.OUTPUT_DIR));

// Cleanup
foreach (TARGETS as $target) {
unlink(__SystemLib\hphp_test_tmppath(OUTPUT_DIR . "/$target"));
unlink(sys_get_temp_dir().'/'.OUTPUT_DIR . "/$target");
}
rmdir(__SystemLib\hphp_test_tmppath(OUTPUT_DIR));
unlink(__SystemLib\hphp_test_tmppath(ZIP_NAME));
rmdir(sys_get_temp_dir().'/'.OUTPUT_DIR);
unlink(sys_get_temp_dir().'/'.ZIP_NAME);
}
4 changes: 2 additions & 2 deletions hphp/test/slow/ext_zlib/ziparchive_setencryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
function main_ziparchive_setencryption() {
$str = 'temp';
$archive = new ZipArchive();
$archive->open(__SystemLib\hphp_test_tmppath('comptest.zip'), ZipArchive::CREATE);
$archive->open(sys_get_temp_dir().'/'.'comptest.zip', ZipArchive::CREATE);
$archive->addFromString("A.txt", $str);
$archive->addFromString("B.txt", $str);
var_dump($archive->setEncryptionIndex(0, ZipArchive::EM_AES_256, 'password'));
var_dump($archive->setEncryptionName("B.txt", ZipArchive::EM_AES_256, 'password'));
$archive->close();
unlink(__SystemLib\hphp_test_tmppath('comptest.zip'));
unlink(sys_get_temp_dir().'/'.'comptest.zip');
}
4 changes: 2 additions & 2 deletions hphp/test/slow/file/copy_directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<<__EntryPoint>>
function main_copy_directory() {

$src_dir = __SystemLib\hphp_test_tmppath('copy_dir_src');
$dest_dir = __SystemLib\hphp_test_tmppath('copy_dir_dest');
$src_dir = sys_get_temp_dir().'/'.'copy_dir_src';
$dest_dir = sys_get_temp_dir().'/'.'copy_dir_dest';

// Create the source directory
mkdir("$src_dir");
Expand Down
Loading

0 comments on commit 1b9165a

Please sign in to comment.