diff options
author | iilyak <iilyak@users.noreply.github.com> | 2019-12-12 07:21:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-12 07:21:13 -0800 |
commit | 0ef71cbba7adc06fe7cf48259aec41e48c3087e2 (patch) | |
tree | 7fb69eeca9c44bf8d4e6f1597eae64eb9265b235 | |
parent | cda94302d7b1462061cc0ae14a1c714950b61d61 (diff) | |
parent | 1953c33005eb4ffdef75a4a248d6298b1e0ce41a (diff) | |
download | couchdb-0ef71cbba7adc06fe7cf48259aec41e48c3087e2.tar.gz |
Merge pull request #2353 from cloudant/exunit-cover
Exunit cover
-rw-r--r-- | .credo.exs | 8 | ||||
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | Makefile.win | 2 | ||||
-rw-r--r-- | mix.exs | 79 | ||||
-rw-r--r-- | mix.lock | 9 |
6 files changed, 109 insertions, 4 deletions
diff --git a/.credo.exs b/.credo.exs index 2b84a5064..c2ffd19d0 100644 --- a/.credo.exs +++ b/.credo.exs @@ -25,11 +25,19 @@ excluded: [ ~r"/_build/", ~r"/node_modules/", + ~r"/src/certifi/", + ~r"/src/excoveralls/", ~r"/src/jason", + ~r"/src/hackney", ~r"/src/httpotion", ~r"/src/credo", + ~r"/src/idna", ~r"/src/junit_formatter", ~r"/src/bunt", + ~r"/src/metrics", + ~r"/src/minerl", + ~r"/src/parse_trans", + ~r"/src/ssl_verify_fun", ~r"/test/elixir/deps/" ] }, diff --git a/.gitignore b/.gitignore index 6b9198d42..18a4cbdbd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ .DS_Store .rebar/ .eunit/ +cover/ log apache-couchdb-*/ bin/ @@ -32,6 +33,7 @@ share/server/main.js share/www src/b64url/ src/bear/ +src/certifi/ src/config/ src/couch/priv/couch_js/config.h src/couch/priv/couchjs @@ -45,23 +47,31 @@ src/couch/priv/icu_driver/couch_icu_driver.d src/mango/src/mango_cursor_text.nocompile src/docs/ src/ets_lru/ +src/excoveralls/ src/fauxton/ src/folsom/ +src/hackney/ src/hqueue/ src/hyper/ src/ibrowse/ +src/idna/ src/ioq/ src/jiffy/ src/ken/ src/khash/ src/meck/ +src/metrics/ +src/mimerl/ src/mochiweb/ src/oauth/ +src/parse_trans/ src/proper/ src/rebar/ src/smoosh/ src/snappy/ +src/ssl_verify_fun/ src/triq/ +src/unicode_util_compat/ tmp/ src/couch/*.o @@ -191,7 +191,7 @@ exunit: export ERL_LIBS = $(shell pwd)/src exunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell pwd)/bin/couchjs $(shell pwd)/share/server/main.js exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo - @mix test --trace $(EXUNIT_OPTS) + @mix test --cover --trace $(EXUNIT_OPTS) setup-eunit: export BUILDDIR = $(shell pwd) setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config @@ -237,7 +237,8 @@ elixir: elixir-init elixir-check-formatted elixir-credo devclean @dev/run -a adm:pass --no-eval 'mix test --trace --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)' .PHONY: elixir-init -elixir-init: +elixir-init: MIX_ENV=test +elixir-init: config.erl @mix local.rebar --force && mix local.hex --force && mix deps.get .PHONY: elixir-cluster-without-quorum diff --git a/Makefile.win b/Makefile.win index eda27a02a..77cbcbf4b 100644 --- a/Makefile.win +++ b/Makefile.win @@ -152,7 +152,7 @@ exunit: export ERL_LIBS = $(shell echo %cd%)\src exunit: export ERL_AFLAGS = -config $(shell echo %cd%)/rel/files/eunit.config exunit: export COUCHDB_QUERY_SERVER_JAVASCRIPT = $(shell echo %cd%)/bin/couchjs $(shell echo %cd%)/share/server/main.js exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo - @mix test --trace $(EXUNIT_OPTS) + @mix test --cover --trace $(EXUNIT_OPTS) setup-eunit: export BUILDDIR = $(shell pwd) setup-eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config") @@ -1,3 +1,25 @@ +defmodule CoverTool do + def start(path, options) do + {dirs, options} = Keyword.pop(options, :dirs, []) + fun = ExCoveralls.start(path, options) + Mix.shell().info("Cover compiling modules ...") + :cover.stop() + :cover.start() + + Enum.each(dirs, fn path -> + path + |> Path.expand(__DIR__) + |> String.to_charlist() + |> :cover.compile_beam_directory() + end) + + ExCoveralls.ConfServer.start() + ExCoveralls.ConfServer.set(options) + ExCoveralls.StatServer.start() + fun + end +end + defmodule CouchDBTest.Mixfile do use Mix.Project @@ -15,7 +37,12 @@ defmodule CouchDBTest.Mixfile do deps: deps(), consolidate_protocols: Mix.env() not in [:test, :dev, :integration], test_paths: get_test_paths(Mix.env()), - elixirc_paths: elixirc_paths(Mix.env()) + elixirc_paths: elixirc_paths(Mix.env()), + test_coverage: [ + tool: CoverTool, + dirs: get_coverage_paths(), + type: "html" + ] ] end @@ -37,6 +64,7 @@ defmodule CouchDBTest.Mixfile do [ {:junit_formatter, "~> 3.0", only: [:dev, :test, :integration]}, {:httpotion, ">= 3.1.3", only: [:dev, :test, :integration], runtime: false}, + {:excoveralls, "~> 0.12", only: :test}, {:jiffy, path: Path.expand("src/jiffy", __DIR__)}, {:ibrowse, path: Path.expand("src/ibrowse", __DIR__), override: true, compile: false}, @@ -58,4 +86,53 @@ defmodule CouchDBTest.Mixfile do def get_test_paths(_) do [] end + + defp get_deps_paths() do + deps = [ + "bunt", + "certifi", + "credo", + "excoveralls", + "hackney", + "httpotion", + "ibrowse", + "idna", + "jason", + "jiffy", + "junit_formatter", + "metrics", + "mimerl", + "parse_trans", + "ssl_verify_fun", + "unicode_util_compat", + "b64url", + "bear", + "mochiweb", + "snappy", + "triq", + "rebar", + "proper", + "mochiweb", + "meck", + "khash", + "hyper", + "fauxton", + "folsom", + "hqueue" + ] + + deps |> Enum.map(fn app -> "src/#{app}" end) + end + + defp get_coverage_paths() do + deps = + get_deps_paths() + |> Enum.reduce(MapSet.new(), fn x, set -> + MapSet.put(set, "#{x}/ebin") + end) + + Path.wildcard("src/*/ebin") + |> Enum.filter(&File.dir?/1) + |> Enum.filter(fn path -> not MapSet.member?(deps, path) end) + end end @@ -1,9 +1,18 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, + "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"}, "credo": {:hex, :credo, "1.0.5", "fdea745579f8845315fe6a3b43e2f9f8866839cfbc8562bb72778e9fdaa94214", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.12.1", "a553c59f6850d0aff3770e4729515762ba7c8e41eedde03208182a8dc9d0ce07", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, + "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "httpotion": {:hex, :httpotion, "3.1.3", "fdaf1e16b9318dcb722de57e75ac368c93d4c6e3c9125f93e960f953a750fb77", [:mix], [{:ibrowse, "== 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm"}, "ibrowse": {:hex, :ibrowse, "4.4.0", "2d923325efe0d2cb09b9c6a047b2835a5eda69d8a47ed6ff8bc03628b764e991", [:rebar3], [], "hexpm"}, + "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, "jiffy": {:hex, :jiffy, "0.15.2", "de266c390111fd4ea28b9302f0bc3d7472468f3b8e0aceabfbefa26d08cd73b7", [:rebar3], [], "hexpm"}, "junit_formatter": {:hex, :junit_formatter, "3.0.0", "13950d944dbd295da7d8cc4798b8faee808a8bb9b637c88069954eac078ac9da", [:mix], [], "hexpm"}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, + "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm"}, + "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"}, } |