From e2e4e3ced75bb5e9db28cc35b6ebf371e8e5be94 Mon Sep 17 00:00:00 2001 From: Simon Johnsson Date: Wed, 18 Feb 2026 15:37:48 +0100 Subject: Scale history-list to screen width --- test/integration/test-history | 73 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 15 deletions(-) (limited to 'test/integration/test-history') diff --git a/test/integration/test-history b/test/integration/test-history index 34108e357..48966d011 100755 --- a/test/integration/test-history +++ b/test/integration/test-history @@ -54,20 +54,7 @@ Command line: apt-get install pkg1 Packages changed: Install pkg1:amd64 (1) " normalizedinfo - -# replace aribtrary command line and date with "dummy". -normalizedlist() { - apt history-list | sed -E 's/^([0-9]+)[[:space:]]+'\ -'.*'\ -'[0-9]{4}-[0-9]{2}-[0-9]{2}[[:space:]]+'\ -'[0-9]{2}:[0-9]{2}:[0-9]{2}/'\ -'\1 dummy dummy /' -} - -testsuccessequal "ID Command line Date and Time Action Changes -0 dummy dummy Install 1 -1 dummy dummy Install 1 " normalizedlist ################################################################################ # Read previous history for manipulation @@ -118,9 +105,9 @@ Commandline: install nothing End-Date: dummy EOF -testsuccessequal "ID Command line Date and Time Action Changes +testsuccessequal "ID Command line Date and Time Action Changes -0 install nothing dummy 0 " normalizedlist +0 install nothing dummy 0 " apt history-list testsuccessequal "Transaction ID: 0 Start time: dummy @@ -129,6 +116,62 @@ Requested by: Command line: install nothing Packages changed:" normalizedinfo +cat > rootdir/var/log/apt/history.log << EOF +Start-Date: 1970-01-01 00:00:00 +Commandline: install nothing +Install: nothing +End-Date: 1970-01-01 00:00:00 + +Start-Date: 1971-01-01 00:00:00 +Commandline: remove something +Remove: something +End-Date: 1971-01-01 00:00:00 +EOF + +testsuccessequal "ID Command line Date and Time Action Changes + +0 install nothing 1970-01-01 00:00:00 Install 1 +1 remove something 1971-01-01 00:00:00 Remove 1 " apt history-list + +################################################################################ +# Test different column widths +################################################################################ +settestcolumnwidth() { + local columns=$1 + local A_chars + A_chars=$(printf 'a%.0s' $(seq 1 "$columns")) + + cat > rootdir/var/log/apt/history.log << EOF +Start-Date: dummy +Commandline: $A_chars +Install: nothing +End-Date: dummy +EOF + + export COLUMNS="$columns" +} + +settestcolumnwidth 80 +testsuccessequal "ID Command line Date and Time Action Changes + +0 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...dummy Install 1 " apt history-list + +settestcolumnwidth 50 +testsuccessequal "ID Command line Date and Time Action Changes + +0 aaaaaaaaaaaaa...dummy Install 1 " apt history-list + +settestcolumnwidth 100 +testsuccessequal "ID Command line Date and Time Action Changes + +0 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...dummy Install 1 " apt history-list + +settestcolumnwidth 60 +testsuccessequal "ID Command line Date and Time Action Changes + +0 aaaaaaaaaaaaaaaaaaaaaaa...dummy Install 1 " apt history-list + + testfailureequal "E: Incorrect usage, no ID was given." apt history-redo testfailureequal "E: Incorrect usage, no ID was given." apt history-undo testfailureequal "E: Incorrect usage, no ID was given." apt history-rollback -- cgit v1.2.3-70-g09d2