Permalink
Browse files

use eqc(mini) if it's defined, fetching proper otherwise

  • Loading branch information...
1 parent a45de8a commit 4e8d9904e63cf7c6ad5bd5cfdf80d4a4d1699d48 @hyperthunk committed Nov 16, 2012
Showing with 105 additions and 21 deletions.
  1. +1 −0 .gitignore
  2. +7 −6 Makefile
  3. +61 −0 priv/build/plugins/eqc_resolver.erl
  4. +20 −9 rebar.config
  5. +9 −0 test.config
  6. +7 −6 {include → test}/test.hrl
View
@@ -14,3 +14,4 @@ test/logs/
ebin/*.beam
logs/*
include/hamcrest.hrl
+qc.hrl
View
@@ -1,13 +1,14 @@
-all: clean build test
+.PHONY: clean build test
+
+all: clean test
clean:
@(./rebar clean)
build:
- @(./rebar get-deps compile)
-
-test:
- @(./rebar skip_deps=true ct)
+ @(./rebar compile xref)
-.PHONY: deps test clean build
+test: build
+ @(./rebar -C test.config get-deps compile)
+ @(./rebar -C test.config skip_deps=true ct)
@@ -0,0 +1,61 @@
+%% -----------------------------------------------------------------------------
+%%
+%% Hamcrest Erlang.
+%%
+%% Copyright (c) 2010 Tim Watson (watson.timothy@gmail.com)
+%%
+%% Permission is hereby granted, free of charge, to any person obtaining a copy
+%% of this software and associated documentation files (the "Software"), to deal
+%% in the Software without restriction, including without limitation the rights
+%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the Software is
+%% furnished to do so, subject to the following conditions:
+%%
+%% The above copyright notice and this permission notice shall be included in
+%% all copies or substantial portions of the Software.
+%%
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+%% THE SOFTWARE.
+%% -----------------------------------------------------------------------------
+%% @author Tim Watson <watson.timothy@gmail.com>
+%% @copyright 2010 Tim Watson.
+%%
+%% Generates hamcrest.hrl header file during build process. Loaded by rebar.
+%% -----------------------------------------------------------------------------
+-module(eqc_resolver).
+
+-export([preprocess/2]).
+
+preprocess(Config, _) ->
+ case rebar_utils:processing_base_dir(Config) of
+ false -> {ok, []};
+ true -> case code:lib_dir(eqc, include) of
+ {error, bad_name} ->
+ write_include("proper"),
+ {ok, []};
+ _ ->
+ write_include("eqc"),
+ Deps = rebar_config:get_local(Config, deps, []),
+ DepsNoPropEr = proplists:delete(proper, Deps),
+ Config2 = rebar_config:set(Config, deps, DepsNoPropEr),
+ {ok, Config2, []}
+ end
+ end.
+
+write_include(Lib) ->
+ file:write_file(filename:join(test_dir(), "qc.hrl"),
+ include(Lib)).
+
+test_dir() ->
+ filename:join(rebar_utils:get_cwd(), "test").
+
+include(Lib) ->
+ [<<"-include_lib(\"">>,
+ Lib, <<"/include/">>,
+ Lib, <<".hrl\").\n">>,
+ <<"-define(">>, Lib, <<", true).">>].
View
@@ -1,15 +1,26 @@
{lib_dirs, ["deps"]}.
{erl_opts, [debug_info, fail_on_warning]}.
-{cover_enabled, true}.
{clean_files, ["logs", "build", "include/hamcrest.hrl"]}.
-{deps, [
- {proper, "1.0", {git, "http://github.com/manopapad/proper.git", "master"}}
-]}.
-
-%{pre_hooks, [
-% {compile, "sh priv/build/scripts/bootstrap-deps.sh"}
-%]}.
{plugin_dir, "priv/build/plugins"}.
-{plugins, [header_generator]}.
+{plugins, [header_generator, eqc_resolver]}.
+
+{xref_checks, []}.
+{xref_queries,
+ [{"((XC - UC) || (XU - X - B))",[]}, %% calls to undefined functions
+ {"(L - LU)", []}, %% local unused
+ {"(LU * (X - XU))", [ %% exported functions only used locally
+ {hamcrest,assert_that,2}, %% NB: we're a library so this is expected...
+ {hamcrest,assert_that,3},
+ {hamcrest,check,2},
+ {hamcrest,describe,2},
+ {hamcrest,heckle,2},
+ {hamcrest,match,3},
+ {hamcrest_matchers,check_member,2}, %% called via apply/3
+ {hamcrest_matchers,equal_to,1},
+ {hamcrest_matchers,foreach,1},
+ {hamcrest_matchers,is_not,1},
+ {hamcrest_matchers,match_mfa,3},
+ {hamcrest_matchers,reverse_match_mfa,3}]},
+ {"(DF * (XU + LU))", []}]}.
View
@@ -0,0 +1,9 @@
+
+{cover_enabled, true}.
+{deps, [
+ %% TODO: bind to a specific commit or tag instead of 'master'
+ {proper, "1.0", {git, "http://github.com/manopapad/proper.git", "master"}}
+]}.
+
+{plugin_dir, "priv/build/plugins"}.
+{plugins, [eqc_resolver]}.
@@ -38,7 +38,7 @@
Mod:module_info(exports)
)
],
- ct:pal("registering ~p~n", [All]),
+ ct:log("registering ~p~n", [All]),
All).
%% NB: copied verbatim from eunit.hrl because proper_common.hrl redefined the LET macro,
@@ -71,9 +71,10 @@
end)())).
-define(EQC(P),
- case code:lib_dir(eqc, include) of
- {error, bad_name} ->
- proper:quickcheck(P);
- _ ->
- eqc:check(P)
+ begin
+ Mod = case code:lib_dir(eqc, include) of
+ {error, bad_name} -> proper;
+ _ -> eqc
+ end,
+ true = Mod:quickcheck(P)
end).

0 comments on commit 4e8d990

Please sign in to comment.