summaryrefslogtreecommitdiff
blob: 14e8f2f6482a394582ad0f24f8cecec264062fb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
From a1c0782e828bc5f0fc8b79d0131f1847c5e7b359 Mon Sep 17 00:00:00 2001
From: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
Date: Sun, 13 Aug 2023 14:52:20 -0500
Subject: [PATCH 3/3] test_ansi: add -A to the tests

---
See also: https://github.com/zlin/wgetpaste/pull/46
- Oskari

 test/test_ansi.sh | 92 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 81 insertions(+), 11 deletions(-)

diff --git a/test/test_ansi.sh b/test/test_ansi.sh
index 23b27a8..e1e95f0 100755
--- a/test/test_ansi.sh
+++ b/test/test_ansi.sh
@@ -94,8 +94,8 @@ fi
 
 # Paste stuff. Use a short timeout between requests (we're friendly after all!)
 sleep 1
-echo -n "Pasting command output (cat): "
-ERROR_LOG="$DL_DIR/command-error.log"
+echo -n "Pasting command output with ANSI stripping (cat): "
+ERROR_LOG="$DL_DIR/command-noansi-error.log"
 URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
 if [ $? -ne 0 ]; then
     echo "FAILED!"
@@ -104,7 +104,7 @@ else
     echo "SUCCESS!"
 
     echo -n "Downloading: "
-    if ! (wget -q "$URL" -O "$DL_DIR/command.txt" 2>>"$ERROR_LOG"); then
+    if ! (wget -q "$URL" -O "$DL_DIR/command-noansi.txt" 2>>"$ERROR_LOG"); then
         echo "FAILED!"
         FAILED_PASTE=$((FAILED_PASTE + 1))
     else
@@ -112,13 +112,35 @@ else
         rm "$ERROR_LOG"
 
         echo "Removing 'command run' header"
-        sed -i -e '1d' "$DL_DIR/command.txt"
+        sed -i -e '1d' "$DL_DIR/command-noansi.txt"
+    fi
+fi
+sleep 1
+echo -n "Pasting command output without ANSI stripping (cat): "
+ERROR_LOG="$DL_DIR/command-ansi-error.log"
+URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v -c "cat $ANSI_FILE" 2>"$ERROR_LOG")"
+if [ $? -ne 0 ]; then
+    echo "FAILED!"
+    FAILED_PASTE=$((FAILED_PASTE + 1))
+else
+    echo "SUCCESS!"
+
+    echo -n "Downloading: "
+    if ! (wget -q "$URL" -O "$DL_DIR/command-ansi.txt" 2>>"$ERROR_LOG"); then
+        echo "FAILED!"
+        FAILED_PASTE=$((FAILED_PASTE + 1))
+    else
+        echo "SUCCESS"
+        rm "$ERROR_LOG"
+
+        echo "Removing 'command run' header"
+        sed -i -e '1d' "$DL_DIR/command-ansi.txt"
     fi
 fi
 
 sleep 1
-echo -n "Pasting stdin (cat | wgetpaste): "
-ERROR_LOG="$DL_DIR/stdin-error.log"
+echo -n "Pasting stdin with ANSI stripping (cat | wgetpaste): "
+ERROR_LOG="$DL_DIR/stdin-noansi-error.log"
 URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v 2>"$ERROR_LOG")"
 if [ $? -ne 0 ]; then
     echo "FAILED!"
@@ -127,7 +149,26 @@ else
     echo "SUCCESS!"
 
     echo -n "Downloading: "
-    if ! (wget -q "$URL" -O "$DL_DIR/stdin.txt" 2>>"$ERROR_LOG"); then
+    if ! (wget -q "$URL" -O "$DL_DIR/stdin-noansi.txt" 2>>"$ERROR_LOG"); then
+        echo "FAILED!"
+        FAILED_PASTE=$((FAILED_PASTE + 1))
+    else
+        echo "SUCCESS!"
+        rm "$ERROR_LOG"
+    fi
+fi
+sleep 1
+echo -n "Pasting stdin without ANSI stripping (cat | wgetpaste): "
+ERROR_LOG="$DL_DIR/stdin-ansi-error.log"
+URL="$(cat "$ANSI_FILE" | "$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v 2>"$ERROR_LOG")"
+if [ $? -ne 0 ]; then
+    echo "FAILED!"
+    FAILED_PASTE=$((FAILED_PASTE + 1))
+else
+    echo "SUCCESS!"
+
+    echo -n "Downloading: "
+    if ! (wget -q "$URL" -O "$DL_DIR/stdin-ansi.txt" 2>>"$ERROR_LOG"); then
         echo "FAILED!"
         FAILED_PASTE=$((FAILED_PASTE + 1))
     else
@@ -137,8 +178,8 @@ else
 fi
 
 sleep 1
-echo -n "Pasting a file: "
-ERROR_LOG="$DL_DIR/file-error.log"
+echo -n "Pasting a file with ANSI stripping: "
+ERROR_LOG="$DL_DIR/file-noansi-error.log"
 URL="$("$TEST_DIR"/../wgetpaste -N -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
 if [ $? -ne 0 ]; then
     echo "FAILED!"
@@ -147,7 +188,26 @@ else
     echo "SUCCESS!"
 
     echo -n "Downloading: "
-    if ! (wget -q "$URL" -O "$DL_DIR/file.txt" 2>>"$ERROR_LOG"); then
+    if ! (wget -q "$URL" -O "$DL_DIR/file-noansi.txt" 2>>"$ERROR_LOG"); then
+        echo "FAILED!"
+        FAILED_PASTE=$((FAILED_PASTE + 1))
+    else
+        echo "SUCCESS!"
+        rm "$ERROR_LOG"
+    fi
+fi
+sleep 1
+echo -n "Pasting a file without ANSI stripping: "
+ERROR_LOG="$DL_DIR/file-ansi-error.log"
+URL="$("$TEST_DIR"/../wgetpaste -A -r -s "$WORKING" -v "$ANSI_FILE" 2>"$ERROR_LOG")"
+if [ $? -ne 0 ]; then
+    echo "FAILED!"
+    FAILED_PASTE=$((FAILED_PASTE + 1))
+else
+    echo "SUCCESS!"
+
+    echo -n "Downloading: "
+    if ! (wget -q "$URL" -O "$DL_DIR/file-ansi.txt" 2>>"$ERROR_LOG"); then
         echo "FAILED!"
         FAILED_PASTE=$((FAILED_PASTE + 1))
     else
@@ -157,7 +217,7 @@ else
 fi
 
 # Compare downloaded files
-for dl_file in "$DL_DIR"/*.txt; do
+for dl_file in "$DL_DIR"/*-noansi.txt; do
     echo -n "Testing file $dl_file: "
     # Ignore missing trailing newline and extra empty lines in downloaded file
     if (diff -q -Z -B "$NOANSI_FILE" "$dl_file" &>/dev/null); then
@@ -167,6 +227,16 @@ for dl_file in "$DL_DIR"/*.txt; do
         DL_MISMATCH=$((DL_MISMATCH + 1))
     fi
 done
+for dl_file in "$DL_DIR"/*-ansi.txt; do
+    echo -n "Testing file $dl_file: "
+    # Ignore missing trailing newline and extra empty lines in downloaded file
+    if (diff -q -Z -B "$ANSI_FILE" "$dl_file" &>/dev/null); then
+        echo "SUCCESS!"
+    else
+        echo "FAILED!"
+        DL_MISMATCH=$((DL_MISMATCH + 1))
+    fi
+done
 
 echo "Total failed pastes: $FAILED_PASTE"
 echo "Total mismatches: $DL_MISMATCH"
-- 
2.41.0