Skip to content

Commit ef8ff67

Browse files
committed
test: fix command tests that may hang on linux due to sudo
1 parent 246cbd4 commit ef8ff67

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/system/Commands/Housekeeping/ClearDebugbarTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ public function testClearDebugbarWithError(): void
9191
@exec('which chattr', $whichOut, $whichRc);
9292

9393
if ($whichRc === 0) {
94-
@exec(sprintf('sudo chattr +i %s', escapeshellarg($path)), $output, $rc);
94+
@exec(sprintf(
95+
'%schattr +i %s 2>/dev/null',
96+
getenv('GITHUB_ACTIONS') !== false ? 'sudo ' : '', // GHA supports passwordless sudo
97+
escapeshellarg($path),
98+
), $output, $rc);
9599
$immutableSet = $rc === 0;
96100
}
97101
}

tests/system/Commands/Housekeeping/ClearLogsTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ public function testClearLogsFailsOnChmodFailure(): void
154154
@exec('which chattr', $whichOut, $whichRc);
155155

156156
if ($whichRc === 0) {
157-
@exec(sprintf('sudo chattr +i %s', escapeshellarg($path)), $output, $rc);
157+
@exec(sprintf(
158+
'%schattr +i %s 2>/dev/null',
159+
getenv('GITHUB_ACTIONS') !== false ? 'sudo ' : '', // GHA supports passwordless sudo
160+
escapeshellarg($path),
161+
), $output, $rc);
158162
$immutableSet = $rc === 0;
159163
}
160164
}

0 commit comments

Comments
 (0)