Skip to content

Commit

Permalink
Add restricted test (#84)
Browse files Browse the repository at this point in the history
This is to mimic some failures that happened on PHPStan repo
  • Loading branch information
theofidry authored Dec 10, 2022
1 parent f97cce1 commit 666cb04
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,30 @@ jobs:

- name: "Run E2E tests"
run: "./e2e/test-finders.sh"

e2e-ubuntu-restricted:
name: "End-to-End tests Ubuntu (restricted)"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "8.1"
steps:
- name: "Checkout"
uses: "actions/[email protected]"

- name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
coverage: "xdebug"
php-version: "${{ matrix.php-version }}"
tools: "phive"

- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: "Setup the expected output"
run: "mv e2e/expected-output-ubuntu-restricted e2e/expected-output"

- name: "Run E2E tests"
run: "./e2e/test-restricted-finders.sh"
13 changes: 13 additions & 0 deletions e2e/expected-output-ubuntu-restricted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CpuInfoFinder: F
DummyCpuCoreFinder(value=1): .
HwLogicalFinder: F
HwPhysicalFinder: F
_NProcessorFinder: F
NProcessorFinder: F
NProcFinder(all=true): F
NProcFinder(all=false): F
NullCpuCoreFinder: F
OnlyOnWindowsFinder(DummyCpuCoreFinder(value=1)): F
SkipOnWindowsFinder(DummyCpuCoreFinder(value=1)): .
WmicPhysicalFinder: F
WmicLogicalFinder: F
9 changes: 9 additions & 0 deletions e2e/test-restricted-finders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

execute_finders() {
php -d open_basedir="$(cd .. && pwd):$(php -r 'echo sys_get_temp_dir();')" -d disable_functions="pcntl_exec,pcntl_fork,exec,passthru,proc_open,shell_exec,system,popen" "$(pwd)/e2e/execute-finders.php" 2>&1
}

execute_finders > $(pwd)/e2e/actual-output

diff --ignore-all-space e2e/expected-output e2e/actual-output
4 changes: 2 additions & 2 deletions src/Finder/CpuInfoFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public function toString(): string

private static function getCpuInfo(): ?string
{
if (!is_file(self::CPU_INFO_PATH)) {
if (!@is_file(self::CPU_INFO_PATH)) {
return null;
}

$cpuInfo = file_get_contents(self::CPU_INFO_PATH);
$cpuInfo = @file_get_contents(self::CPU_INFO_PATH);

return false === $cpuInfo
? null
Expand Down

0 comments on commit 666cb04

Please sign in to comment.