You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2019/07/29 13:39:54 UTC

[couchdb] branch exunit-simplified updated (02b0421 -> 25ad74a)

This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a change to branch exunit-simplified
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


 discard 02b0421  Update .travis.yml
    omit 74a1007  Unify runners for unit and integration tests
     new d427f35  Unify runners for unit and integration tests
     new 25ad74a  Update .travis.yml

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (02b0421)
            \
             N -- N -- N   refs/heads/exunit-simplified (25ad74a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Makefile.win | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[couchdb] 02/02: Update .travis.yml

Posted by ii...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a commit to branch exunit-simplified
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 25ad74a6cdc03732265d5175218e96a004dd4c40
Author: ILYA Khlopotov <ii...@apache.org>
AuthorDate: Fri Jun 21 12:50:56 2019 +0000

    Update .travis.yml
---
 .travis.yml | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7ef4aea..4af915e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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


[couchdb] 01/02: Unify runners for unit and integration tests

Posted by ii...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a commit to branch exunit-simplified
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d427f353ab4be03998685f6a167d9559c7b50a76
Author: ILYA Khlopotov <ii...@apache.org>
AuthorDate: Thu Jun 20 21:41:40 2019 +0000

    Unify runners for unit and integration tests
---
 .credo.exs                            |  3 ++-
 Makefile                              | 29 +++++++++++++--------------
 Makefile.win                          | 18 +++++++----------
 config/integration.exs                | 12 ++++++++++++
 mix.exs                               | 25 +++++++++++++++++------
 test/elixir/Makefile                  |  4 +++-
 test/elixir/lib/utils.ex              |  5 +++--
 test/elixir/mix.exs                   | 37 -----------------------------------
 test/elixir/mix.lock                  |  9 ---------
 test/elixir/run                       |  6 ------
 test/elixir/test/replication_test.exs |  4 ++--
 test/elixir/test/test_helper.exs      |  8 +++++---
 12 files changed, 67 insertions(+), 93 deletions(-)

diff --git a/.credo.exs b/.credo.exs
index db301e4..2b84a50 100644
--- a/.credo.exs
+++ b/.credo.exs
@@ -29,7 +29,8 @@
           ~r"/src/httpotion",
           ~r"/src/credo",
           ~r"/src/junit_formatter",
-          ~r"/src/bunt"
+          ~r"/src/bunt",
+          ~r"/test/elixir/deps/"
         ]
       },
       #
diff --git a/Makefile b/Makefile
index 3d1be51..58c8148 100644
--- a/Makefile
+++ b/Makefile
@@ -180,11 +180,7 @@ 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
+exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
 	@mix test --trace $(EXUNIT_OPTS)
 
 setup-eunit: export BUILDDIR = $(shell pwd)
@@ -226,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:
-	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:
-	mix credo
+elixir-credo: elixir-init
+	@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 2c4dc98..a5e23d4 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -151,11 +151,7 @@ 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
+exunit: couch elixir-init setup-eunit elixir-check-formatted elixir-credo
 	@mix test --trace $(EXUNIT_OPTS)
 
 setup-eunit: export BUILDDIR = $(shell pwd)
@@ -191,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
diff --git a/config/integration.exs b/config/integration.exs
new file mode 100644
index 0000000..c5a5ed2
--- /dev/null
+++ b/config/integration.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
index d9c8c21..2e213ae 100644
--- a/mix.exs
+++ b/mix.exs
@@ -13,8 +13,8 @@ defmodule CouchDBTest.Mixfile do
       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(),
+      consolidate_protocols: Mix.env() not in [:test, :dev, :integration],
+      test_paths: get_test_paths(Mix.env()),
       elixirc_paths: elixirc_paths(Mix.env())
     ]
   end
@@ -22,26 +22,39 @@ defmodule CouchDBTest.Mixfile do
   # Run "mix help compile.app" to learn about applications.
   def application do
     [
-      extra_applications: [:logger]
+      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], runtime: false},
+      {: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], runtime: false}
+      {:credo, "~> 1.0.0", only: [:dev, :test, :integration], runtime: false}
     ]
   end
 
-  def get_test_paths do
+  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
diff --git a/test/elixir/Makefile b/test/elixir/Makefile
index bfcf017..67ce2b4 100644
--- a/test/elixir/Makefile
+++ b/test/elixir/Makefile
@@ -1,2 +1,4 @@
+SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+
 all:
-	mix test --trace
+	make -C ${SELF_DIR}../.. elixir
diff --git a/test/elixir/lib/utils.ex b/test/elixir/lib/utils.ex
index 4d3f33f..3ecf878 100644
--- a/test/elixir/lib/utils.ex
+++ b/test/elixir/lib/utils.ex
@@ -1,11 +1,12 @@
 defmodule Couch.Test.Utils do
   require Record
   @moduledoc "Helper functions for testing"
+  @project_root "#{__DIR__}/../../../"
   Record.defrecord :user_ctx, Record.extract(
-    :user_ctx, from_lib: "couch/include/couch_db.hrl")
+    :user_ctx, from: "#{@project_root}/src/couch/include/couch_db.hrl")
 
   Record.defrecord :doc_info, Record.extract(
-    :doc_info, from_lib: "couch/include/couch_db.hrl")
+    :doc_info, from: "#{@project_root}/src/couch/include/couch_db.hrl")
 
   def random_name(prefix) do
     time = :erlang.monotonic_time()
diff --git a/test/elixir/mix.exs b/test/elixir/mix.exs
deleted file mode 100644
index f04038e..0000000
--- a/test/elixir/mix.exs
+++ /dev/null
@@ -1,37 +0,0 @@
-defmodule Foo.Mixfile do
-  use Mix.Project
-
-  def project do
-    [
-      app: :foo,
-      version: "0.1.0",
-      elixir: "~> 1.6",
-      elixirc_paths: elixirc_paths(Mix.env()),
-      start_permanent: Mix.env() == :prod,
-      deps: deps()
-    ]
-  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: ["lib", "test/support"]
-  defp elixirc_paths(_), do: ["lib"]
-
-  # Run "mix help deps" to learn about dependencies.
-  defp deps do
-    [
-      # {:dep_from_hexpm, "~> 0.3.0"},
-      {:httpotion, "~> 3.0"},
-      {:jiffy, "~> 0.15.2"},
-      {:credo, "~> 1.0.0", only: [:dev, :test], runtime: false},
-      {:junit_formatter, "~> 3.0", only: [:test]}
-      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
-    ]
-  end
-end
diff --git a/test/elixir/mix.lock b/test/elixir/mix.lock
deleted file mode 100644
index 0fc391a..0000000
--- a/test/elixir/mix.lock
+++ /dev/null
@@ -1,9 +0,0 @@
-%{
-  "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"},
-  "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/test/elixir/run b/test/elixir/run
deleted file mode 100755
index a9c2efa..0000000
--- a/test/elixir/run
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash -e
-cd "$(dirname "$0")"
-mix local.hex --force
-mix local.rebar --force
-mix deps.get
-mix test --trace "$@"
diff --git a/test/elixir/test/replication_test.exs b/test/elixir/test/replication_test.exs
index e98775f..a6e1303 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -1757,11 +1757,11 @@ defmodule ReplicationTest do
   end
 
   def get_att1_data do
-    File.read!("test/data/lorem.txt")
+    File.read!(Path.expand("data/lorem.txt", __DIR__))
   end
 
   def get_att2_data do
-    File.read!("test/data/lorem_b64.txt")
+    File.read!(Path.expand("data/lorem_b64.txt", __DIR__))
   end
 
   def cmp_json(lhs, rhs) when is_map(lhs) and is_map(rhs) do
diff --git a/test/elixir/test/test_helper.exs b/test/elixir/test/test_helper.exs
index ef71bbb..4bf65bc 100644
--- a/test/elixir/test/test_helper.exs
+++ b/test/elixir/test/test_helper.exs
@@ -2,12 +2,14 @@
 # and skip certain tests that fail on jenkins.
 exclude =
   case System.get_env("BUILD_NUMBER") !== nil do
-    true -> [pending: true, skip_on_jenkins: true]
-    false -> [pending: true]
+    true -> [:pending, :skip_on_jenkins]
+    false -> [:pending]
   end
 
+current_exclude = Keyword.get(ExUnit.configuration(), :exclude, [])
+
 ExUnit.configure(
-  exclude: exclude,
+  exclude: Enum.uniq(exclude ++ current_exclude),
   formatters: [JUnitFormatter, ExUnit.CLIFormatter]
 )