Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 0bdd183

Browse files
committed
Fix block in skip-linting process, fixes #34
1 parent 77d3245 commit 0bdd183

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

bin/skip-linting.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
$stdin = fopen('php://stdin', 'r');
3+
$input = stream_get_contents($stdin);
4+
fclose($stdin);
35

4-
while($file = fgets($stdin)) {
6+
foreach (explode("\n", $input) as $file) {
57
$skip = false;
6-
$file = rtrim($file);
78
$f = @fopen($file, 'r');
89
if ($f) {
910
$firstLine = fgets($f);
@@ -19,4 +20,3 @@
1920
echo "$file;" . ($skip ? '1' : '0') . "\n";
2021
}
2122

22-
fclose($stdin);

tests/SkipLintProcess.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* @testCase
5+
*/
6+
7+
require __DIR__ . '/../vendor/nette/tester/Tester/bootstrap.php';
8+
require_once __DIR__ . '/../src/Process.php';
9+
10+
use Tester\Assert;
11+
12+
$filesToCheck = [
13+
__DIR__ . '/skip-on-5.3/class.php',
14+
__DIR__ . '/skip-on-5.3/trait.php',
15+
];
16+
17+
for ($i = 0; $i < 15; $i++) {
18+
$filesToCheck = array_merge($filesToCheck, $filesToCheck);
19+
}
20+
21+
$process = new \JakubOnderka\PhpParallelLint\SkipLintProcess('php', $filesToCheck);
22+
23+
while (!$process->isFinished()) {
24+
usleep(100);
25+
$process->getChunk();
26+
}
27+
28+
foreach ($filesToCheck as $fileToCheck) {
29+
$status = $process->isSkipped($fileToCheck);
30+
Assert::notEqual(null, $status);
31+
}

0 commit comments

Comments
 (0)