Fossil SCM

Enhancements to the test-parse-manifest command to also test the manifest_is_well_formed() interface.

drh 2020-09-11 15:20 trunk
Commit 761696443aca574f1deeea0ec0865ff6d97f3c26a2b22f6126438d2ac2f7a8bb
1 file changed +15 -1
+15 -1
--- src/manifest.c
+++ src/manifest.c
@@ -1197,24 +1197,38 @@
11971197
void manifest_test_parse_cmd(void){
11981198
Manifest *p;
11991199
Blob b;
12001200
int i;
12011201
int n = 1;
1202
+ int isWF;
12021203
db_find_and_open_repository(OPEN_SUBSTITUTE|OPEN_OK_NOT_FOUND,0);
12031204
verify_all_options();
12041205
if( g.argc!=3 && g.argc!=4 ){
12051206
usage("FILENAME");
12061207
}
12071208
blob_read_from_file(&b, g.argv[2], ExtFILE);
12081209
if( g.argc>3 ) n = atoi(g.argv[3]);
1210
+ isWF = manifest_is_well_formed(blob_buffer(&b), blob_size(&b));
1211
+ fossil_print("manifest_is_well_formed() reports the input %s\n",
1212
+ isWF ? "is ok" : "contains errors");
12091213
for(i=0; i<n; i++){
12101214
Blob b2;
12111215
Blob err;
12121216
blob_copy(&b2, &b);
12131217
blob_zero(&err);
12141218
p = manifest_parse(&b2, 0, &err);
1215
- if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err));
1219
+ if( p==0 ){
1220
+ fossil_print("ERROR: %s\n", blob_str(&err));
1221
+ }else if( i==0 || (n==2 && i==1) ){
1222
+ fossil_print("manifest_parse() worked\n");
1223
+ }else if( i==n-1 ){
1224
+ fossil_print("manifest_parse() worked %d more times\n", n-1);
1225
+ }
1226
+ if( (p==0 && isWF) || (p!=0 && !isWF) ){
1227
+ fossil_print("ERROR: manifest_is_well_formed() and "
1228
+ "manifest_parse() disagree!\n");
1229
+ }
12161230
blob_reset(&err);
12171231
manifest_destroy(p);
12181232
}
12191233
blob_reset(&b);
12201234
}
12211235
--- src/manifest.c
+++ src/manifest.c
@@ -1197,24 +1197,38 @@
1197 void manifest_test_parse_cmd(void){
1198 Manifest *p;
1199 Blob b;
1200 int i;
1201 int n = 1;
 
1202 db_find_and_open_repository(OPEN_SUBSTITUTE|OPEN_OK_NOT_FOUND,0);
1203 verify_all_options();
1204 if( g.argc!=3 && g.argc!=4 ){
1205 usage("FILENAME");
1206 }
1207 blob_read_from_file(&b, g.argv[2], ExtFILE);
1208 if( g.argc>3 ) n = atoi(g.argv[3]);
 
 
 
1209 for(i=0; i<n; i++){
1210 Blob b2;
1211 Blob err;
1212 blob_copy(&b2, &b);
1213 blob_zero(&err);
1214 p = manifest_parse(&b2, 0, &err);
1215 if( p==0 ) fossil_print("ERROR: %s\n", blob_str(&err));
 
 
 
 
 
 
 
 
 
 
1216 blob_reset(&err);
1217 manifest_destroy(p);
1218 }
1219 blob_reset(&b);
1220 }
1221
--- src/manifest.c
+++ src/manifest.c
@@ -1197,24 +1197,38 @@
1197 void manifest_test_parse_cmd(void){
1198 Manifest *p;
1199 Blob b;
1200 int i;
1201 int n = 1;
1202 int isWF;
1203 db_find_and_open_repository(OPEN_SUBSTITUTE|OPEN_OK_NOT_FOUND,0);
1204 verify_all_options();
1205 if( g.argc!=3 && g.argc!=4 ){
1206 usage("FILENAME");
1207 }
1208 blob_read_from_file(&b, g.argv[2], ExtFILE);
1209 if( g.argc>3 ) n = atoi(g.argv[3]);
1210 isWF = manifest_is_well_formed(blob_buffer(&b), blob_size(&b));
1211 fossil_print("manifest_is_well_formed() reports the input %s\n",
1212 isWF ? "is ok" : "contains errors");
1213 for(i=0; i<n; i++){
1214 Blob b2;
1215 Blob err;
1216 blob_copy(&b2, &b);
1217 blob_zero(&err);
1218 p = manifest_parse(&b2, 0, &err);
1219 if( p==0 ){
1220 fossil_print("ERROR: %s\n", blob_str(&err));
1221 }else if( i==0 || (n==2 && i==1) ){
1222 fossil_print("manifest_parse() worked\n");
1223 }else if( i==n-1 ){
1224 fossil_print("manifest_parse() worked %d more times\n", n-1);
1225 }
1226 if( (p==0 && isWF) || (p!=0 && !isWF) ){
1227 fossil_print("ERROR: manifest_is_well_formed() and "
1228 "manifest_parse() disagree!\n");
1229 }
1230 blob_reset(&err);
1231 manifest_destroy(p);
1232 }
1233 blob_reset(&b);
1234 }
1235

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button