Skip to content

Commit

Permalink
Fix mix test and mix dialyzer repeated runs
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanRublev committed Jun 12, 2022
1 parent ba9e28d commit 14aad77
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
23 changes: 18 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report
about: Create a report to help us improve
about: Create a report to help us improve Domo
title: ''
labels: ''
assignees: ''
Expand All @@ -11,16 +11,29 @@ assignees: ''

* Elixir version (elixir -v):
* Domo version (mix deps | grep domo | head -1):
* TypedStruct version (mix deps | grep typed_struct | head -1):

### Actual behavior

<!--
Describe the actual behaviour. If you are seeing an error, include the full message and stacktrace. If you can provide a link to sample app that reproduces the behaviour, even better!
-->

### Expected behavior

<!--
Describe what's expected.
-->

### Verbose output

<!--
Run the following command in your project's directory:
mix clean && mix compile --verbose
Describe the actual behaviour. If you are seeing an error, include the full message and stacktrace. If you can provide a link to sample app that reproduces the behaviour, even better!
-->
If the bug happens during the test, then run the command in the test environment like the following:
### Expected behavior
MIX_ENV=test mix clean && mix compile --verbose
Attach the output.
-->
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,10 @@ F.e. with `validate_required/2` call in the `Ecto` changeset.

## Changelog

### v1.5.5 (2022-06-12)

* Fix to repeatedly run `mix test` and `mix dialyzer` without crashes.

### v1.5.4 (2022-05-23)

* Fix to reenable the support of Phoenix hot-reload. If you use it then, please, add `:domo_phoenix_hot_reload` after `:elixir` to `compilers` list in the mix.exs file and to `reloadable_compilers` list in the config file.
Expand Down
2 changes: 1 addition & 1 deletion example_avialia/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ config :example_avialia, ExampleAvialiaWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
reloadable_compilers: [:phoenix, :domo_compiler] ++ Mix.compilers(),
reloadable_compilers: [:phoenix, :domo_compiler] ++ Mix.compilers() ++ [:domo_phoenix_hot_reload],
check_origin: false,
watchers: [
node: [
Expand Down
2 changes: 1 addition & 1 deletion example_avialia/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule ExampleAvialia.MixProject do
version: "0.1.0",
elixir: "~> 1.11",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :domo_compiler] ++ Mix.compilers(),
compilers: [:phoenix, :domo_compiler] ++ Mix.compilers() ++ [:domo_phoenix_hot_reload],
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
Expand Down
16 changes: 15 additions & 1 deletion lib/domo/type_ensurer_factory/dependency_resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ defmodule Domo.TypeEnsurerFactory.DependencyResolver do
defp maybe_cleanup_preconds(preconds_path, preconds, file_module) do
updated_preconds =
Enum.reduce(preconds, %{}, fn {module, type_precond_description}, map ->
if Kernel.function_exported?(module, :__precond__, 2) do
if Code.ensure_loaded?(module) and Kernel.function_exported?(module, :__precond__, 2) do
Map.put(map, module, type_precond_description)
else
map
Expand Down Expand Up @@ -253,8 +253,22 @@ defmodule Domo.TypeEnsurerFactory.DependencyResolver do
# and make elixir compiler to percept them as stale files.
Process.sleep(1000)

if verbose? do
IO.write("""
Domo marks files for recompilation by touching:
#{Enum.join(sources_to_recompile, "\n")}
""")
end

Enum.each(sources_to_recompile, &File.touch!/1)

if verbose? do
IO.write("""
Domo meets Elixir's criteria for recompilation by removing:
#{Enum.join(beams_to_recompile, "\n")}
""")
end

# Since v1.13 Elixir expects missing .beam to recompile from source
Enum.each(beams_to_recompile, &File.rm/1)

Expand Down
10 changes: 6 additions & 4 deletions lib/domo/type_ensurer_factory/resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ defmodule Domo.TypeEnsurerFactory.Resolver do
{:ok, fields_envs} ->
modules_count = map_size(fields)

IO.puts("""
Domo is compiling type ensurer for #{to_string(modules_count)} \
module#{if modules_count > 1, do: "s"} (.ex)\
""")
if modules_count > 0 do
IO.puts("""
Domo is compiling type ensurer for #{to_string(modules_count)} \
module#{if modules_count > 1, do: "s"} (.ex)\
""")
end

anys_by_module = plan[:anys_by_module]

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Domo.MixProject do
use Mix.Project

@version "1.5.4"
@version "1.5.5"
@repo_url "https://github.com/IvanRublev/Domo"

def project do
Expand Down

0 comments on commit 14aad77

Please sign in to comment.