@@ -74,6 +74,8 @@ public class ParserTestBase {
74
74
protected boolean printFormatStringLiteralValues = false ;
75
75
protected int printOnlyDiffIfLenIsBigger = 1000 ;
76
76
77
+ private static final boolean REGENERATE_TREE = false ;
78
+
77
79
@ Rule public TestName name = new TestName ();
78
80
79
81
private ScopeInfo lastGlobalScope ;
@@ -155,7 +157,7 @@ public void saveNewTreeResult(File testFile, boolean goldenFileNextToTestFile) t
155
157
File newGoldenFile = goldenFileNextToTestFile
156
158
? new File (testFile .getParentFile (), getFileName (testFile ) + NEW_GOLDEN_FILE_EXT )
157
159
: getGoldenFile (NEW_GOLDEN_FILE_EXT );
158
- if (!newGoldenFile .exists ()) {
160
+ if (REGENERATE_TREE || !newGoldenFile .exists ()) {
159
161
try (FileWriter fw = new FileWriter (newGoldenFile )) {
160
162
fw .write (tree );
161
163
}
@@ -172,7 +174,7 @@ public void checkTreeFromFile(File testFile, boolean goldenFileNextToTestFile) t
172
174
File goldenFile = goldenFileNextToTestFile
173
175
? new File (testFile .getParentFile (), getFileName (testFile ) + GOLDEN_FILE_EXT )
174
176
: getGoldenFile (GOLDEN_FILE_EXT );
175
- if (!goldenFile .exists ()) {
177
+ if (REGENERATE_TREE || !goldenFile .exists ()) {
176
178
try (FileWriter fw = new FileWriter (goldenFile )) {
177
179
fw .write (tree );
178
180
}
@@ -192,7 +194,7 @@ public void saveNewScope(File testFile, boolean goldenFileNextToTestFile) throws
192
194
File newScopeFile = goldenFileNextToTestFile
193
195
? new File (testFile .getParentFile (), getFileName (testFile ) + NEW_SCOPE_FILE_EXT )
194
196
: getGoldenFile (NEW_SCOPE_FILE_EXT );
195
- if (!newScopeFile .exists ()) {
197
+ if (REGENERATE_TREE || !newScopeFile .exists ()) {
196
198
try (FileWriter fw = new FileWriter (newScopeFile )) {
197
199
fw .write (scopes .toString ());
198
200
}
@@ -210,7 +212,7 @@ public void checkScopeFromFile(File testFile, boolean goldenFileNextToTestFile)
210
212
File goldenScopeFile = goldenFileNextToTestFile
211
213
? new File (testFile .getParentFile (), getFileName (testFile ) + SCOPE_FILE_EXT )
212
214
: getGoldenFile (SCOPE_FILE_EXT );
213
- if (!goldenScopeFile .exists ()) {
215
+ if (REGENERATE_TREE || !goldenScopeFile .exists ()) {
214
216
try (FileWriter fw = new FileWriter (goldenScopeFile )) {
215
217
fw .write (scopes .toString ());
216
218
}
@@ -223,7 +225,7 @@ public void checkTreeResult(String source, PythonParser.ParserMode mode, Frame f
223
225
Node resultNew = parse (source , name .getMethodName (), mode , frame );
224
226
String tree = printTreeToString (resultNew );
225
227
File goldenFile = getGoldenFile (GOLDEN_FILE_EXT );
226
- if (!goldenFile .exists ()) {
228
+ if (REGENERATE_TREE || !goldenFile .exists ()) {
227
229
try (FileWriter fw = new FileWriter (goldenFile )) {
228
230
fw .write (tree );
229
231
}
@@ -242,7 +244,7 @@ public void checkScopeResult(String source, PythonParser.ParserMode mode) throws
242
244
StringBuilder scopes = new StringBuilder ();
243
245
scopeNew .debugPrint (scopes , 0 );
244
246
File goldenScopeFile = getGoldenFile (SCOPE_FILE_EXT );
245
- if (!goldenScopeFile .exists ()) {
247
+ if (REGENERATE_TREE || !goldenScopeFile .exists ()) {
246
248
try (FileWriter fw = new FileWriter (goldenScopeFile )) {
247
249
fw .write (scopes .toString ());
248
250
}
0 commit comments