19declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
34 protected const string MODULE =
'stest';
42 protected function setUp(): void
48 if (!defined(
'ILIAS_ABSOLUTE_PATH')) {
49 define(
'ILIAS_ABSOLUTE_PATH', realpath(__DIR__ .
'/../../../../../'));
52 $this->client_data_dir = sys_get_temp_dir() .
'/ilias_mlfs_lock_test_' . bin2hex(random_bytes(4));
53 mkdir($this->client_data_dir, 0775,
true);
76 mkdir(dirname($this->
lockFile()), 0775,
true);
88 if ($started ===
null) {
89 $this->fail(
'Could not start the child PHP process.');
91 [$process, $pipes] = $started;
92 stream_set_blocking($pipes[1],
false);
93 stream_set_blocking($pipes[2],
false);
95 $deadline = microtime(
true) + $timeout_seconds;
98 $output .= (string) stream_get_contents($pipes[1]);
99 $output .= (string) stream_get_contents($pipes[2]);
100 $status = proc_get_status($process);
101 if (!$status[
'running']) {
104 proc_close($process);
106 return [
'finished' =>
true,
'exit_code' => $status[
'exitcode'],
'output' => $output];
109 }
while (microtime(
true) < $deadline);
111 proc_terminate($process, 9);
113 $output .= (string) stream_get_contents($pipes[1]);
114 $output .= (string) stream_get_contents($pipes[2]);
117 proc_close($process);
119 return [
'finished' =>
false,
'exit_code' =>
null,
'output' => $output];
trait RestoresProcessState
Whatever a test does to the process (locale, LANGUAGE/LC_*, LOCPATH, the static state of the runtime ...
static open(array $arguments, ?string $working_directory=null)
Fixture of the MigratedLanguageFileSyncLock*Test classes: a throwaway client data directory and the h...
LanguageFileDirectory $directory
runPhpWithTimeout(string $code, float $timeout_seconds)
Runs $code in a child PHP process and kills it after $timeout_seconds, so a regression that deadlocks...
seedLockDirectory()
Forces withOverlayLock() to take a real lock without needing a shipped .po: the overlay directory alr...
LanguageFileDirectoryManager $manager
static directory(string $prefix, string $path, bool $local=false)
static removeDirectory(string $directory)
static overlayLock(string $base_path)
static overlayBase(string $client_data_dir, LanguageFileDirectory $directory, string $lang_key)
The overlay of $directory's module for $lang_key without the .po extension.
static resetRuntime(?string $artifact_directory=null)
Forgets the static state of the runtime read path and points build and runtime at $artifact_directory...
A directory of language files with a path and a prefix for them.