@@ -109,8 +109,7 @@ public function detectRuntimeWillPreferTheConsumerLocalInstallation(): void
109109 #[Test]
110110 public function detectRuntimeWillFallbackToTheWorkflowSourceWhenTheConsumerDoesNotInstallDevTools (): void
111111 {
112- mkdir ($ this ->workspace . '/.dev-tools-actions ' , 0o777 , true );
113- file_put_contents ($ this ->workspace . '/.dev-tools-actions/composer.json ' , "{} \n" );
112+ $ this ->createRepositoryRuntimeFiles ($ this ->workspace . '/.dev-tools-actions ' );
114113 $ resolvedWorkspace = realpath ($ this ->workspace );
115114
116115 $ files = $ this ->createGitHubActionFiles ();
@@ -150,6 +149,30 @@ public function detectRuntimeWillPreferTheWorkspaceRootRepositoryCheckout(): voi
150149 self ::assertSame ($ resolvedWorkspace . '/vendor/autoload.php ' , $ outputs ['autoload ' ]);
151150 }
152151
152+ /**
153+ * @return void
154+ */
155+ #[Test]
156+ public function detectRuntimeWillIgnoreAnUnrelatedWorkspaceRepositoryBinary (): void
157+ {
158+ $ this ->createRepositoryRuntimeFiles ($ this ->workspace , 'example/consumer ' );
159+ $ this ->createRepositoryRuntimeFiles ($ this ->workspace . '/.dev-tools-actions ' );
160+ $ resolvedWorkspace = realpath ($ this ->workspace );
161+
162+ $ files = $ this ->createGitHubActionFiles ();
163+
164+ $ this ->runActionScript ('detect-dev-tools-runtime.sh ' , [
165+ 'GITHUB_OUTPUT ' => $ files ['output ' ],
166+ ]);
167+
168+ $ outputs = $ this ->parseKeyValueFile ($ files ['output ' ]);
169+
170+ self ::assertSame ('workflow ' , $ outputs ['source ' ]);
171+ self ::assertSame ('true ' , $ outputs ['needs-fallback ' ]);
172+ self ::assertSame ($ resolvedWorkspace . '/.dev-tools-actions/bin/dev-tools ' , $ outputs ['binary ' ]);
173+ self ::assertSame ($ resolvedWorkspace . '/.dev-tools-actions/vendor/autoload.php ' , $ outputs ['autoload ' ]);
174+ }
175+
153176 /**
154177 * @return void
155178 */
@@ -209,19 +232,23 @@ private function createInstalledRuntimeFiles(string $runtimeRoot): void
209232 }
210233
211234 /**
235+ * @param string $packageName
212236 * @param string $runtimeRoot
213237 *
214238 * @return void
215239 */
216- private function createRepositoryRuntimeFiles (string $ runtimeRoot ): void
217- {
240+ private function createRepositoryRuntimeFiles (
241+ string $ runtimeRoot ,
242+ string $ packageName = 'fast-forward/dev-tools '
243+ ): void {
218244 mkdir ($ runtimeRoot . '/bin ' , 0o777 , true );
219245 mkdir ($ runtimeRoot . '/vendor ' , 0o777 , true );
220246 file_put_contents (
221247 $ runtimeRoot . '/bin/dev-tools ' ,
222248 "#!/usr/bin/env bash \nprintf 'dev-tools:%s \\n' \"\$* \"\n" ,
223249 );
224250 chmod ($ runtimeRoot . '/bin/dev-tools ' , 0o755 );
251+ file_put_contents ($ runtimeRoot . '/composer.json ' , \sprintf ("{ \n \"name \": \"%s \"\n} \n" , $ packageName ));
225252 file_put_contents ($ runtimeRoot . '/vendor/autoload.php ' , "<?php \n" );
226253 }
227254
0 commit comments