Fossil SCM
Enhancements to the test-parse-manifest command to also test the manifest_is_well_formed() interface.
Commit
761696443aca574f1deeea0ec0865ff6d97f3c26a2b22f6126438d2ac2f7a8bb
Parent
0f7eff9eebc00cc…
1 file changed
+15
-1
+15
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1197,24 +1197,38 @@ | ||
| 1197 | 1197 | void manifest_test_parse_cmd(void){ |
| 1198 | 1198 | Manifest *p; |
| 1199 | 1199 | Blob b; |
| 1200 | 1200 | int i; |
| 1201 | 1201 | int n = 1; |
| 1202 | + int isWF; | |
| 1202 | 1203 | db_find_and_open_repository(OPEN_SUBSTITUTE|OPEN_OK_NOT_FOUND,0); |
| 1203 | 1204 | verify_all_options(); |
| 1204 | 1205 | if( g.argc!=3 && g.argc!=4 ){ |
| 1205 | 1206 | usage("FILENAME"); |
| 1206 | 1207 | } |
| 1207 | 1208 | blob_read_from_file(&b, g.argv[2], ExtFILE); |
| 1208 | 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"); | |
| 1209 | 1213 | for(i=0; i<n; i++){ |
| 1210 | 1214 | Blob b2; |
| 1211 | 1215 | Blob err; |
| 1212 | 1216 | blob_copy(&b2, &b); |
| 1213 | 1217 | blob_zero(&err); |
| 1214 | 1218 | 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 | + } | |
| 1216 | 1230 | blob_reset(&err); |
| 1217 | 1231 | manifest_destroy(p); |
| 1218 | 1232 | } |
| 1219 | 1233 | blob_reset(&b); |
| 1220 | 1234 | } |
| 1221 | 1235 |
| --- 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 |