Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lnav.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,9 @@ VALUES ('org.lnav.mouse-support', -1, DATETIME('now', '+1 minute'),
lnav_data.ld_files_view.set_selection(0_vl);
}
}
lnav_data.ld_views[LNV_LOG].set_top_for_last_row();
if (!lnav_data.ld_views[LNV_LOG].get_selection().has_value()) {
lnav_data.ld_views[LNV_LOG].set_top_for_last_row();
}
lnav::session::restore_view_states();
lnav_data.ld_active_files.fc_files
| lnav::itertools::for_each(&logfile::dump_stats);
Expand Down
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ dist_noinst_DATA = \
UTF-8-test.txt \
view_colors_output.0 \
xpath_tui.0 \
goto_tui.0 \
configs/installed/anno-test.json \
configs/installed/anno-test.sh \
configs/installed/hw-url-handler.json \
Expand Down
2 changes: 2 additions & 0 deletions test/goto_tui.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
K 71
# Key: q
12 changes: 9 additions & 3 deletions test/scripty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ usage()
" -h Print this message, then exit.\n"
" -n Do not pass the output to the console.\n"
" -X Set TERM to xterm-256color.\n"
" -r Replay input without comparing the terminal output.\n"
" -i Pass stdin to the child process instead of connecting\n"
" the child to the tty.\n"
" -a <file> The file where the actual I/O from/to the child "
Expand All @@ -1225,14 +1226,14 @@ int
main(int argc, char* argv[])
{
int c, fd, retval = EXIT_SUCCESS;
bool passout = true, prompt = false;
bool passout = true, prompt = false, compare_output = true;
const char* term_type = "xterm";
auto force_update = getenv("SCRIPTY_FORCE_UPDATE") != nullptr;

scripty_data.sd_program_name = argv[0];
scripty_data.sd_looping = true;

while ((c = getopt(argc, argv, "ha:e:nipSX")) != -1) {
while ((c = getopt(argc, argv, "ha:e:nipSXr")) != -1) {
switch (c) {
case 'h':
usage();
Expand Down Expand Up @@ -1267,6 +1268,9 @@ main(int argc, char* argv[])
case 'n':
passout = false;
break;
case 'r':
compare_output = false;
break;
case 'p':
prompt = true;
break;
Expand Down Expand Up @@ -1521,7 +1525,9 @@ main(int argc, char* argv[])
}

fprintf(stderr, "%s:done!\n", tstamp());
if (retval == EXIT_SUCCESS && !scripty_data.sd_expected_name.empty()) {
if (retval == EXIT_SUCCESS && compare_output
&& !scripty_data.sd_expected_name.empty())
{
auto cmd = fmt::format("diff -ua {} {}",
scripty_data.sd_expected_name.string(),
scripty_data.sd_actual_name.string());
Expand Down
26 changes: 26 additions & 0 deletions test/test_tui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,29 @@ run_test ./scripty -nX -e ${srcdir}/xpath_tui.0 -- \
${srcdir}/logfile_xml_msg.0

on_error_log "xpath() fields are not working?"

# These checks exercise startup and session restoration without comparing transient
# screen redraws. scripty still checks that the child exits successfully.
run_test ./scripty -nrX -e ${srcdir}/goto_tui.0 -- \
${lnav_test} -d ./tui-home/goto-default.err ${srcdir}/logfile_partitions.0
on_error_fail_with "Could not open the log at its default position"
run_test grep -E 'log view actual top/selection: [0-9]+/81$' ./tui-home/goto-default.err
on_error_fail_with "Default log selection should be the last line"

run_test ./scripty -nrX -e ${srcdir}/goto_tui.0 -- \
${lnav_test} -d ./tui-home/goto-explicit.err -c ':goto 2' ${srcdir}/logfile_partitions.0
on_error_fail_with "Could not run the initial goto command"
run_test grep -E 'log view actual top/selection: [0-9]+/2$' ./tui-home/goto-explicit.err
on_error_fail_with "Initial goto selection was lost when restoring the session"

run_test ./scripty -nrX -e ${srcdir}/goto_tui.0 -- \
${lnav_test} -d ./tui-home/goto-restored.err ${srcdir}/logfile_partitions.0
on_error_fail_with "Could not reopen the log"
run_test grep -E 'log view actual top/selection: [0-9]+/2$' ./tui-home/goto-restored.err
on_error_fail_with "Saved log selection was not restored"

run_test ./scripty -nrX -e ${srcdir}/goto_tui.0 -- \
${lnav_test} -d ./tui-home/goto-override.err -c ':goto 5' ${srcdir}/logfile_partitions.0
on_error_fail_with "Could not override the saved log selection"
run_test grep -E 'log view actual top/selection: [0-9]+/5$' ./tui-home/goto-override.err
on_error_fail_with "Initial goto should override the saved selection"