Skip to content
Permalink
Browse files
Merge pull request #2039 from cloudant/exunit-simplified
Exunit simplified
  • Loading branch information
iilyak committed Jul 29, 2019
2 parents 29d484e + 25ad74a commit f37e1e73205e98d6a74a714a23c4a59f7cf2bb0b
Show file tree
Hide file tree
Showing 205 changed files with 887 additions and 79 deletions.
@@ -22,7 +22,16 @@
# 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",
~r"/test/elixir/deps/"
]
},
#
# If you create your own checks, you must specify the source files for
@@ -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"
]
@@ -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/
@@ -41,10 +41,6 @@ env:
- secure: "UdA/gKIlyuXaW+hUgRx40t1TYjLCGxMqHvM5Uw7UbUH2dqEkgJiLfhZGchS1JVzl8M01VKZUUzS7v2nvRLiHZN1kvaw5kfq31VRoafUah8jfmvqNWZVdLovHl3aw5UX/HRt0RkbWbhdbdknTfh6+YinSZ+Nb54jCErMg9nabXtM="
- COUCHDB_IO_LOG_DIR=/tmp/couchjslogs

# Change to elixir folder so that travis can run mix deps.get during install
before_install:
- cd test/elixir

# Enable this block if you want to build docs & fauxton too
#node_js:
# - 6
@@ -53,7 +49,6 @@ before_install:

# Then comment this section out
before_script:
- cd ../..
- kerl list installations
- rm -rf /tmp/couchjslogs
- mkdir -p /tmp/couchjslogs
@@ -173,6 +173,16 @@ 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-init setup-eunit elixir-check-formatted elixir-credo
@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:
@@ -212,34 +222,37 @@ python-black-update: .venv/bin/black
. dev/run rel/overlay/bin/couchup test/javascript/run

.PHONY: elixir
elixir: export MIX_ENV=integration
elixir: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -a adm:pass --no-eval 'test/elixir/run --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
@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:
@cd test/elixir && mix local.rebar --force && mix local.hex --force && mix deps.get
@mix local.rebar --force && mix local.hex --force && mix deps.get

.PHONY: elixir-cluster-without-quorum
elixir-cluster-without-quorum: elixir-check-formatted elixir-credo devclean
elixir-cluster-without-quorum: export MIX_ENV=integration
elixir-cluster-without-quorum: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 2 \
--no-eval 'test/elixir/run --only without_quorum_test $(EXUNIT_OPTS)'
--no-eval 'mix test --trace --only without_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-cluster-with-quorum
elixir-cluster-with-quorum: elixir-check-formatted elixir-credo devclean
elixir-cluster-with-quorum: export MIX_ENV=integration
elixir-cluster-with-quorum: elixir-init elixir-check-formatted elixir-credo devclean
@dev/run -n 3 -q -a adm:pass \
--degrade-cluster 1 \
--no-eval 'test/elixir/run --only with_quorum_test $(EXUNIT_OPTS)'
--no-eval 'mix test --trace --only with_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-check-formatted
elixir-check-formatted:
@cd test/elixir/ && mix format --check-formatted
elixir-check-formatted: elixir-init
@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
elixir-credo: elixir-init
@mix credo

.PHONY: javascript
# target: javascript - Run JavaScript test suites or specific ones defined by suites option
@@ -144,6 +144,16 @@ 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-init setup-eunit elixir-check-formatted elixir-credo
@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:
@@ -177,33 +187,33 @@ python-black-update: .venv/bin/black

.PHONY: elixir
elixir: elixir-init elixir-check-formatted elixir-credo devclean
@dev\run -a adm:pass --no-eval 'test\elixir\run.cmd --exclude without_quorum_test --exclude with_quorum_test $(EXUNIT_OPTS)'
@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:
@cd test/elixir && mix local.rebar --force && mix local.hex --force && mix deps.get
@mix local.rebar --force && mix local.hex --force && mix deps.get

.PHONY: elixir-cluster-without-quorum
elixir-cluster-without-quorum: elixir-check-formatted elixir-credo devclean
@dev\run -n 3 -q -a adm:pass \
--degrade-cluster 2 \
--no-eval 'test\elixir\run.cmd --only without_quorum_test $(EXUNIT_OPTS)'
--no-eval 'mix test --trace --only without_quorum_test $(EXUNIT_OPTS)'

.PHONY: elixir-cluster-with-quorum
elixir-cluster-with-quorum: elixir-check-formatted elixir-credo devclean
@dev\run -n 3 -q -a adm:pass \
--degrade-cluster 1 \
--no-eval 'test\elixir\run.cmd --only with_quorum_test $(EXUNIT_OPTS)'
--no-eval 'mix test --trace --only with_quorum_test $(EXUNIT_OPTS)'

.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: test-cluster-with-quorum
test-cluster-with-quorum: devclean
@@ -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"
@@ -0,0 +1 @@
use Mix.Config
@@ -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
@@ -0,0 +1 @@
use Mix.Config
@@ -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
60 mix.exs
@@ -0,0 +1,60 @@
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, :integration],
test_paths: get_test_paths(Mix.env()),
elixirc_paths: elixirc_paths(Mix.env())
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
applications: [:httpotion]
]
end

# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["test/elixir/lib", "test/elixir/test/support"]
defp elixirc_paths(:integration), 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, :integration], 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, :integration], runtime: false}
]
end

def get_test_paths(:test) do
Path.wildcard("src/*/test/exunit") |> Enum.filter(&File.dir?/1)
end

def get_test_paths(:integration) do
integration_tests =
Path.wildcard("src/*/test/integration") |> Enum.filter(&File.dir?/1)

["test/elixir/test" | integration_tests]
end

def get_test_paths(_) do
[]
end
end
@@ -1,8 +1,8 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"credo": {:hex, :credo, "1.0.0", "aaa40fdd0543a0cf8080e8c5949d8c25f0a24e4fc8c1d83d06c388f5e5e0ea42", [: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.0", "14d20d9b0ce4e86e253eb91e4af79e469ad949f57a5d23c0a51b2f86559f6589", [:mix], [{:ibrowse, "~> 4.4", [hex: :ibrowse, repo: "hexpm", optional: false]}], "hexpm"},
"ibrowse": {:hex, :ibrowse, "4.4.1", "2b7d0637b0f8b9b4182de4bd0f2e826a4da2c9b04898b6e15659ba921a8d6ec2", [:rebar3], [], "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"},
File renamed without changes.
File renamed without changes.