各位,
我在学写 openresty 的 .t 测试,现在碰到的问题是不会测试输出中的 \r\n,以及不会如何忽略掉最后一个 \n,例如
001-test.t 如下
use Test::Nginx::Socket::Lua::Stream "no_plan";
run_tests();
__DATA__
=== TEST 1: \r\n
--- stream_server_config
content_by_lua_block {
ngx.print("a\r\nb")
}
--- stream_response
a
b
--- no_error_log
[error]
[warn]
此测试运行时输出如下
# Failed test 'TEST 1: \r\n - response_body - response is expected (repeated req 0, req 0)'
# at /usr/local/share/perl5/Test/Nginx/Socket.pm line 1387.
# got: "a\x{0d}\x{0a}b"
# length: 4
# expected: "a\x{0a}b\x{0a}"
# length: 4
# strings begin to differ at char 2 (line 1 column 2)
# Looks like you failed 1 test of 4.
程序输出的是 a\r\nb ,而配置文件写出来模块理解的期待输出是 a\nb\n ,这里第一个 \n 是我配置文件中写的,第二个 \n 是因为要换行写 --- no_error_log 而不得不包括的。
请问这里我应该怎么写这个配置文件?
谢谢
---