diff options
Diffstat (limited to 'test/examples_SUITE.erl')
-rw-r--r-- | test/examples_SUITE.erl | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/test/examples_SUITE.erl b/test/examples_SUITE.erl index 0a3b0eb..3d7c48b 100644 --- a/test/examples_SUITE.erl +++ b/test/examples_SUITE.erl @@ -1,4 +1,4 @@ -%% Copyright (c) 2016-2017, Loïc Hoguin <[email protected]> +%% Copyright (c) Loïc Hoguin <[email protected]> %% %% Permission to use, copy, modify, and/or distribute this software for any %% purpose with or without fee is hereby granted, provided that the above @@ -35,10 +35,10 @@ init_per_suite(Config) -> %% reuse the same build across all tests. Make = do_find_make_cmd(), CommonDir = config(priv_dir, Config), - ct:log("~s~n", [os:cmd("git clone --depth 1 https://github.com/ninenines/cowboy " + ct:log("~ts~n", [os:cmd("git clone --depth 1 https://github.com/ninenines/cowboy " ++ CommonDir ++ "cowboy")]), - ct:log("~s~n", [os:cmd(Make ++ " -C " ++ CommonDir ++ "cowboy distclean")]), - ct:log("~s~n", [os:cmd(Make ++ " -C " ++ CommonDir ++ "cowboy DEPS_DIR=" ++ CommonDir)]), + ct:log("~ts~n", [os:cmd(Make ++ " -C " ++ CommonDir ++ "cowboy distclean")]), + ct:log("~ts~n", [os:cmd(Make ++ " -C " ++ CommonDir ++ "cowboy DEPS_DIR=" ++ CommonDir)]), Config. end_per_suite(_) -> @@ -70,24 +70,24 @@ do_get_paths(Example0) -> do_compile_and_start(Example, Config) -> Make = do_find_make_cmd(), {Dir, Rel, _} = do_get_paths(Example), - ct:log("~s~n", [os:cmd(Make ++ " -C " ++ Dir ++ " distclean")]), + ct:log("~ts~n", [os:cmd(Make ++ " -C " ++ Dir ++ " distclean")]), %% We use a common build for Cowboy, Cowlib and Ranch to speed things up. CommonDir = config(priv_dir, Config), - ct:log("~s~n", [os:cmd("mkdir " ++ Dir ++ "/deps")]), - ct:log("~s~n", [os:cmd("ln -s " ++ CommonDir ++ "cowboy " ++ Dir ++ "/deps/cowboy")]), - ct:log("~s~n", [os:cmd("ln -s " ++ CommonDir ++ "cowlib " ++ Dir ++ "/deps/cowlib")]), - ct:log("~s~n", [os:cmd("ln -s " ++ CommonDir ++ "ranch " ++ Dir ++ "/deps/ranch")]), + ct:log("~ts~n", [os:cmd("mkdir " ++ Dir ++ "/deps")]), + ct:log("~ts~n", [os:cmd("ln -s " ++ CommonDir ++ "cowboy " ++ Dir ++ "/deps/cowboy")]), + ct:log("~ts~n", [os:cmd("ln -s " ++ CommonDir ++ "cowlib " ++ Dir ++ "/deps/cowlib")]), + ct:log("~ts~n", [os:cmd("ln -s " ++ CommonDir ++ "ranch " ++ Dir ++ "/deps/ranch")]), %% TERM=dumb disables relx coloring. - ct:log("~s~n", [os:cmd(Make ++ " -C " ++ Dir ++ " TERM=dumb")]), - ct:log("~s~n", [os:cmd(Rel ++ " stop")]), - ct:log("~s~n", [os:cmd(Rel ++ " start")]), + ct:log("~ts~n", [os:cmd(Make ++ " -C " ++ Dir ++ " TERM=dumb")]), + ct:log("~ts~n", [os:cmd(Rel ++ " stop")]), + ct:log("~ts~n", [os:cmd(Rel ++ " daemon")]), timer:sleep(2000), ok. do_stop(Example) -> {_, Rel, Log} = do_get_paths(Example), - ct:log("~s~n", [os:cmd(Rel ++ " stop")]), - ct:log("~s~n", [element(2, file:read_file(Log))]), + ct:log("~ts~n", [os:cmd(Rel ++ " stop")]), + ct:log("~ts~n", [element(2, file:read_file(Log))]), ok. %% Fetch a response. @@ -372,13 +372,16 @@ file_server(Config) -> do_file_server(Transport, Protocol, Config) -> %% Directory. {200, DirHeaders, <<"<!DOCTYPE html><html>", _/bits >>} = do_get(Transport, Protocol, "/", Config), - {_, <<"text/html">>} = lists:keyfind(<<"content-type">>, 1, DirHeaders), + {_, <<"text/html; charset=utf-8">>} = lists:keyfind(<<"content-type">>, 1, DirHeaders), _ = do_rest_get(Transport, Protocol, "/", <<"application/json">>, undefined, Config), %% Files. {200, _, _} = do_get(Transport, Protocol, "/small.mp4", Config), {200, _, _} = do_get(Transport, Protocol, "/small.ogv", Config), {200, _, _} = do_get(Transport, Protocol, "/test.txt", Config), {200, _, _} = do_get(Transport, Protocol, "/video.html", Config), + {200, _, _} = do_get(Transport, Protocol, + ["/", cow_uri:urlencode(<<"中文"/utf8>>), "/", cow_uri:urlencode(<<"中文.html"/utf8>>)], + Config), ok. %% Markdown middleware. |