diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2019-05-09 21:49:32 +0000 |
---|---|---|
committer | ILYA Khlopotov <iilyak@apache.org> | 2019-07-29 11:24:37 +0000 |
commit | d5849629a99603904ce94ce561916ebb66d04600 (patch) | |
tree | 984ff4894dfd67969ca002e39435f9988ed7cf5f | |
parent | f33378b38e45629c5934e739835571fbbd28bdda (diff) | |
download | couchdb-d5849629a99603904ce94ce561916ebb66d04600.tar.gz |
Minimal ExUnit setup
-rw-r--r-- | .credo.exs (renamed from test/elixir/.credo.exs) | 10 | ||||
-rw-r--r-- | .formatter.exs | 9 | ||||
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | Makefile.win | 14 | ||||
-rw-r--r-- | config/config.exs | 30 | ||||
-rw-r--r-- | config/dev.exs | 1 | ||||
-rw-r--r-- | config/prod.exs | 1 | ||||
-rw-r--r-- | config/test.exs | 12 | ||||
-rw-r--r-- | mix.exs | 47 | ||||
-rw-r--r-- | mix.lock | 9 | ||||
-rw-r--r-- | src/couch/test/exunit/test_helper.exs | 2 |
12 files changed, 157 insertions, 3 deletions
diff --git a/test/elixir/.credo.exs b/.credo.exs index e24836c8f..db301e4d0 100644 --- a/test/elixir/.credo.exs +++ b/.credo.exs @@ -22,7 +22,15 @@ # In the latter case `**/*.{ex,exs}` will be used. # included: ["lib/", "src/", "test/", "web/", "apps/"], - excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] + excluded: [ + ~r"/_build/", + ~r"/node_modules/", + ~r"/src/jason", + ~r"/src/httpotion", + ~r"/src/credo", + ~r"/src/junit_formatter", + ~r"/src/bunt" + ] }, # # If you create your own checks, you must specify the source files for diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 000000000..28b883d54 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,9 @@ +# Used by "mix format" +[ + inputs: [ + "{mix,.formatter}.exs", + "{config,src}/*/test/exunit/*.{ex,exs}" + ], + line_length: 90, + rename_deprecated_at: "1.5.0" +] diff --git a/.gitignore b/.gitignore index 36bc13007..6b9198d42 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,10 @@ src/global_changes/ebin/ src/mango/ebin/ src/mango/test/*.pyc src/mango/venv/ + +/_build/ +/src/bunt +/src/credo/ +/src/httpotion/ +/src/jason/ +/src/junit_formatter/ @@ -173,6 +173,20 @@ eunit: couch $(REBAR) -r eunit $(EUNIT_OPTS) apps=$$dir || exit 1; \ done +.PHONY: exunit +# target: exunit - Run ExUnit tests +exunit: export BUILDDIR = $(shell pwd) +exunit: export MIX_ENV=test +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-check-formatted elixir-credo + @mix local.hex --force + @mix local.rebar rebar ${REBAR} --force + @mix deps.get + @$(REBAR) setup_eunit 2> /dev/null + @mix test --trace $(EXUNIT_OPTS) + setup-eunit: export BUILDDIR = $(shell pwd) setup-eunit: export ERL_AFLAGS = -config $(shell pwd)/rel/files/eunit.config setup-eunit: @@ -233,13 +247,13 @@ elixir-cluster-with-quorum: elixir-check-formatted elixir-credo devclean .PHONY: elixir-check-formatted elixir-check-formatted: - @cd test/elixir/ && mix format --check-formatted + mix format --check-formatted # Credo is a static code analysis tool for Elixir. # We use it in our tests .PHONY: elixir-credo elixir-credo: - @cd test/elixir/ && mix credo + mix credo .PHONY: javascript # target: javascript - Run JavaScript test suites or specific ones defined by suites option diff --git a/Makefile.win b/Makefile.win index 99ec71278..2c4dc9821 100644 --- a/Makefile.win +++ b/Makefile.win @@ -144,6 +144,20 @@ eunit: couch @$(REBAR) setup_eunit 2> nul @$(REBAR) -r eunit $(EUNIT_OPTS) +.PHONY: exunit +# target: exunit - Run ExUnit tests +exunit: export BUILDDIR = $(shell echo %cd%) +exunit: export MIX_ENV=test +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-check-formatted elixir-credo + @mix local.hex --force + @mix local.rebar rebar ${REBAR} --force + @mix deps.get + @$(REBAR) setup_eunit 2> nul + @mix test --trace $(EXUNIT_OPTS) + setup-eunit: export BUILDDIR = $(shell pwd) setup-eunit: export ERL_AFLAGS = $(shell echo "-config rel/files/eunit.config") setup-eunit: diff --git a/config/config.exs b/config/config.exs new file mode 100644 index 000000000..8e52433cc --- /dev/null +++ b/config/config.exs @@ -0,0 +1,30 @@ +# This file is responsible for configuring your application +# and its dependencies with the aid of the Mix.Config module. +use Mix.Config + +# This configuration is loaded before any dependency and is restricted +# to this project. If another project depends on this project, this +# file won't be loaded nor affect the parent project. For this reason, +# if you want to provide default values for your application for +# 3rd-party users, it should be done in your "mix.exs" file. + +# You can configure your application as: +# +# config :couchdbtest, key: :value +# +# and access this configuration in your application as: +# +# Application.get_env(:couchdbtest, :key) +# +# You can also configure a 3rd-party app: +# +# config :logger, level: :info +# + +# It is also possible to import configuration files, relative to this +# directory. For example, you can emulate configuration per environment +# by uncommenting the line below and defining dev.exs, test.exs and such. +# Configuration from the imported file will override the ones defined +# here (which is why it is important to import them last). +# +import_config "#{Mix.env}.exs"
\ No newline at end of file diff --git a/config/dev.exs b/config/dev.exs new file mode 100644 index 000000000..d2d855e6d --- /dev/null +++ b/config/dev.exs @@ -0,0 +1 @@ +use Mix.Config diff --git a/config/prod.exs b/config/prod.exs new file mode 100644 index 000000000..d2d855e6d --- /dev/null +++ b/config/prod.exs @@ -0,0 +1 @@ +use Mix.Config diff --git a/config/test.exs b/config/test.exs new file mode 100644 index 000000000..c5a5ed24a --- /dev/null +++ b/config/test.exs @@ -0,0 +1,12 @@ +use Mix.Config + +config :logger, + backends: [:console], + compile_time_purge_level: :debug, + level: :debug + +config :kernel, + error_logger: false + +config :sasl, + sasl_error_logger: false diff --git a/mix.exs b/mix.exs new file mode 100644 index 000000000..d9c8c2160 --- /dev/null +++ b/mix.exs @@ -0,0 +1,47 @@ +defmodule CouchDBTest.Mixfile do + use Mix.Project + + def project do + [ + app: :couchdbtest, + version: "0.1.0", + elixir: "~> 1.5", + lockfile: Path.expand("mix.lock", __DIR__), + deps_path: Path.expand("src", __DIR__), + build_path: Path.expand("_build", __DIR__), + compilers: [:elixir, :app], + start_permanent: Mix.env() == :prod, + build_embedded: Mix.env() == :prod, + deps: deps(), + consolidate_protocols: Mix.env() not in [:test, :dev], + test_paths: get_test_paths(), + elixirc_paths: elixirc_paths(Mix.env()) + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Specifies which paths to compile per environment. + defp elixirc_paths(:test), do: ["test/elixir/lib", "test/elixir/test/support"] + defp elixirc_paths(_), do: ["test/elixir/lib"] + + # Run "mix help deps" to learn about dependencies. + defp deps() do + [ + {:httpotion, "~> 3.0", only: [:dev, :test], runtime: false}, + {:jiffy, path: Path.expand("src/jiffy", __DIR__)}, + {:ibrowse, + path: Path.expand("src/ibrowse", __DIR__), override: true, compile: false}, + {:credo, "~> 1.0.0", only: [:dev, :test], runtime: false} + ] + end + + def get_test_paths do + Path.wildcard("src/*/test/exunit") |> Enum.filter(&File.dir?/1) + end +end diff --git a/mix.lock b/mix.lock new file mode 100644 index 000000000..34c0ea961 --- /dev/null +++ b/mix.lock @@ -0,0 +1,9 @@ +%{ + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "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"}, + "httpotion": {:hex, :httpotion, "3.1.2", "50e3e559c2ffe8c8908c97e4ffb01efc1c18e8547cc7ce5dd173c9cf0a573a3b", [:mix], [{:ibrowse, "== 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm"}, + "ibrowse": {:hex, :ibrowse, "4.4.0", "2d923325efe0d2cb09b9c6a047b2835a5eda69d8a47ed6ff8bc03628b764e991", [:rebar3], [], "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"}, +} diff --git a/src/couch/test/exunit/test_helper.exs b/src/couch/test/exunit/test_helper.exs new file mode 100644 index 000000000..314050085 --- /dev/null +++ b/src/couch/test/exunit/test_helper.exs @@ -0,0 +1,2 @@ +ExUnit.configure(formatters: [JUnitFormatter, ExUnit.CLIFormatter]) +ExUnit.start() |