Skip to content

Commit 6699668

Browse files
committed
Reorganize test files
1 parent 094ea2f commit 6699668

File tree

10 files changed

+37
-38
lines changed

10 files changed

+37
-38
lines changed

test/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ erl_crash.dump
1717
*.ez
1818

1919
# Ignore package tarball (built via "mix hex.build").
20-
fine_test-*.tar
20+
finest-*.tar
2121

2222
# Temporary files, for example, from tests.
2323
/tmp/

test/Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
PRIV_DIR = $(MIX_APP_PATH)/priv
2-
NIF_PATH = $(PRIV_DIR)/libfine_test.so
1+
PRIV_DIR := $(MIX_APP_PATH)/priv
2+
NIF_PATH := $(PRIV_DIR)/libfinest.so
3+
C_SRC := $(shell pwd)/c_src
34

4-
C_SRC = $(shell pwd)/c_src/fine_test
5-
CPPFLAGS = -shared -fPIC -std=c++17 -Wall -Wextra
5+
CPPFLAGS := -shared -fPIC -std=c++17 -Wall -Wextra
66
CPPFLAGS += -I$(ERTS_INCLUDE_DIR) -I$(FINE_INCLUDE_DIR)
7-
# We want to eliminate all warnings, so the end user doesn't see any
7+
# We want to eliminate all warnings, so the end user doesn't see any.
88
CPPFLAGS += -Werror
99

1010
ifdef DEBUG
@@ -13,21 +13,19 @@ else
1313
CPPFLAGS += -O3
1414
endif
1515

16-
UNAME_S := $(shell uname -s)
1716
ifndef TARGET_ABI
18-
ifeq ($(UNAME_S),Darwin)
19-
TARGET_ABI = darwin
20-
endif
17+
TARGET_ABI := $(shell uname -s | tr '[:upper:]' '[:lower:]')
2118
endif
2219

2320
ifeq ($(TARGET_ABI),darwin)
2421
CPPFLAGS += -undefined dynamic_lookup -flat_namespace
2522
endif
2623

27-
SOURCES = $(wildcard $(C_SRC)/*.cpp)
28-
FINE_HEADERS = $(wildcard $(FINE_INCLUDE_DIR)/*.hpp)
24+
SOURCES := $(wildcard $(C_SRC)/*.cpp)
25+
# We add dependency on Fine header file, since it can change as we test.
26+
FINE_HEADERS := $(wildcard $(FINE_INCLUDE_DIR)/*.hpp)
2927

30-
build: $(NIF_PATH)
28+
all: $(NIF_PATH)
3129
@ echo > /dev/null # Dummy command to avoid the default output "Nothing to be done"
3230

3331
$(NIF_PATH): $(SOURCES) $(FINE_HEADERS)

test/Makefile.win

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
PRIV_DIR=$(MIX_APP_PATH)\priv
2-
NIF_PATH=$(PRIV_DIR)\libfine_test.dll
2+
NIF_PATH=$(PRIV_DIR)\libfinest.dll
3+
C_SRC=$(MAKEDIR)\c_src
34

4-
C_SRC=$(MAKEDIR)\c_src\fine_test
55
CPPFLAGS=/LD /std:c++17 /W4 /O2 /EHsc
66
CPPFLAGS=$(CPPFLAGS) /I"$(ERTS_INCLUDE_DIR)" /I"$(FINE_INCLUDE_DIR)"
7-
# We want to eliminate all warnings, so the end user doesn't see any
7+
# We want to eliminate all warnings, so the end user doesn't see any.
88
CPPFLAGS=$(CPPFLAGS) /WX
99

1010
SOURCES=$(C_SRC)\*.cpp
11+
# We add dependency on Fine header file, since it can change as we test.
1112
FINE_HEADERS=$(FINE_INCLUDE_DIR)\*.hpp
1213

13-
build: $(NIF_PATH)
14+
all: $(NIF_PATH)
1415

1516
$(NIF_PATH): $(SOURCES) $(FINE_HEADERS)
1617
@ if not exist "$(PRIV_DIR)" mkdir "$(PRIV_DIR)"

test/c_src/fine_test/fine_test.cpp renamed to test/c_src/finest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#include <stdexcept>
77
#include <thread>
88

9-
namespace fine_test {
9+
namespace finest {
1010

1111
namespace atoms {
12-
auto ElixirFineTestError = fine::Atom("Elixir.FineTest.Error");
13-
auto ElixirFineTestPoint = fine::Atom("Elixir.FineTest.Point");
12+
auto ElixirFinestError = fine::Atom("Elixir.Finest.Error");
13+
auto ElixirFinestPoint = fine::Atom("Elixir.Finest.Point");
1414
auto data = fine::Atom("data");
1515
auto destructor_with_env = fine::Atom("destructor_with_env");
1616
auto destructor_default = fine::Atom("destructor_default");
@@ -53,7 +53,7 @@ struct ExPoint {
5353
int64_t x;
5454
int64_t y;
5555

56-
static constexpr auto module = &atoms::ElixirFineTestPoint;
56+
static constexpr auto module = &atoms::ElixirFinestPoint;
5757

5858
static constexpr auto fields() {
5959
return std::make_tuple(std::make_tuple(&ExPoint::x, &atoms::x),
@@ -64,7 +64,7 @@ struct ExPoint {
6464
struct ExError {
6565
int64_t data;
6666

67-
static constexpr auto module = &atoms::ElixirFineTestError;
67+
static constexpr auto module = &atoms::ElixirFinestError;
6868

6969
static constexpr auto fields() {
7070
return std::make_tuple(std::make_tuple(&ExError::data, &atoms::data));
@@ -214,6 +214,6 @@ int64_t raise_erlang_error(ErlNifEnv *env) {
214214
}
215215
FINE_NIF(raise_erlang_error, 0);
216216

217-
} // namespace fine_test
217+
} // namespace finest
218218

219-
FINE_INIT("Elixir.FineTest.NIF");
219+
FINE_INIT("Elixir.Finest.NIF");

test/lib/fine_test/point.ex

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/lib/fine_test/error.ex renamed to test/lib/finest/error.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule FineTest.Error do
1+
defmodule Finest.Error do
22
defexception [:data]
33

44
@impl true

test/lib/fine_test/nif.ex renamed to test/lib/finest/nif.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
defmodule FineTest.NIF do
1+
defmodule Finest.NIF do
22
@moduledoc false
33

44
@on_load :__on_load__
55

66
def __on_load__ do
7-
path = :filename.join(:code.priv_dir(:fine_test), ~c"libfine_test")
7+
path = :filename.join(:code.priv_dir(:finest), ~c"libfinest")
88

99
case :erlang.load_nif(path, 0) do
1010
:ok -> :ok

test/lib/finest/point.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
defmodule Finest.Point do
2+
defstruct [:x, :y]
3+
end

test/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
defmodule FineTest.MixProject do
1+
defmodule Finest.MixProject do
22
use Mix.Project
33

44
def project do
55
[
6-
app: :fine_test,
6+
app: :finest,
77
version: "0.1.0",
88
elixir: "~> 1.15",
99
start_permanent: Mix.env() == :prod,

test/test/fine_test_test.exs renamed to test/test/finest_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
defmodule FineTestTest do
1+
defmodule FinestTest do
22
use ExUnit.Case, async: true
33

4-
alias FineTest.NIF
4+
alias Finest.NIF
55

66
test "add" do
77
assert NIF.add(1, 2) == 3
@@ -172,7 +172,7 @@ defmodule FineTestTest do
172172
end
173173

174174
test "struct" do
175-
struct = %FineTest.Point{x: 1, y: 2}
175+
struct = %Finest.Point{x: 1, y: 2}
176176
assert NIF.codec_struct(struct) == struct
177177

178178
assert_raise ArgumentError, "decode failed, expected a struct", fn ->
@@ -183,13 +183,13 @@ defmodule FineTestTest do
183183
NIF.codec_struct(%{})
184184
end
185185

186-
assert_raise ArgumentError, "decode failed, expected a Elixir.FineTest.Point struct", fn ->
186+
assert_raise ArgumentError, "decode failed, expected a Elixir.Finest.Point struct", fn ->
187187
NIF.codec_struct(~D"2000-01-01")
188188
end
189189
end
190190

191191
test "exception struct" do
192-
struct = %FineTest.Error{data: 1}
192+
struct = %Finest.Error{data: 1}
193193
assert NIF.codec_struct_exception(struct) == struct
194194
assert is_exception(NIF.codec_struct_exception(struct))
195195

@@ -240,7 +240,7 @@ defmodule FineTestTest do
240240
end
241241

242242
test "raising an elixir exception" do
243-
assert_raise FineTest.Error, "got error with data 10", fn ->
243+
assert_raise Finest.Error, "got error with data 10", fn ->
244244
NIF.raise_elixir_exception()
245245
end
246246
end

0 commit comments

Comments
 (0)