Merge pull request #1 from apache/optional-proper

Make PropEr an optional (test) dependency
diff --git a/rebar.config b/rebar.config
deleted file mode 100644
index 4c4da01..0000000
--- a/rebar.config
+++ /dev/null
@@ -1,13 +0,0 @@
-{deps, [
-    {proper, ".*", {git, "https://github.com/manopapad/proper.git", "master"}}
-]}.
-
-{port_specs, [
-    {"priv/hqueue.so", ["c_src/hqueue*.c"]}
-]}.
-{port_env, [
-    {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -DHQ_ENIF_ALLOC -O3"}
-    %% {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -Wextra"}
-]}.
-{eunit_opts, [verbose]}.
-{erl_opts, [debug_info]}.
diff --git a/rebar.config.script b/rebar.config.script
new file mode 100644
index 0000000..50bbd22
--- /dev/null
+++ b/rebar.config.script
@@ -0,0 +1,20 @@
+WithProper = code:lib_dir(proper) /= {error, bad_name}.
+
+ErlOpts =
+    [debug_info] ++
+    case WithProper of
+        true ->
+            [{d, 'WITH_PROPER'}];
+        false ->
+            []
+    end,
+
+[{port_specs, [
+    {"priv/hqueue.so", ["c_src/hqueue*.c"]}
+]},
+{port_env, [
+    {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -DHQ_ENIF_ALLOC -O3"}
+    %% {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -Wextra"}
+]},
+{eunit_opts, [verbose]},
+{erl_opts, [{i, "../"} | ErlOpts]}].
diff --git a/test/hqueue_proper.erl b/test/hqueue_proper.erl
index 0337b01..314d83f 100644
--- a/test/hqueue_proper.erl
+++ b/test/hqueue_proper.erl
@@ -12,6 +12,7 @@
 
 -module(hqueue_proper).
 
+-ifdef(WITH_PROPER).
 -include_lib("proper/include/proper.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
@@ -31,3 +32,4 @@
 simple_test_() ->
     ?_assertEqual(true, ?QC(prop_simple())).
 
+-endif.
diff --git a/test/hqueue_statem.erl b/test/hqueue_statem.erl
index 027d65d..2bc3dc5 100644
--- a/test/hqueue_statem.erl
+++ b/test/hqueue_statem.erl
@@ -12,6 +12,7 @@
 
 -module(hqueue_statem).
 
+-ifdef(WITH_PROPER).
 -include_lib("proper/include/proper.hrl").
 -include_lib("eunit/include/eunit.hrl").
 
@@ -113,3 +114,4 @@
 postcondition(_S, {call, _, max_elems, [_]}, Result) ->
     0 < Result.
 
+-endif.