diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-26 15:25:33 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-26 15:29:00 +0100 |
commit | 46cddb8c1a393cc7d03fbd897f2504ae9f47179d (patch) | |
tree | 38cb605c453ecc24ee86d25b3d6ab760a10c8f21 /methods | |
parent | 0b29c72bdfc1466d47567cc3191b9661f81d3d3f (diff) |
rred: Allow passing files as arguments for compressor testing
This introduces a -t mode in which the first argument is input,
the second is output and the remaining are diffs.
This allows us to test patching compressed files, which are
detected using their file extension.
Diffstat (limited to 'methods')
-rw-r--r-- | methods/rred.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/methods/rred.cc b/methods/rred.cc index bb801cb4e..351c1ebf9 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -689,6 +689,7 @@ int main(int argc, char **argv) { int i; bool just_diff = true; + bool test = false; Patch patch; if (argc <= 1) { @@ -696,7 +697,12 @@ int main(int argc, char **argv) return Mth.Run(); } - if (argc > 1 && strcmp(argv[1], "-f") == 0) { + // Usage: rred -t input output diff ... + if (argc > 1 && strcmp(argv[1], "-t") == 0) { + just_diff = false; + test = true; + i = 4; + } else if (argc > 1 && strcmp(argv[1], "-f") == 0) { just_diff = false; i = 2; } else { @@ -716,7 +722,13 @@ int main(int argc, char **argv) } } - if (just_diff) { + if (test) { + FileFd out, inp; + std::cerr << "Patching " << argv[2] << " into " << argv[3] << "\n"; + inp.Open(argv[2], FileFd::ReadOnly,FileFd::Extension); + out.Open(argv[3], FileFd::WriteOnly | FileFd::Create, FileFd::Extension); + patch.apply_against_file(out, inp); + } else if (just_diff) { FileFd out; out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly | FileFd::Create); patch.write_diff(out); |