aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-29 14:41:21 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-07-29 14:42:03 -0700
commit52ae5f885e9c72b7b1477156bdb946fc78294052 (patch)
tree10bb26e2dc7f7c4c79fbf11aca2d34ae6f44e436 /fish_tests.cpp
parentb6658c54974f0488de89042545e417d2b9d2b5eb (diff)
Improve history robustness against corrupt files
Fixes #1581
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r--fish_tests.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp
index a415d08e..3a653797 100644
--- a/fish_tests.cpp
+++ b/fish_tests.cpp
@@ -2827,7 +2827,7 @@ static bool history_equals(history_t &hist, const wchar_t * const *strings)
void history_tests_t::test_history_formats(void)
{
const wchar_t *name;
-
+
// Test inferring and reading legacy and bash history formats
name = L"history_sample_fish_1_x";
say(L"Testing %ls", name);
@@ -2920,6 +2920,33 @@ void history_tests_t::test_history_formats(void)
test_history.clear();
fclose(f);
}
+
+ name = L"history_sample_corrupt1";
+ say(L"Testing %ls", name);
+ if (! install_sample_history(name))
+ {
+ err(L"Couldn't open file tests/%ls", name);
+ }
+ else
+ {
+ /* We simply invoke get_string_representation. If we don't die, the test is a success. */
+ history_t &test_history = history_t::history_with_name(name);
+ const wchar_t *expected[] =
+ {
+ L"no_newline_at_end_of_file",
+
+ L"corrupt_prefix",
+
+ L"this_command_is_ok",
+
+ NULL
+ };
+ if (! history_equals(test_history, expected))
+ {
+ err(L"test_history_formats failed for %ls\n", name);
+ }
+ test_history.clear();
+ }
}
void history_tests_t::test_history_speed(void)