Skip to content

Commit 96fca76

Browse files
authored
Merge pull request microsoft#150 from Microsoft/lexicalGrammarTestSetup
Fix LexicalGrammarTest when no expected tokens present
2 parents f536fc6 + 55c2a2b commit 96fca76

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/LexicalGrammarTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFai
3333
* @dataProvider lexicalProvider
3434
*/
3535
public function testOutputTokenClassificationAndLength($testCaseFile, $expectedTokensFile) {
36+
$fileContents = file_get_contents($testCaseFile);
37+
if (!file_exists($expectedTokensFile)) {
38+
file_put_contents($expectedTokensFile, $fileContents);
39+
exec("git add " . $expectedTokensFile);
40+
}
41+
3642
$expectedTokens = str_replace("\r\n", "\n", file_get_contents($expectedTokensFile));
37-
$lexer = \Microsoft\PhpParser\TokenStreamProviderFactory::GetTokenStreamProvider(file_get_contents($testCaseFile));
43+
$lexer = \Microsoft\PhpParser\TokenStreamProviderFactory::GetTokenStreamProvider($fileContents);
3844
$GLOBALS["SHORT_TOKEN_SERIALIZE"] = true;
3945
$tokens = str_replace("\r\n", "\n", json_encode($lexer->getTokensArray(), JSON_PRETTY_PRINT));
4046
$GLOBALS["SHORT_TOKEN_SERIALIZE"] = false;

0 commit comments

Comments
 (0)