aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-07-10 12:58:12 +0200
committerLoïc Hoguin <[email protected]>2017-07-10 12:58:12 +0200
commit2cf430f404771255feead27873e48542829ea185 (patch)
tree1b6e6ed9a223064158031fb64db35e0498e64b97
parent93d68bcccc118ef1b72622efc95f9fde5252c3ff (diff)
downloadcowlib-2cf430f404771255feead27873e48542829ea185.tar.gz
cowlib-2cf430f404771255feead27873e48542829ea185.tar.bz2
cowlib-2cf430f404771255feead27873e48542829ea185.zip
Switch from Triq to Proper
-rw-r--r--.gitignore1
-rw-r--r--Makefile3
-rw-r--r--erlang.mk78
-rw-r--r--src/cow_date.erl14
-rw-r--r--src/cow_hpack.erl2
-rw-r--r--src/cow_http_hd.erl23
6 files changed, 91 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore
index fd3d6c9..006dfdd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.cowlib.plt
.erlang.mk
_rel
+cowlib.d
deps
doc/man3
doc/man7
diff --git a/Makefile b/Makefile
index cb2fbc3..ba2ecd3 100644
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,8 @@ CI_HIPE ?= $(lastword $(CI_OTP))
CI_ERLLVM ?= $(CI_HIPE)
TEST_ERLC_OPTS += +'{parse_transform, eunit_autoexport}' +'{parse_transform, horse_autoexport}'
-TEST_DEPS = horse triq
+TEST_DEPS = horse proper
dep_horse = git https://github.com/extend/horse master
-dep_triq = git https://github.com/krestenkrab/triq master
include erlang.mk
diff --git a/erlang.mk b/erlang.mk
index ecc0490..953f247 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -17,7 +17,7 @@
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
export ERLANG_MK_FILENAME
-ERLANG_MK_VERSION = 2017.05.18
+ERLANG_MK_VERSION = 2017.07.06-1-gff27159
ERLANG_MK_WITHOUT =
# Make 3.81 and 3.82 are deprecated.
@@ -2023,6 +2023,14 @@ pkg_ibrowse_fetch = git
pkg_ibrowse_repo = https://github.com/cmullaparthi/ibrowse
pkg_ibrowse_commit = master
+PACKAGES += idna
+pkg_idna_name = idna
+pkg_idna_description = Erlang IDNA lib
+pkg_idna_homepage = https://github.com/benoitc/erlang-idna
+pkg_idna_fetch = git
+pkg_idna_repo = https://github.com/benoitc/erlang-idna
+pkg_idna_commit = master
+
PACKAGES += ierlang
pkg_ierlang_name = ierlang
pkg_ierlang_description = An Erlang language kernel for IPython.
@@ -2298,9 +2306,9 @@ pkg_kvs_commit = master
PACKAGES += lager
pkg_lager_name = lager
pkg_lager_description = A logging framework for Erlang/OTP.
-pkg_lager_homepage = https://github.com/basho/lager
+pkg_lager_homepage = https://github.com/erlang-lager/lager
pkg_lager_fetch = git
-pkg_lager_repo = https://github.com/basho/lager
+pkg_lager_repo = https://github.com/erlang-lager/lager
pkg_lager_commit = master
PACKAGES += lager_amqp_backend
@@ -2314,9 +2322,9 @@ pkg_lager_amqp_backend_commit = master
PACKAGES += lager_syslog
pkg_lager_syslog_name = lager_syslog
pkg_lager_syslog_description = Syslog backend for lager
-pkg_lager_syslog_homepage = https://github.com/basho/lager_syslog
+pkg_lager_syslog_homepage = https://github.com/erlang-lager/lager_syslog
pkg_lager_syslog_fetch = git
-pkg_lager_syslog_repo = https://github.com/basho/lager_syslog
+pkg_lager_syslog_repo = https://github.com/erlang-lager/lager_syslog
pkg_lager_syslog_commit = master
PACKAGES += lambdapad
@@ -4579,7 +4587,7 @@ define dep_autopatch_appsrc_script.erl
AppSrc = "$(call core_native_path,$(DEPS_DIR)/$1/src/$1.app.src)",
AppSrcScript = AppSrc ++ ".script",
Bindings = erl_eval:new_bindings(),
- {ok, Conf} = file:script(AppSrcScript, Bindings),
+ {ok, [Conf]} = file:script(AppSrcScript, Bindings),
ok = file:write_file(AppSrc, io_lib:format("~p.~n", [Conf])),
halt()
endef
@@ -6433,6 +6441,60 @@ apps-eunit:
endif
endif
+# Copyright (c) 2015-2017, Loïc Hoguin <[email protected]>
+# This file is part of erlang.mk and subject to the terms of the ISC License.
+
+ifeq ($(filter proper,$(DEPS) $(TEST_DEPS)),proper)
+.PHONY: proper
+
+# Targets.
+
+tests:: proper
+
+define proper_check.erl
+ code:add_pathsa(["$(call core_native_path,$(CURDIR)/ebin)", "$(call core_native_path,$(DEPS_DIR)/*/ebin)"]),
+ Module = fun(M) ->
+ [true] =:= lists:usort([
+ case atom_to_list(F) of
+ "prop_" ++ _ ->
+ io:format("Testing ~p:~p/0~n", [M, F]),
+ proper:quickcheck(M:F());
+ _ ->
+ true
+ end
+ || {F, 0} <- M:module_info(exports)])
+ end,
+ try
+ case $(1) of
+ all -> [true] =:= lists:usort([Module(M) || M <- [$(call comma_list,$(3))]]);
+ module -> Module($(2));
+ function -> proper:quickcheck($(2))
+ end
+ of
+ true -> halt(0);
+ _ -> halt(1)
+ catch error:undef ->
+ io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]),
+ halt(0)
+ end.
+endef
+
+ifdef t
+ifeq (,$(findstring :,$(t)))
+proper: test-build
+ $(verbose) $(call erlang,$(call proper_check.erl,module,$(t)))
+else
+proper: test-build
+ $(verbose) echo Testing $(t)/0
+ $(verbose) $(call erlang,$(call proper_check.erl,function,$(t)()))
+endif
+else
+proper: test-build
+ $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(wildcard ebin/*.beam))))))
+ $(gen_verbose) $(call erlang,$(call proper_check.erl,all,undefined,$(MODULES)))
+endif
+endif
+
# Copyright (c) 2013-2016, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
@@ -6443,7 +6505,7 @@ endif
RELX ?= $(ERLANG_MK_TMP)/relx
RELX_CONFIG ?= $(CURDIR)/relx.config
-RELX_URL ?= https://github.com/erlware/relx/releases/download/v3.19.0/relx
+RELX_URL ?= https://github.com/erlware/relx/releases/download/v3.23.0/relx
RELX_OPTS ?=
RELX_OUTPUT_DIR ?= _rel
RELX_REL_EXT ?=
@@ -6590,7 +6652,7 @@ define triq_check.erl
true -> halt(0);
_ -> halt(1)
catch error:undef ->
- io:format("Undefined property or module~n"),
+ io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]),
halt(0)
end.
endef
diff --git a/src/cow_date.erl b/src/cow_date.erl
index 803448b..c0710f8 100644
--- a/src/cow_date.erl
+++ b/src/cow_date.erl
@@ -20,7 +20,7 @@
-export([rfc7231/1]).
-ifdef(TEST).
--include_lib("triq/include/triq.hrl").
+-include_lib("proper/include/proper.hrl").
-endif.
%% @doc Parse the HTTP date (IMF-fixdate, rfc850, asctime).
@@ -143,12 +143,12 @@ asctime_day(D1, D2) -> (D1 - $0) * 10 + (D2 - $0).
-ifdef(TEST).
day_name() -> oneof(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]).
day_name_l() -> oneof(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]).
-year() -> int(1951, 2050).
-month() -> int(1, 12).
-day() -> int(1, 31).
-hour() -> int(23).
-minute() -> int(59).
-second() -> int(60).
+year() -> integer(1951, 2050).
+month() -> integer(1, 12).
+day() -> integer(1, 31).
+hour() -> integer(0, 23).
+minute() -> integer(0, 59).
+second() -> integer(0, 60).
fixdate_gen() ->
?LET({DayName, Y, Mo, D, H, Mi, S},
diff --git a/src/cow_hpack.erl b/src/cow_hpack.erl
index a3c1c9b..694acfb 100644
--- a/src/cow_hpack.erl
+++ b/src/cow_hpack.erl
@@ -42,7 +42,7 @@
-export_type([opts/0]).
-ifdef(TEST).
--include_lib("triq/include/triq.hrl").
+-include_lib("proper/include/proper.hrl").
-endif.
%% State initialization.
diff --git a/src/cow_http_hd.erl b/src/cow_http_hd.erl
index 600f21a..08c392b 100644
--- a/src/cow_http_hd.erl
+++ b/src/cow_http_hd.erl
@@ -135,7 +135,7 @@
-include("cow_parse.hrl").
-ifdef(TEST).
--include_lib("triq/include/triq.hrl").
+-include_lib("proper/include/proper.hrl").
vector(Min, Max, Dom) -> ?LET(N, choose(Min, Max), vector(N, Dom)).
small_list(Dom) -> vector(0, 10, Dom).
@@ -162,13 +162,13 @@ token() ->
list_to_binary(T)).
abnf_char() ->
- int(1, 127).
+ integer(1, 127).
vchar() ->
- int(33, 126).
+ integer(33, 126).
obs_text() ->
- int(128, 255).
+ integer(128, 255).
qdtext() ->
frequency([
@@ -200,7 +200,7 @@ parameter() ->
weight() ->
frequency([
- {90, int(0, 1000)},
+ {90, integer(0, 1000)},
{10, undefined}
]).
@@ -1759,7 +1759,7 @@ etag(<< C, R/bits >>, Strength, Tag) when ?IS_ETAGC(C) ->
-ifdef(TEST).
etagc() ->
- ?SUCHTHAT(C, int(16#21, 16#ff), C =/= 16#22 andalso C =/= 16#7f).
+ ?SUCHTHAT(C, integer(16#21, 16#ff), C =/= 16#22 andalso C =/= 16#7f).
etag() ->
?LET({Strength, Tag},
@@ -1920,7 +1920,7 @@ host() -> vector(1, 255, elements(host_chars())).
host_port() ->
?LET({Host, Port},
- {host(), oneof([undefined, int(1, 65535)])},
+ {host(), oneof([undefined, integer(1, 65535)])},
begin
HostBin = list_to_binary(Host),
{{?LOWER(HostBin), Port},
@@ -2242,7 +2242,7 @@ scheme() -> oneof([<<"http">>, <<"https">>]).
scheme_host_port() ->
?LET({Scheme, Host, Port},
- {scheme(), host(), int(1, 65535)},
+ {scheme(), host(), integer(1, 65535)},
begin
HostBin = list_to_binary(Host),
{[{Scheme, ?LOWER(HostBin), Port}],
@@ -2693,7 +2693,7 @@ parse_sec_websocket_version_req(SecWebSocketVersion) when byte_size(SecWebSocket
-ifdef(TEST).
prop_parse_sec_websocket_version_req() ->
?FORALL(Version,
- int(0, 255),
+ integer(0, 255),
Version =:= parse_sec_websocket_version_req(integer_to_binary(Version))).
parse_sec_websocket_version_req_test_() ->
@@ -2744,7 +2744,7 @@ ws_version_list_sep(<< $,, R/bits >>, Acc) -> ws_version_list(R, Acc).
-ifdef(TEST).
sec_websocket_version_resp() ->
?LET(L,
- non_empty(list({ows(), ows(), int(0, 255)})),
+ non_empty(list({ows(), ows(), integer(0, 255)})),
begin
<< _, SecWebSocketVersion/binary >> = iolist_to_binary(
[[OWS1, $,, OWS2, integer_to_binary(V)] || {OWS1, OWS2, V} <- L]),
@@ -2834,7 +2834,7 @@ te() ->
L2 = case Trail of
no_trailers -> L;
trailers ->
- Rand = random:uniform(length(L) + 1) - 1,
+ Rand = rand:uniform(length(L) + 1) - 1,
{Before, After} = lists:split(Rand, L),
Before ++ [{<<"trailers">>, undefined}|After]
end,
@@ -2847,7 +2847,6 @@ te() ->
).
prop_parse_te() ->
- random:seed(os:timestamp()),
?FORALL({Trail, L, TE},
te(),
begin