Skip to content

Commit

Permalink
fix mystrerious lf bug
Browse files Browse the repository at this point in the history
  • Loading branch information
calpo committed May 25, 2014
1 parent fd82bd0 commit 3d6b197
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/FlflPlainize.php
Expand Up @@ -20,6 +20,7 @@ public function __construct(Iterator $input, Outputter $outputter)
public function main(Array $keys)
{
foreach ($this->input as $line_str) {
$line_str = trim($line_str);
try {
$line = new Line($line_str);
} catch (InvalidLineException $e) {
Expand Down
30 changes: 21 additions & 9 deletions tests/acceptance/FlflPlainizeTest.php
Expand Up @@ -11,30 +11,42 @@
*/
class FlflPlainizeTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
exec('cd ' . ROOT);
}
private $fixtureDir;
private $normalLog;
private $cmd;

public function setUp()
{
$this->fixtureDir = ROOT . '/tests/fixture';
$this->normalLog = $this->fixtureDir . '/normal.log';
$this->cmd = ROOT . '/bin/flflplainize';
}

/**
* @test
* @group xfail
* known bug. mysterious empty line was added to output.
*/
public function itReceivesStdinAndOutputsToStdout()
{
exec('cat tests/fixture/normal.log | bin/flflplainize -k foo --key data.buz', $output, $retval);
exec(
"cat {$this->normalLog} | {$this->cmd} -k foo --key data.buz",
$output,
$retval
);

$this->assertEquals(0, $retval);
$this->assertCount(3, $output);
$this->assertCount(count(file($this->normalLog)) + 1, $output);
}

/**
* @test
*/
public function itConvertsLogFormatToPlainText()
{
exec('cat tests/fixture/normal.log | bin/flflplainize -k foo --key data.buz', $output, $retval);
exec(
"cat {$this->normalLog} | {$this->cmd} -k foo --key data.buz",
$output,
$retval
);

list($date, $firstItem, $secondItem) = explode("\t", $output[0]);

Expand Down

0 comments on commit 3d6b197

Please sign in to comment.