|
6 | 6 |
|
7 | 7 | use Composer\IO\BufferIO; |
8 | 8 | use Composer\Package\CompletePackageInterface; |
| 9 | +use Composer\Util\Filesystem; |
9 | 10 | use Composer\Util\Platform; |
10 | 11 | use Php\Pie\Building\UnixBuild; |
11 | 12 | use Php\Pie\DependencyResolver\Package; |
|
30 | 31 | use function array_unshift; |
31 | 32 | use function assert; |
32 | 33 | use function file_exists; |
| 34 | +use function getenv; |
33 | 35 | use function is_executable; |
34 | 36 | use function is_writable; |
35 | 37 | use function mkdir; |
| 38 | +use function putenv; |
36 | 39 | use function rename; |
37 | | -use function unlink; |
| 40 | +use function uniqid; |
38 | 41 |
|
39 | 42 | use const DIRECTORY_SEPARATOR; |
40 | 43 |
|
@@ -79,14 +82,18 @@ public static function phpPathProvider(): array |
79 | 82 | #[DataProvider('phpPathProvider')] |
80 | 83 | public function testUnixInstallCanInstallExtensionBuiltFromSource(string $phpConfig): void |
81 | 84 | { |
| 85 | + $installRoot = '/tmp/' . uniqid('pie-test-install-root-', true); |
| 86 | + $oldInstallRoot = getenv('INSTALL_ROOT'); |
| 87 | + putenv('INSTALL_ROOT=' . $installRoot); |
| 88 | + |
82 | 89 | assert($phpConfig !== ''); |
83 | 90 | if (Platform::isWindows()) { |
84 | 91 | self::markTestSkipped('Unix build test cannot be run on Windows'); |
85 | 92 | } |
86 | 93 |
|
87 | 94 | $output = new BufferIO(); |
88 | 95 | $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null); |
89 | | - $extensionPath = $targetPlatform->phpBinaryPath->extensionPath(); |
| 96 | + $extensionPath = $targetPlatform->phpBinaryPath->extensionPath($installRoot); |
90 | 97 |
|
91 | 98 | $composerPackage = $this->createMock(CompletePackageInterface::class); |
92 | 99 | $composerPackage |
@@ -135,19 +142,26 @@ public function testUnixInstallCanInstallExtensionBuiltFromSource(string $phpCon |
135 | 142 | (new Process($rmCommand))->mustRun(); |
136 | 143 | (new Process(['make', 'clean'], $downloadedPackage->extractedSourcePath))->mustRun(); |
137 | 144 | (new Process(['phpize', '--clean'], $downloadedPackage->extractedSourcePath))->mustRun(); |
| 145 | + (new Filesystem())->remove($installRoot); |
| 146 | + putenv('INSTALL_ROOT=' . $oldInstallRoot); |
138 | 147 | } |
139 | 148 |
|
140 | 149 | #[DataProvider('phpPathProvider')] |
141 | 150 | public function testUnixInstallCanInstallPrePackagedBinary(string $phpConfig): void |
142 | 151 | { |
| 152 | + $installRoot = '/tmp/' . uniqid('pie-test-install-root-', true); |
| 153 | + $oldInstallRoot = getenv('INSTALL_ROOT'); |
| 154 | + putenv('INSTALL_ROOT=' . $installRoot); |
| 155 | + |
143 | 156 | assert($phpConfig !== ''); |
144 | 157 | if (Platform::isWindows()) { |
145 | 158 | self::markTestSkipped('Unix build test cannot be run on Windows'); |
146 | 159 | } |
147 | 160 |
|
148 | 161 | $output = new BufferIO(); |
149 | 162 | $targetPlatform = TargetPlatform::fromPhpBinaryPath(PhpBinaryPath::fromPhpConfigExecutable($phpConfig), null, null); |
150 | | - $extensionPath = $targetPlatform->phpBinaryPath->extensionPath(); |
| 163 | + $extensionPath = $installRoot . $targetPlatform->phpBinaryPath->extensionPath(); |
| 164 | + mkdir($extensionPath, 0777, true); |
151 | 165 |
|
152 | 166 | // First build it (otherwise the test assets would need to have a binary for every test platform...) |
153 | 167 | $composerPackage = $this->createMock(CompletePackageInterface::class); |
@@ -218,6 +232,8 @@ public function testUnixInstallCanInstallPrePackagedBinary(string $phpConfig): v |
218 | 232 | } |
219 | 233 |
|
220 | 234 | (new Process($rmCommand))->mustRun(); |
221 | | - unlink($prebuiltBinaryFile->filePath); |
| 235 | + (new Filesystem())->remove($prebuiltBinaryFile->filePath); |
| 236 | + (new Filesystem())->remove($installRoot); |
| 237 | + putenv('INSTALL_ROOT=' . $oldInstallRoot); |
222 | 238 | } |
223 | 239 | } |
0 commit comments