223
223
static svn_error_t *
224
224
create_file(const char *fname, const char *eol_str, apr_pool_t *pool)
226
apr_status_t apr_err;
230
apr_err = apr_file_open(&f, fname,
229
SVN_ERR(svn_io_file_open(&f, fname,
231
230
(APR_WRITE | APR_CREATE | APR_EXCL | APR_BINARY),
232
APR_OS_DEFAULT, pool);
234
return svn_error_create(apr_err, NULL, fname);
231
APR_OS_DEFAULT, pool));
236
233
for (i = 0; i < (sizeof(lines) / sizeof(*lines)); i++)
243
240
fprintf() doing a newline conversion? */
244
241
for (j = 0; this_eol_str[j]; j++)
246
apr_err = apr_file_putc(this_eol_str[j], f);
248
return svn_error_create(apr_err, NULL, fname);
252
apr_err = apr_file_close(f);
254
return svn_error_create(apr_err, NULL, fname);
260
/* If FNAME is a regular file, remove it; if it doesn't exist at all,
261
return success. Otherwise, return error. */
263
remove_file(const char *fname, apr_pool_t *pool)
265
apr_status_t apr_err;
268
if (apr_stat(&finfo, fname, APR_FINFO_TYPE, pool) == APR_SUCCESS)
270
if (finfo.filetype == APR_REG)
272
apr_err = apr_file_remove(fname, pool);
274
return svn_error_create(apr_err, NULL, fname);
277
return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
278
"non-file '%s' is in the way", fname);
243
SVN_ERR(svn_io_file_putc(this_eol_str[j], f, pool));
247
return svn_error_trace(svn_io_file_close(f, pool));
285
250
/* Set up, run, and verify the results of a substitution.
325
290
apr_size_t idx = 0;
327
292
const char *expect[(sizeof(lines) / sizeof(*lines))];
328
const char *src_fname = apr_pstrcat(pool, test_name, ".src", (char *)NULL);
329
const char *dst_fname = apr_pstrcat(pool, test_name, ".dst", (char *)NULL);
293
const char *src_fname = apr_pstrcat(pool, test_name, ".src", SVN_VA_NULL);
294
const char *dst_fname = apr_pstrcat(pool, test_name, ".dst", SVN_VA_NULL);
330
295
svn_string_t *val;
331
296
apr_pool_t *subpool = svn_pool_create(pool);
333
298
/** Clean up from previous tests, set up src data, and convert. **/
334
SVN_ERR(remove_file(src_fname, pool));
335
SVN_ERR(remove_file(dst_fname, pool));
299
SVN_ERR(svn_io_remove_file2(src_fname, TRUE, pool));
300
SVN_ERR(svn_io_remove_file2(dst_fname, TRUE, pool));
336
301
SVN_ERR(create_file(src_fname, src_eol, pool));
419
384
"Valid $LastChangedRevision: ",
421
386
" $, started unexpanded.",
424
389
apr_pstrcat(pool, "Line 5: ",
425
390
"Valid $Rev: ", rev, " $, started unexpanded.",
428
393
apr_pstrcat(pool, "Line 26: ",
429
394
"Emptily expanded keyword $Rev: ", rev," $.",
432
397
apr_pstrcat(pool, "Line 29: ",
433
398
"Valid $LastChangedRevision: ",
435
400
" $, started expanded.",
438
403
apr_pstrcat(pool, "Line 30: ",
441
406
" $, started expanded.",
444
409
else /* unexpand */
462
427
"Valid $LastChangedDate: ",
464
429
" $, started unexpanded.",
467
432
apr_pstrcat(pool, "Line 13: ",
468
433
"Valid $Date: ", date, " $, started unexpanded.",
471
436
apr_pstrcat(pool, "Line 33: ",
472
437
"Valid $LastChangedDate: ",
474
439
" $, started expanded.",
477
442
apr_pstrcat(pool, "Line 34: ",
478
443
"Valid $Date: ", date, " $, started expanded.",
481
446
apr_pstrcat(pool, "Line 51: ",
482
447
"same, but with embedded keyword ",
483
448
"$$$$$$$$Date: ", date, " $$$$$$$$$$.",
486
451
apr_pstrcat(pool, "Line 52: ",
487
452
"same, with expanded, empty keyword ",
488
453
"$$$$$$Date: ", date, " $$$$$$.",
491
456
else /* unexpand */
511
476
"Valid $LastChangedBy: ",
513
478
" $, started unexpanded.",
516
481
apr_pstrcat(pool, "Line 9: ",
517
482
"Valid $Author: ", author, " $, started unexpanded.",
520
485
apr_pstrcat(pool, "Line 37: ",
521
486
"Valid $LastChangedBy: ", author,
522
" $, started expanded.", (char *)NULL);
487
" $, started expanded.", SVN_VA_NULL);
524
489
apr_pstrcat(pool, "Line 38: ",
525
490
"Valid $Author: ", author, " $, started expanded.",
528
493
apr_pstrcat(pool, "Line 46: ",
529
494
"Empty $Author: ", author, " $, started expanded.",
532
apr_pstrcat(pool, ".$veR$Author: ", author, " $", (char *)NULL);
497
apr_pstrcat(pool, ".$veR$Author: ", author, " $", SVN_VA_NULL);
535
500
apr_pstrcat(pool, "Line 74: ",
536
501
"Valid $Author: ", author, " $, started expanded.",
539
504
apr_pstrcat(pool, "Line 79: ",
540
505
"Valid $Author: ", author, " $, started expanded.",
543
508
apr_pstrcat(pool, "Line 80: ",
544
509
"Valid $Author: ", author, " $, started expanded.",
547
512
apr_pstrcat(pool, "Line 81: ",
548
513
"Valid $Author: ", author, " $, started expanded.",
551
516
apr_pstrcat(pool, "Line 82: ",
552
517
"Valid $Author: ", author, " $, started expanded.",
555
520
else /* unexpand */
582
547
apr_pstrcat(pool, "Line 16: ",
583
548
"Valid $HeadURL: ", url, " $, started unexpanded.",
586
551
apr_pstrcat(pool, "Line 17: ",
587
552
"Valid $URL: ", url, " $, started unexpanded.",
590
555
apr_pstrcat(pool, "Line 41: ",
591
556
"Valid $HeadURL: ", url, " $, started expanded.",
594
559
apr_pstrcat(pool, "Line 42: ",
595
560
"Valid $URL: ", url, " $, started expanded.",
598
563
apr_pstrcat(pool, "Line 75: ",
599
564
"Valid $URL: ", url, " $, started expanded.",
602
567
else /* unexpand */
622
587
"Two keywords back to back: "
623
588
"$Author: ", author, " $"
624
589
"$Rev: ", rev, " $.",
627
592
apr_pstrcat(pool, "Line 49: ",
628
593
"One keyword, one not, back to back: "
629
594
"$Author: ", author, " $Rev$.",
632
apr_pstrcat(pool, "$Author: ", author, " $Rev$.", (char *)NULL);
597
apr_pstrcat(pool, "$Author: ", author, " $Rev$.", SVN_VA_NULL);
634
599
/* Else Lines 48, 49, and 70 remain unchanged. */
641
606
apr_pstrcat(pool, "Line 48: ",
642
607
"Two keywords back to back: "
643
608
"$Author$$Rev: ", rev, " $.",
646
611
apr_pstrcat(pool, "Line 49: ",
647
612
"One keyword, one not, back to back: "
648
613
"$Author$Rev: ", rev, " $.",
651
apr_pstrcat(pool, "$Author$Rev: ", rev, " $.", (char *)NULL);
616
apr_pstrcat(pool, "$Author$Rev: ", rev, " $.", SVN_VA_NULL);
653
618
/* Else Lines 48, 49, and 70 remain unchanged. */
660
625
apr_pstrcat(pool, "Line 48: ",
661
626
"Two keywords back to back: "
662
627
"$Author: ", author, " $$Rev$.",
665
630
apr_pstrcat(pool, "Line 49: ",
666
631
"One keyword, one not, back to back: "
667
632
"$Author: ", author, " $Rev$.",
670
apr_pstrcat(pool, "$Author: ", author, " $Rev$.", (char *)NULL);
635
apr_pstrcat(pool, "$Author: ", author, " $Rev$.", SVN_VA_NULL);
672
637
/* Else Lines 48, 49, and 70 remain unchanged. */
771
736
/* Clean up this test, since successful. */
772
SVN_ERR(remove_file(src_fname, pool));
773
SVN_ERR(remove_file(dst_fname, pool));
737
SVN_ERR(svn_io_remove_file2(src_fname, FALSE, pool));
738
SVN_ERR(svn_io_remove_file2(dst_fname, FALSE, pool));
775
740
return SVN_NO_ERROR;
862
827
mixed_to_lf(apr_pool_t *pool)
864
829
return substitute_and_verify
865
("cr_to_lf", NULL, "\n", 1, NULL, NULL, NULL, NULL, 1, pool);
830
("mixed_to_lf", NULL, "\n", 1, NULL, NULL, NULL, NULL, 1, pool);
1096
1061
unexpand_author(apr_pool_t *pool)
1098
1063
SVN_ERR(substitute_and_verify
1099
("author", "\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1064
("unexpand_author", "\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1101
1066
SVN_ERR(substitute_and_verify
1102
("author", "\r\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1067
("unexpand_author", "\r\n", NULL, 0, NULL, NULL, "jrandom", NULL, 0, pool));
1104
1069
return SVN_NO_ERROR;
1109
1074
unexpand_date(apr_pool_t *pool)
1111
1076
SVN_ERR(substitute_and_verify
1112
("date", "\n", NULL, 0,
1077
("unexpand_date", "\n", NULL, 0,
1113
1078
NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 0, pool));
1115
1080
SVN_ERR(substitute_and_verify
1116
("date", "\r\n", NULL, 0,
1081
("unexpand_date", "\r\n", NULL, 0,
1117
1082
NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 0, pool));
1119
1084
return SVN_NO_ERROR;
1124
1089
unexpand_author_date(apr_pool_t *pool)
1126
1091
SVN_ERR(substitute_and_verify
1127
("author_date", "\n", NULL, 0,
1092
("unexpand_author_date", "\n", NULL, 0,
1128
1093
NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool));
1130
1095
SVN_ERR(substitute_and_verify
1131
("author_date", "\r\n", NULL, 0,
1096
("unexpand_author_date", "\r\n", NULL, 0,
1132
1097
NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool));
1134
1099
return SVN_NO_ERROR;
1139
1104
unexpand_author_rev(apr_pool_t *pool)
1141
1106
SVN_ERR(substitute_and_verify
1142
("author_rev", "\n", NULL, 0,
1107
("unexpand_author_rev", "\n", NULL, 0,
1143
1108
"1729", NULL, "jrandom", NULL, 0, pool));
1145
1110
SVN_ERR(substitute_and_verify
1146
("author_rev", "\r\n", NULL, 0,
1111
("unexpand_author_rev", "\r\n", NULL, 0,
1147
1112
"1729", NULL, "jrandom", NULL, 0, pool));
1149
1114
return SVN_NO_ERROR;
1154
1119
unexpand_rev(apr_pool_t *pool)
1156
1121
SVN_ERR(substitute_and_verify
1157
("rev", "\n", NULL, 0,
1122
("unexpand_rev", "\n", NULL, 0,
1158
1123
"1729", NULL, NULL, NULL, 0, pool));
1160
1125
SVN_ERR(substitute_and_verify
1161
("rev", "\r\n", NULL, 0,
1126
("unexpand_rev", "\r\n", NULL, 0,
1162
1127
"1729", NULL, NULL, NULL, 0, pool));
1164
1129
return SVN_NO_ERROR;
1169
1134
unexpand_rev_url(apr_pool_t *pool)
1171
1136
SVN_ERR(substitute_and_verify
1172
("rev_url", "\n", NULL, 0,
1137
("unexpand_rev_url", "\n", NULL, 0,
1173
1138
"1729", NULL, NULL, "http://subversion.tigris.org", 0, pool));
1175
1140
SVN_ERR(substitute_and_verify
1176
("rev_url", "\r\n", NULL, 0,
1141
("unexpand_rev_url", "\r\n", NULL, 0,
1177
1142
"1729", NULL, NULL, "http://subversion.tigris.org", 0, pool));
1179
1144
return SVN_NO_ERROR;
1184
1149
unexpand_author_date_rev_url(apr_pool_t *pool)
1186
1151
SVN_ERR(substitute_and_verify
1187
("author_date_rev_url", "\n", NULL, 0,
1152
("unexpand_author_date_rev_url", "\n", NULL, 0,
1189
1154
"Wed Jan 9 07:49:05 2002",
1194
1159
SVN_ERR(substitute_and_verify
1195
("author_date_rev_url", "\r\n", NULL, 0,
1160
("unexpand_author_date_rev_url", "\r\n", NULL, 0,
1197
1162
"Wed Jan 9 07:49:05 2002",
1210
1175
lf_to_crlf_unexpand_author(apr_pool_t *pool)
1212
1177
return substitute_and_verify
1213
("lf_to_crlf_author", "\n", "\r\n", 0,
1178
("lf_to_crlf_unexpand_author", "\n", "\r\n", 0,
1214
1179
NULL, NULL, "jrandom", NULL, 0, pool);
1219
1184
mixed_to_lf_unexpand_author_date(apr_pool_t *pool)
1221
1186
return substitute_and_verify
1222
("mixed_to_lf_author_date", NULL, "\n", 1,
1187
("mixed_to_lf_unexpand_author_date", NULL, "\n", 1,
1223
1188
NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 0, pool);
1228
1193
crlf_to_cr_unexpand_author_rev(apr_pool_t *pool)
1230
1195
return substitute_and_verify
1231
("crlf_to_cr_author_rev", "\r\n", "\r", 0,
1196
("crlf_to_cr_unexpand_author_rev", "\r\n", "\r", 0,
1232
1197
"1729", NULL, "jrandom", NULL, 0, pool);
1237
1202
cr_to_crlf_unexpand_rev(apr_pool_t *pool)
1239
1204
return substitute_and_verify
1240
("cr_to_crlf_rev", "\r", "\r\n", 0,
1205
("cr_to_crlf_unexpand_rev", "\r", "\r\n", 0,
1241
1206
"1729", NULL, NULL, NULL, 0, pool);
1246
1211
cr_to_crlf_unexpand_rev_url(apr_pool_t *pool)
1248
1213
return substitute_and_verify
1249
("cr_to_crlf_rev_url", "\r", "\r\n", 0,
1214
("cr_to_crlf_unexpand_rev_url", "\r", "\r\n", 0,
1250
1215
"1729", NULL, NULL, "http://subversion.tigris.org", 0, pool);
1255
1220
mixed_to_crlf_unexpand_author_date_rev_url(apr_pool_t *pool)
1257
1222
return substitute_and_verify
1258
("mixed_to_crlf_author_date_rev_url", NULL, "\r\n", 1,
1223
("mixed_to_crlf_unexpand_author_date_rev_url", NULL, "\r\n", 1,
1260
1225
"Wed Jan 9 07:49:05 2002",