← Commit list

540ee5b560

Samuel Henrique
Samuel Henrique
2026-09-17
SUCCESS Duration: 422s

Subject

tests: add test cases for --styled-output

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_cb_wrt.c+0 -8
@@ -303,14 +303,6 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
return bytes;
#ifdef DEBUGBUILD
- {
- char *tty = curl_getenv("CURL_ISATTY");
- if(tty) {
- is_tty = TRUE;
- curl_free(tty);
- }
- }
-
if(config->show_headers) {
if(bytes > (size_t)CURL_MAX_HTTP_HEADER) {
warnf("Header data size exceeds write limit");
src/tool_operate.c+13 -1
@@ -1339,6 +1339,18 @@ static CURLcode setup_transfer_upload(struct OperationConfig *config,
return result;
}
+/* returns TRUE if the given stream is a terminal */
+static bool stream_isatty(FILE *stream)
+{
+#ifdef DEBUGBUILD
+ /* the test suite sets CURL_ISATTY to make curl act as if the output goes
+ to a terminal */
+ if(getenv("CURL_ISATTY"))
+ return TRUE;
+#endif
+ return !!isatty(fileno(stream));
+}
+
/* create a transfer */
static CURLcode create_single(struct OperationConfig *config,
CURLSH *share, struct State *state,
@@ -1441,7 +1453,7 @@ static CURLcode create_single(struct OperationConfig *config,
return result;
if(!outs->out_null && output_expected(per->url, per->uploadfile) &&
- outs->stream && isatty(fileno(outs->stream)))
+ outs->stream && stream_isatty(outs->stream))
/* we send the output to a tty, therefore we switch off the progress
meter */
per->noprogress = global->noprogress = global->isatty = TRUE;
tests/data/Makefile.am+2 -0
@@ -1707,6 +1707,8 @@ TESTCASES = \
test1686 \
test1687 \
test1688 \
+ test1689 \
+ test1690 \
\
test1700 \
test1702 \
tests/data/test1425+1 -1
@@ -42,7 +42,7 @@ CURL_ISATTY=yes
Refuse binary output to terminal
</name>
<command>
-http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --no-styled-output
</command>
</client>
tests/data/test1426+1 -1
@@ -42,7 +42,7 @@ CURL_ISATTY=yes
Okay binary output to terminal
</name>
<command>
-http://%HOSTIP:%HTTPPORT/%TESTNUMBER --output -
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --output - --no-styled-output
</command>
</client>
tests/data/test1689+68 -0
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+--styled-output
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 301 Moved Permanently
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Location: /moved/here
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+# this test needs to be a Debug build in order to fake it being a TTY output
+<features>
+Debug
+!win32
+</features>
+<setenv>
+VTE_VERSION=4802
+CURL_ISATTY=yes
+</setenv>
+<name>
+--styled-output makes header names bold and Location a link
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --show-headers
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+GET /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stdout>
+HTTP/1.1 301 Moved Permanently
+%hex[%1b]hex%[1mDate%hex[%1b]hex%[0m: Tue, 09 Nov 2010 14:49:00 GMT
+%hex[%1b]hex%[1mLocation%hex[%1b]hex%[0m: %hex[%1b]hex%]8;;http://%HOSTIP:%HTTPPORT/moved/here%hex[%1b%5c]hex%/moved/here
+%hex[%1b]hex%]8;;%hex[%1b%5c]hex%%hex[%1b]hex%[1mContent-Length%hex[%1b]hex%[0m: 6
+%hex[%1b]hex%[1mConnection%hex[%1b]hex%[0m: close
+
+-foo-
+</stdout>
+</verify>
+</testcase>
tests/data/test1690+66 -0
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+--styled-output
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data nocheck="yes">
+HTTP/1.1 301 Moved Permanently
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Location: /moved/here
+Content-Length: 6
+Connection: close
+
+-foo-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+# this test needs to be a Debug build in order to fake it being a TTY output
+<features>
+Debug
+</features>
+<setenv>
+CURL_ISATTY=yes
+</setenv>
+<name>
+--no-styled-output writes plain headers to a terminal
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --show-headers --no-styled-output
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+GET /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stdout>
+HTTP/1.1 301 Moved Permanently
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Location: /moved/here
+Content-Length: 6
+Connection: close
+
+-foo-
+</stdout>
+</verify>
+</testcase>