From b48c631bb44f67d511e16d2ed1ef798726237c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Mon, 14 Feb 2022 11:41:52 +0100 Subject: [PATCH 1/4] Don't leak IO in tests --- test/ex_type_test.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/ex_type_test.exs b/test/ex_type_test.exs index d092b9d..30d258d 100644 --- a/test/ex_type_test.exs +++ b/test/ex_type_test.exs @@ -1,10 +1,15 @@ defmodule ExTypeTest do use ExUnit.Case + import ExUnit.CaptureIO + + alias ExType.Emoji + doctest ExType test "typespec/**/*_test_case.ex" do for file <- Path.wildcard("#{__DIR__}/ex_type/**/*_test_case.ex") do - ExType.check(file) + result = capture_io(fn -> ExType.check(file) end) + assert String.contains?(result, [Emoji.one_test_pass()]) end end end From 735070c5d006db6fb163bb9bf7d1b255fe59a4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Mon, 14 Feb 2022 11:50:41 +0100 Subject: [PATCH 2/4] Document ex_type_test.exs --- test/ex_type_test.exs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ex_type_test.exs b/test/ex_type_test.exs index 30d258d..2950427 100644 --- a/test/ex_type_test.exs +++ b/test/ex_type_test.exs @@ -1,4 +1,8 @@ defmodule ExTypeTest do + @moduledoc """ + Test whether ex_type can successfully typecheck files without crashing. + """ + use ExUnit.Case import ExUnit.CaptureIO From 7ccba4bddca9b286a426445cbfa5aee6de216455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Mon, 14 Feb 2022 15:57:47 +0100 Subject: [PATCH 3/4] Enable CI on PRs --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d301f0..01b8ad5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: Elixir CI -on: push +on: [push, pull_request] jobs: test: From c67d624837b2f56da320cf0f8585546570049561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Mon, 14 Feb 2022 13:15:01 +0100 Subject: [PATCH 4/4] Make failing type checks test errors, and comment failing tests --- test/ex_type/checker_test_case.ex | 6 +++--- test/ex_type_test.exs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/ex_type/checker_test_case.ex b/test/ex_type/checker_test_case.ex index 33c2747..bff8b9f 100644 --- a/test/ex_type/checker_test_case.ex +++ b/test/ex_type/checker_test_case.ex @@ -1,7 +1,6 @@ defmodule ExType.CheckerTestCase do - require ExType.T - alias ExType.T - + # See https://github.com/gyson/ex_type/issues/47 + _currently_failing_tests = """ @spec test_case_1({:ok, integer()} | :error) :: any() def test_case_1(input) do @@ -32,6 +31,7 @@ defmodule ExType.CheckerTestCase do other end end + """ @spec test_case_3() :: integer() diff --git a/test/ex_type_test.exs b/test/ex_type_test.exs index 2950427..9b0fdbf 100644 --- a/test/ex_type_test.exs +++ b/test/ex_type_test.exs @@ -14,6 +14,7 @@ defmodule ExTypeTest do for file <- Path.wildcard("#{__DIR__}/ex_type/**/*_test_case.ex") do result = capture_io(fn -> ExType.check(file) end) assert String.contains?(result, [Emoji.one_test_pass()]) + refute String.contains?(result, [Emoji.one_test_fail()]) end end end