Skip to content

Commit

Permalink
debug test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ogmueller committed Dec 22, 2023
1 parent 4e2939f commit de80e01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions src/Console/ShareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,27 @@ protected function readFile(InputInterface $input, OutputInterface $output): ?st
{
$secret = null;

# check if data is given by STDIN
$readStreams = [STDIN];
$writeStreams = [];
$exceptStreams = [];
$streamCount = stream_select($readStreams, $writeStreams, $exceptStreams, 0);

if ($streamCount === 1) {
while (!feof(STDIN)) {
$secret .= fread(STDIN, 1024);
$file = $input->getOption('file');

if ($file !== null) {
# check for secret in file
if (!is_readable($file)) {
$output->writeln('<error>ERROR: file "'.$file.'" is not readable.');
exit(1);
}
} else {
$file = $input->getOption('file');

if ($file !== null) {
# check for secret in file
if (!is_readable($file)) {
$output->writeln('<error>ERROR: file "'.$file.'" is not readable.');
exit(1);
$secret = file_get_contents($file);
} else {
# check if data is given by STDIN
$readStreams = [STDIN];
$writeStreams = [];
$exceptStreams = [];
$streamCount = stream_select($readStreams, $writeStreams, $exceptStreams, 0);

if ($streamCount === 1) {
while (!feof(STDIN)) {
$secret .= fread(STDIN, 1024);
}

$secret = file_get_contents($file);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function testVersion(): void

public function testFileInput(): void
{
$ret = $this->execute(self::$cmd.' shamir:share \-f tests/secret.txt');
$ret = $this->execute(self::$cmd.' shamir:share -f tests/secret.txt');
self::assertEquals(0, $ret['ret'], 'Non zero return code: '.var_export($ret, true));
self::assertMatchesRegularExpression('(10201.*)', $ret['std']);
self::assertMatchesRegularExpression('(10202.*)', $ret['std']);
Expand Down

0 comments on commit de80e01

Please sign in to comment.