--- /dev/null
+#!/usr/bin/env perl
+use 5.012;
+use warnings;
+
+# run script on the first line and compare its output to remaining lines
+
+my $regenerate = @ARGV > 1 && $ARGV[0] eq '-G' && shift;
+
+@ARGV or die "missing input script\n";
+!!(my $spec = readline)
+ or die "input lacks a script on the first line\n";
+
+my $script = $spec;
+chomp $script;
+my $wantexit = $script =~ s/\h+[?](\d+)\z// ? $1 : 0;
+my $wantwarn = $script !~ s/[?]\z//;
+my $shell = $script;
+if ($script =~ /\|/) {
+ # explicit shell wrapper to capture all warnings
+ $script =~ s/'/'\\''/g;
+ $shell = "sh -c '$shell'";
+}
+$shell .= ' 2>&1' if $wantwarn;
+
+local $ENV{COLUMNS} = 40;
+open my $cmd, '-|', $shell or do {
+ say "cannot run script `$script`: $!";
+ exit 2;
+};
+my @lines = readline $cmd;
+close $cmd;
+my $error = $? >> 8;
+
+if ($regenerate) {
+ open my $rewrite, '>', $ARGV;
+ print {$rewrite} $_ for $spec, @lines;
+ exit;
+}
+
+if ($error != $wantexit) {
+ say "unexpected exit status $error for `$script`";
+ exit 2;
+}
+
+my @wanted = readline;
+my $diff = 0;
+
+while (@lines or @wanted) {
+ my $was = shift @wanted;
+ my $is = shift @lines;
+ next if defined $was and defined $is and $was eq $is;
+ $diff++;
+ print color(32), "< ", color(0), $_ for $was // ();
+ print color(31), "> ", color(0), $_ for $is // ();
+}
+
+exit($diff > 0);
+
+sub color {
+ return "\e[@{_}m";
+}
test_count=0
fail_count=0
-COLUMNS=40
colorize=
test -t 1 && colorize=1
color () {
test -n "$colorize" &&
printf '\33[%sm' $@
}
-regenerate=
-diffcmd () {
- comm --nocheck-order --output-delimiter=::: -3 $@ |
- perl -pe"END{exit !!\$.} s/^:::/$(color 31)>/ || s/^/$(color 32)</"
-}
for option in "$@"
do
case "$option" in
- -G) regenerate=1 && shift;;
- -*) echo "Usage: $0 [-G] [<files>...]"; exit 64;;
+ -*) echo "Usage: $0 [<files>...]"; exit 64;;
esac
done
do
test_count=$((test_count+1))
file="${candidate%.out}"
- input="${file%%_-*}.in"
name="$(echo ${file#*-} | tr _ \ )"
- set -- barcat
- [ -r "$input" ] && set -- "$@" "$input"
- case "$name" in
- *\ -*)
- args="${name#* -}"
- set -- "$@" -"${args% [?|]*}"
- ;;
- esac
- case "$name" in
- *' ?' ) set -- sh -c "\$0 \$@ 2>/dev/null" "$@";;
- *' ?'*) set -- sh -c "\$0 \$@ | test \$\? = ${name#* \?}" "$@";;
- *' |'*) set -- sh -c "\$0 \$@ | ${name#* |}" "$@";;
- *) eval set -- "$1" $2 $3
- esac
-
- if test -n "$regenerate"
- then
- if test -e $file.sh
- then
- echo "ok $test_count # skip $file.out"
- continue
- fi
- "$@" >$file.out 2>&1
- elif test -e "$file.out"
+ if test -e "$file.out"
then
- "$@" 2>&1 | diffcmd "$file.out" -
+ ./cmddiff "$file.out"
else
color 33
echo "not ok $test_count - $name # TODO"
+barcat -a --version
barcat =^,^= version 1.09
+barcat -Az ?64
Unknown option: A
Unknown option: z
+barcat t1001-seq.in
1 -------------
2 ------------------------+
3 ------------------------+----->-------
+barcat t1002-sinewave.in
998 ---
1987 -------
2955 ----------
+barcat t1003-sinine.in
0.930507621912314 ---<----|----->----
0.968912421710645 ---<----|----->-----
0.992197667229329 ---<----|----->-----
+barcat t1005-float.in
-3
-2.449 --
-2 ----
+barcat t1006-unvalued.in
nan
-1 negative -------
-2 negativer
+barcat t1008-unicode.in
9324 A -<----+-=--->--------------------
920 B -<-
476 C -<
+barcat --markers= t1012-unmarked.in
998 ---
1987 -------
2955 ----------
+barcat --markers='atest 09998 b200v c15000 0test' t1019-invalid_marker.in
Unknown marker a: test
Invalid marker b: percentile 200 out of bounds
Unknown marker 0: test
+barcat t1100-aligned.in
1 -
2 prepend -<
3: append -<
+barcat -l30 t1101-wow_much_length.in
1 -
2 prepend -<
3: append -<
+barcat -l0 t1102-strip_contents.in
1 ----
2 -------
3:---------<-
+barcat -l1 t1103-only_separators.in
1 ----
2 -------
3: ---------<-
+barcat -l5 t1104-abbreviate_contents.in
1 ---
2 pr… ------
3: … --------<-
+barcat -l50% t1105-length_percentage.in
1 --
2 prepend ---
3: append ----<
+barcat -l-30 t1106-forced_length.in
1 <
2 prepend <
3: append <+
+barcat -u t1200-unaligned.in
1 -
2 prepend --
3: append --<
+barcat -uw1 t1201-unchanged.in
1
2 prepend
3: append
+barcat -ul8 t1202-abbreviate_total.in
1 ---
2 pre… -------
3: … --------<-
+barcat -e t1260-powers_of_ten.in
1
10 ------
100 ----------<
+barcat -e t1261-binary_powers.in
1 2^0
2 2^1
4 2^2
+barcat -e t1262-powers_of_tenths.in
1e-5
1e-4
1e-3
+barcat -f2 t1300-field_number.in
1 2 3 4 ---
10 20 30 40 -------<+--=------>---------
3 16 9 123 -------<
+barcat -ftime= t1301-field_grep.in
PING google.com(ams15s40-in-x0e.1e100.net (2a00:1450:400e:80d::200e)) 56 data bytes
... icmp_seq=1 9.92 ms -----------+-
... icmp_seq=2 9.38 ms -----------+
+barcat -f\( ?64
Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE / for option field
+barcat -f+1 t1305-numeric_field.in
1
numeric 1 2 3 ------=-+
-1 - 2-3 ------=-+
+barcat -f',\K' t1310-currency.in
Data Source in SDW: null
,EXR.D.USD.EUR.SP00.A
,"ECB reference exchange rate, US dollar/Euro, 2:15 pm (C.E.T.)"
+barcat -L6- -f',([0-9.]{5})' --value-length=6 --minval=1 t1311-currency_zoom.in
2019-09-23 1.098 ---<
2019-09-20 1.103 ---<
2019-09-19 1.106 ---<
+barcat -f, --value-length=7 --minval=1.1 --maxval=1.11 -L10-30 -s t1312-currency-crop.in
2019-09-17 1.1026 ------
2019-09-16 1.1031 -------
2019-09-13 1.1096 ---------------------
+barcat -f'([.0-9]+)(?=,m)' t1320-earthquakes.in
time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type,horizontalError,depthError,magError,magNst,status,locationSource,magSource
2019-09-23T13:32:01.060Z,36.0413322,-120.2453308,13.57,2.48,md,26,131,0.1773,0.12,nc,nc73278290,2019-09-23T14:03:45.416Z,"11km WNW of Avenal, CA",earthquake,0.53,1.66,0.23,16,automatic,nc,nc
2019-09-23T13:16:57.170Z,36.0901667,-117.8598333,5.57,1.33,ml,18,89,0.02765,0.13,ci,ci38853575,2019-09-23T13:20:31.134Z,"9km ENE of Coso Junction, CA",earthquake,0.3,0.49,0.274,14,automatic,ci,ci
+barcat -f'(?<=\()' t1330-pokemon.in
001 Bulbasaur ( 6.9 kg 0.71 m 0.69)
002 Ivysaur ( 13.0 kg 0.99 m 0.042)
003 Venusaur (100.0 kg 2.01 m 0.017)
+barcat -H t1401-magnitude.in
10p
200p
3.0n
+barcat -H -w1 t1402-rounded.in
999k -
1.0M +
1.0M ++
+barcat -H t1403-precision.in
1
1.0
2.0k
+barcat -H t1404-minitude.in
-10p ------------------------------=+|
-200p ------------------------------=+|
-3.0n ------------------------------=+|
+barcat -Hes t1405-megametric.in
30e-34
300e-33
3.0e-32
+barcat --sexagesimal t1421-sexy_time.in
0:00:00
0:00:01
0:00:01
+barcat --sexagesimal -H -sC t1422-all_the_time.in
\e[90m0:00:00\e[0m -
\e[90m24:00:00\e[0m ---\e[36m=\e[0m---
\e[32m111:11:11\e[0m long ---\e[36m=\e[0m--------------------------
+barcat -L3 t1501-end_limit.in
998 ------------
1987 ------------------------
2955 -----------------------------------
+barcat -L9- t1502-start_limit.in
7833 -----------------<----=-+--
8415 -----------------<----=-+----
8912 -----------------<----=-+----->
+barcat -L1-2 t1503-partial.in
1 -------------
2 prepend --------------------------
+barcat -L-3 t1504-bottom_limit.in
3350 ------------
2392 --------
1411 -----
+barcat -L-4-3 t1505-bottom_range.in
4274 -----------------------------------
3350 ---------------------------
+++ /dev/null
-t1505-bottom_range_-L-4-3_#TODO.out
\ No newline at end of file
--- /dev/null
+barcat -L-4+2 t1506-limit_offset.in
+4274 -----------------------------------
+3350 ---------------------------
+barcat -L-5 t1514-limit_beyond_end.in
+barcat -sL0 t1601-integer_statistics.in
6 total in 3 values (1 min, 2.00 avg, 3 max)
+barcat -sL0 t1602-float_statistics.in
-7.459 total in 16 values over 18 lines (-3 min, -0.47 avg, 2 max)
+barcat -sL2- t1603-added_statistics.in
920 B -<-
476 C -<
619 Ĉ -<
+barcat t1700-empty_input.in
+barcat -1 ?64
Unknown option: 1
+barcat -- 1
1 -------------------------------------+
+barcat -- 1 4 8 2 6 3 9 5 2
1 ----
4 -----------<---+-
8 -----------<---+-=---->-----------
+barcat -- -1 1
-1
1 -----------------|------------------>
+barcat -C -M 1
1 -------------------------------------+
+barcat -M 1 -l 2 hi 3 --st 4 -- 5 -1 --version
1 -----|------
…
3 -----|-----------<-=---+-
+barcat --palette=none ?64
Empty palette resulting from "none"
+barcat -t-1 -ftime='\K' t1801-progress.in ?
PING google.com(ams15s40-in-x0e.1e100.net (2a00:1450:400e:80d::200e)) 56 data bytes
... icmp_seq=1 time=9.92 ms ---------+
... icmp_seq=2 time=9.38 ms --------+
+barcat -Cs --header t1901-technicolor.in
\e[31m -3\e[90m-\e[36m+\e[32m 2\e[90m-\e[36m+\e[0m
\e[31m -3\e[0m
\e[90m -2.449\e[0m --
+barcat -f, --value-length=7 --minval=1.1 --maxval=1.11 -L10-30 -Cs t1912-currency_part.in
2019-09-17\e[90m 1.1026\e[0m ------
2019-09-16\e[90m 1.1031\e[0m -------
2019-09-13\e[90m 1.1096\e[0m ---------------------
+barcat -C --palette= t1920-colorwave_uncolored.in
1 ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
0.987688340623216 ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
0.951056516406084 ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=1 t1921-colorwave_unicolor.in
\e[1m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[1m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[1m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=40,0 t1922-colorwave_duocolor.in
\e[0m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[0m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[0m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=41,0,42 t1923-colorwave_tricolor.in
\e[42m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[0m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[0m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=31,41,43,42,32 t1924-colorwave_custom_palette.in
\e[32m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[42m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[42m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=fire t1931-colorwave_fire.in
\e[96m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[97m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[97m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --palette=fire256 t1932-colorwave_fireworks.in
\e[38;5;159m 1\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[38;5;231m 0.987688340623216\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
\e[38;5;231m 0.951056516406084\e[0m ---\e[36m<\e[0m---\e[36m+\e[0m\e[36m|\e[0m----\e[36m>\e[0m----
+barcat -C --spark --palette=rainbow t1933-lolcat.in
\e[38;5;196m█\e[38;5;197m█\e[38;5;197m█\e[38;5;198m█\e[38;5;199m█\e[38;5;201m▇\e[38;5;129m▇\e[38;5;57m▆\e[38;5;27m▆\e[38;5;39m▅\e[38;5;51m▅\e[38;5;48m▄\e[38;5;46m▃\e[38;5;118m▃\e[38;5;190m▂\e[38;5;220m▂\e[38;5;208m▁\e[38;5;202m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;202m▁\e[38;5;208m▁\e[38;5;220m▂\e[38;5;190m▂\e[38;5;118m▃\e[38;5;46m▃\e[38;5;48m▄\e[38;5;50m▄\e[38;5;39m▅\e[38;5;27m▆\e[38;5;57m▆\e[38;5;129m▇\e[38;5;201m▇\e[38;5;199m█\e[38;5;198m█\e[38;5;197m█\e[38;5;197m█\e[38;5;196m█\e[38;5;197m█\e[38;5;197m█\e[38;5;198m█\e[38;5;199m█\e[38;5;201m▇\e[38;5;129m▇\e[38;5;57m▆\e[38;5;27m▆\e[38;5;39m▅\e[38;5;51m▅\e[38;5;48m▄\e[38;5;46m▃\e[38;5;118m▃\e[38;5;190m▂\e[38;5;220m▂\e[38;5;208m▁\e[38;5;202m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;196m▁\e[38;5;202m▁\e[38;5;208m▁\e[38;5;220m▂\e[38;5;190m▂\e[38;5;118m▃\e[38;5;46m▃\e[38;5;48m▄\e[38;5;50m▄\e[38;5;39m▅\e[38;5;27m▆\e[38;5;57m▆\e[38;5;129m▇\e[38;5;201m▇\e[38;5;199m█\e[38;5;198m█\e[38;5;197m█\e[38;5;197m█\e[0m
+barcat --spark t2100-sparkwave.in
█████████▇▇▇▆▆▅▅▄▄▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▂▂▂▃▃▄▄▅▅▆▆▇▇▇████████████▇▇▆▆▅▅▄▄▃▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▂▂▃▃▄▄▅▅▆▆▆▇▇██
+barcat --spark -w9 t2103-spark-lines.in
█████████
▇▇▇▆▆▅▅▄▄
▃▃▂▂▂▁▁▁▁
+barcat -a --spark t2105-spark_ascii.in
OOOOOOOOOOOOOoooooo...................ooooooOOOOOOOOOOOOOOOOOOOOooooo....................oooooOOOOOO
+barcat --spark --indicators=-123456789 t2109-spark_distribution.in
123456789
+barcat --spark --indicators=XO t2110-spark_binary.in
XOOOOXOOXOOOOXX
+barcat --spark --indicators=-·•O t2111-spark_unicode.in
-··•·-·•-O•··--
+barcat --spark --indicators=1 t2115-spark-oneliner.in
111111111111111
+barcat --indicators= t2120-prefixed.in
nan
▍ -1 negative -------
▏ -2 negativer
+barcat --indicators=# t2122-outcommented.in
#nan
# -1 negative -------
# -2 negativer
+barcat --spark --maxval=1 t2130-overspark.in
▁██▆ ▆█ ████
+barcat --spark --indicators=012345 -Cs --maxval=1 -L17 t2180-spark_combined.in
\e[31m1\e[90m1\e[90m2\e[90m3\e[90m4\e[90m4\e[90m4\e[90m4\e[90m4\e[90m4\e[90m3\e[90m4\e[32m5\e[32m50\e[32m5\e[90m2\e[0m
-7.459 of \e[1m-7.459\e[0m total in 16 values over 18 lines (\e[31m-3\e[0m min, \e[36m-0.47\e[0m avg, \e[32m2\e[0m max)
+barcat -aHl7 t2201-ascii.in
123u micro -------------<--=+---------|
100m long> -------------<--=+---------|-
-1 -------------<--=+-
+barcat --graph-format=* t2220-starry_line.in
123e-6 micro **********<*=+*******|
.1 long line **********<*=+*******|*
-1 **********<*=+*
+barcat --graph-format=─ t2221-unicode_line.in
123e-6 micro ──────────<─=+───────|
.1 long line ──────────<─=+───────|─
-1 ──────────<─=+─
+barcat --markers= t2250-unremarkable.in
123e-6 micro ----------------------
.1 long line -----------------------
-1 ---------------
+barcat --markers=:-2 t2255-value_marker.in
123e-6 micro ------:---------------
.1 long line ------:----------------
-1 ------:--------
+barcat --mark='?0 !0' t2256-remarkable.in
123e-6 micro ---------------------!
.1 long line ---------------------!-
-1 ---------------
+barcat --mark=:/1 t2258-repeat_markers.in
1 ---:
2 ---:---:
3 ---:---:---:-
+barcat -e --markers=+/1 t2259-log_axis.in
1
10 ----+-
100 ----+-----+
+barcat --markers=')0v (100v' t2264-minmax_percent.in
123e-6 micro (---------------------
.1 long line (---------------------)
-1 (--------------
+barcat --graph-format=─ --markers='550v 00v 11v 999v ^100v' t2265-percentile_markers.in
123e-6 micro ──9──────────5────────
.1 long line ──9──────────5────────1
-1 ──9──────────5─
+barcat --graph-format=─ --markers='┼avg ╫50v ┬-2' t2295-unicode_in_my_bar.in
123e-6 micro ──────┬─────┼╫────────
.1 long line ──────┬─────┼╫─────────
-1 ──────┬─────┼╫─