Skip to content

Commit

Permalink
sf2yaml parser multiline flow-scalar string issue
Browse files Browse the repository at this point in the history
merely book-keeping. libyaml not affected. capture the issue in test.
  • Loading branch information
ktomk committed Jun 21, 2022
1 parent f3dd446 commit 945e5a5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/data/yml/yaml/syntax-issue-16-workaround.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.test-sleep: &test-sleep
sleep 10; sleep 20;

.test-step: &test-sleep-step
step:
name: Simple Test
script:
- date;
- *test-sleep
- date;

pipelines:
default:
- parallel:
- <<: *test-sleep-step
4 changes: 4 additions & 0 deletions test/data/yml/yaml/syntax-issue-16.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sf2Yaml has an issue with (indent) multi-line strings
test-sleep: &test-sleep
sleep 10;
sleep 20;
25 changes: 24 additions & 1 deletion test/unit/Yaml/Sf2YamlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function testCreation()

/**
* @param Sf2Yaml $parser
*
* @depends testCreation
*/
public function testParsing(Sf2Yaml $parser)
Expand Down Expand Up @@ -64,6 +65,7 @@ public function testParseFile(Sf2Yaml $parser)
* @depends testCreation
*
* @param Sf2Yaml $parser
*
* @covers \Ktomk\Pipelines\Yaml\Sf2Yaml::tryParseBuffer
*/
public function testParseFileError(Sf2Yaml $parser)
Expand All @@ -87,7 +89,8 @@ public function testParseFileError(Sf2Yaml $parser)
* @depends testCreation
*
* @param Sf2Yaml $parser
* @covers \Ktomk\Pipelines\Yaml\Sf2Yaml::tryParseBuffer
*
* @covers \Ktomk\Pipelines\Yaml\Sf2Yaml::tryParseBuffer
*/
public function testParseFileError2(Sf2Yaml $parser)
{
Expand All @@ -101,4 +104,24 @@ public function testParseFileError2(Sf2Yaml $parser)
$this->expectExceptionMessage('Malformed inline YAML string ');
$parser->parseFile($path);
}

/**
* @depends testCreation
*
* @param Sf2Yaml $parser
*
* @return void
*/
public function testParseFileError3(Sf2Yaml $parser)
{
$path = __DIR__ . '/../../data/yml/yaml/syntax-issue-16.yml';

$struct = $parser->tryParseFile($path);

self::assertNull($struct);

$this->expectException(__NAMESPACE__ . '\ParseException');
$this->expectExceptionMessage('Unable to parse at line 3 (near "sleep 10;").');
$parser->parseFile($path);
}
}

0 comments on commit 945e5a5

Please sign in to comment.