Skip to content

Commit 9dbfffa

Browse files
committed
Remove the project root path from .out files
Signed-off-by: William Desportes <[email protected]>
1 parent 3a6d265 commit 9dbfffa

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/Tools/TestGenerator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PhpMyAdmin\SqlParser\Parser;
1313
use PhpMyAdmin\SqlParser\Token;
1414

15+
use function dirname;
1516
use function file_exists;
1617
use function file_get_contents;
1718
use function file_put_contents;
@@ -25,11 +26,13 @@
2526
use function sprintf;
2627
use function str_contains;
2728
use function str_ends_with;
29+
use function str_replace;
2830
use function strpos;
2931
use function substr;
3032

3133
use const JSON_PRESERVE_ZERO_FRACTION;
3234
use const JSON_PRETTY_PRINT;
35+
use const JSON_UNESCAPED_SLASHES;
3336
use const JSON_UNESCAPED_UNICODE;
3437

3538
/**
@@ -174,10 +177,15 @@ public static function build($type, $input, $output, $debug = null, $ansi = fals
174177
// Writing test's data.
175178
$encoded = $serializer->serialize($test);
176179

177-
$encoded = json_encode(
180+
$encoded = (string) json_encode(
178181
json_decode($encoded),
179-
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION
182+
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_SLASHES
180183
);
184+
185+
// Remove the project path from .out file, it changes for each dev
186+
$projectFolder = dirname(__DIR__, 2);// Jump to root
187+
$encoded = str_replace($projectFolder, '<project-root>', $encoded);
188+
181189
file_put_contents($output, $encoded);
182190

183191
// Dumping test's data in human readable format too (if required).

tests/data/parser/parseExplainErr1.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
},
137137
"message": "An expression was expected.",
138138
"code": 0,
139-
"file": "\/mnt\/Dev\/@phpmyadmin\/sql-parser\/src\/Parser.php",
139+
"file": "<project-root>/src/Parser.php",
140140
"line": 627
141141
},
142142
{
@@ -146,7 +146,7 @@
146146
},
147147
"message": "An expression was expected.",
148148
"code": 0,
149-
"file": "\/mnt\/Dev\/@phpmyadmin\/sql-parser\/src\/Parser.php",
149+
"file": "<project-root>/src/Parser.php",
150150
"line": 627
151151
}
152152
]

0 commit comments

Comments
 (0)