aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-11-16 05:20:18 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2022-11-16 05:20:18 +0000
commit7ad9aa0b9366092a0feb671a2b252faefe3ff7fd (patch)
tree5e66d2c9d9d5592a925edd11d30efa325d740060
parentafb4998dd4de03c2d635faf7db89f3d3f6c3a6ff (diff)
rs: Test actual output in the tests.
Previously the tests just verified if command line arguments raised an error or not, they did not test how command line arguments affected the output. This adds some sample (if simple) input and output to each flag test as well as adding a few additional trivial tests. Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D36835
-rw-r--r--usr.bin/rs/tests/rs_test.sh150
1 files changed, 134 insertions, 16 deletions
diff --git a/usr.bin/rs/tests/rs_test.sh b/usr.bin/rs/tests/rs_test.sh
index 1047a6557ae4..bb7df6fa267d 100644
--- a/usr.bin/rs/tests/rs_test.sh
+++ b/usr.bin/rs/tests/rs_test.sh
@@ -34,7 +34,11 @@ c_flag_head()
c_flag_body()
{
- atf_check -s exit:0 -o empty rs -c < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 8
+" rs -c, 2 <<EOF
+1,2,3,4,5,6,7,8
+EOF
}
atf_test_case s_flag
@@ -45,7 +49,12 @@ s_flag_head()
s_flag_body()
{
- atf_check -s exit:0 -o empty rs -s < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 8
+" rs -s% 2 <<EOF
+1%%2%%3%4%5%%%6%%%7%8
+EOF
+
}
atf_test_case C_flag
@@ -56,7 +65,11 @@ C_flag_head()
C_flag_body()
{
- atf_check -s exit:0 -o empty rs -C < /dev/null
+ atf_check -s exit:0 -o inline:"1,2,3,4,
+5,6,7,8,
+" rs -C, 2 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_test_case S_flag
@@ -67,7 +80,11 @@ S_flag_head()
S_flag_body()
{
- atf_check -s exit:0 -o empty rs -S < /dev/null
+ atf_check -s exit:0 -o inline:"1,,2,,3,,4
+5,,6,,7,,8
+" rs -S, 2 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_test_case t_flag
@@ -78,7 +95,12 @@ t_flag_head()
t_flag_body()
{
- atf_check -s exit:0 -o empty rs -t < /dev/null
+ atf_check -s exit:0 -o inline:"1 4 7
+2 5 8
+3 6
+" rs -t 3 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_test_case T_flag
@@ -89,7 +111,12 @@ T_flag_head()
T_flag_body()
{
- atf_check -s exit:0 -o empty rs -T < /dev/null
+ atf_check -s exit:0 -o inline:"1
+2
+3
+" rs -T <<EOF
+1 2 3
+EOF
}
atf_test_case k_flag
@@ -100,7 +127,13 @@ k_flag_head()
k_flag_body()
{
- atf_check -s exit:0 -o empty rs -k 1 < /dev/null
+ atf_check -s exit:0 -o inline:"3 4 5
+6 7 8
+" rs -k 1 2 <<EOF
+1 2
+3 4 5 6
+7 8
+EOF
}
atf_test_case K_flag
@@ -123,7 +156,11 @@ g_flag_head()
g_flag_body()
{
- atf_check -s exit:0 -o empty rs -g 1 < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 8
+" rs -g 1 2 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_test_case G_flag
@@ -134,7 +171,11 @@ G_flag_head()
G_flag_body()
{
- atf_check -s exit:0 -o empty rs -G 10 < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 acbdefghij
+" rs -G 50 2 <<EOF
+1 2 3 4 5 6 7 acbdefghij
+EOF
}
atf_test_case e_flag
@@ -157,7 +198,14 @@ n_flag_head()
n_flag_body()
{
- atf_check -s exit:0 -o empty rs -n < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3
+4 5
+6 7
+" rs -n 0 3 <<EOF
+1 2 3
+4 5
+6 7
+EOF
}
atf_test_case y_flag
@@ -168,7 +216,12 @@ y_flag_head()
y_flag_body()
{
- atf_check -s exit:0 -o empty rs -y < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3
+4 5 6
+7 8 1
+" rs -y 3 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_test_case h_flag
@@ -204,7 +257,11 @@ j_flag_head()
j_flag_body()
{
- atf_check -s exit:0 -o empty rs -j < /dev/null
+ atf_check -s exit:0 -o inline:" 1 2 3
+abc def ghi
+" rs -j 2 <<EOF
+1 2 3 abc def ghi
+EOF
}
atf_test_case m_flag
@@ -215,7 +272,11 @@ m_flag_head()
m_flag_body()
{
- atf_check -s exit:0 -o empty rs -m < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3
+abc def ghi
+" rs -m 2 <<EOF
+1 2 3 abc def ghi
+EOF
}
atf_test_case z_flag
@@ -226,7 +287,11 @@ z_flag_head()
z_flag_body()
{
- atf_check -s exit:0 -o empty rs -z < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 acbdefghij
+" rs -z 2 <<EOF
+1 2 3 4 5 6 7 acbdefghij
+EOF
}
atf_test_case invalid_usage
@@ -250,8 +315,58 @@ no_arguments_head()
no_arguments_body()
{
- atf_check -s exit:0 -o inline:"
-" rs < /dev/null
+ atf_check -s exit:0 -o inline:"1 2 3 4 5 6 7 8
+" rs <<EOF
+1 2 3 4 5 6 7 8
+EOF
+}
+
+atf_test_case rows_2
+rows_2_head()
+{
+ atf_set "descr" "Simple output with 2 rows"
+}
+
+rows_2_body()
+{
+ atf_check -s exit:0 -o inline:"1 2 3 4
+5 6 7 8
+" rs 2 <<EOF
+1 2 3 4 5 6 7 8
+EOF
+}
+
+atf_test_case rows_3
+rows_3_head()
+{
+ atf_set "descr" "Simple output with 3 rows"
+}
+
+rows_3_body()
+{
+ atf_check -s exit:0 -o inline:"1 2 3
+4 5 6
+7 8
+" rs 3 <<EOF
+1 2 3 4 5 6 7 8
+EOF
+}
+
+atf_test_case rows_4
+rows_4_head()
+{
+ atf_set "descr" "Simple output with 4 rows"
+}
+
+rows_4_body()
+{
+ atf_check -s exit:0 -o inline:"1 2
+3 4
+5 6
+7 8
+" rs 4 <<EOF
+1 2 3 4 5 6 7 8
+EOF
}
atf_init_test_cases()
@@ -276,4 +391,7 @@ atf_init_test_cases()
atf_add_test_case z_flag
atf_add_test_case invalid_usage
atf_add_test_case no_arguments
+ atf_add_test_case rows_2
+ atf_add_test_case rows_3
+ atf_add_test_case rows_4
}