Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 769b664

Browse files
committed
Fixing flaky tests
Since I changed the CI jobs, several tests have been failing; One of them was failing because it was testing the wrong thing, let's see if this helps. I also updated the formatting deps so they're coming from the right project
1 parent 11ea670 commit 769b664

8 files changed

Lines changed: 25 additions & 32 deletions

File tree

apps/common/.formatter.exs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
# Used by "mix format"
2-
eventual_assertions = [
3-
assert_eventually: 1,
4-
assert_eventually: 2,
5-
refute_eventually: 1,
6-
refute_eventually: 2
7-
]
8-
92
[
103
inputs: [
114
"{mix,.formatter}.exs",
125
"{config,test}/**/*.{ex,exs}",
136
"lib/lexical/**/*.{ex,ex}",
147
"lib/mix/**/*.{ex,exs}"
15-
],
16-
locals_without_parens: eventual_assertions,
17-
export: [locals_without_parens: eventual_assertions]
8+
]
189
]

apps/plugin_runner/.formatter.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
4+
import_deps: [:lexical_test]
45
]

apps/plugin_runner/mix.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ defmodule Lexical.Plugin.Runner.MixProject do
2828
defp deps do
2929
[
3030
{:common, in_umbrella: true},
31-
{:lexical_plugin, path: "../../projects/lexical_plugin", only: :test}
31+
{:lexical_plugin, path: "../../projects/lexical_plugin", only: :test},
32+
{:lexical_test, path: "../../projects/lexical_test", only: :test},
33+
{:patch, "~> 0.12", only: :test}
3234
]
3335
end
3436

apps/plugin_runner/test/lexical/plugin/runner/coordinator/state_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ defmodule Lexical.Plugin.Coordinator.StateTest do
128128
assert State.failure_count(state, BadReturn) == 1
129129
end
130130

131-
test "a plugin is disabled if it fails 3 times", %{state: state} do
131+
test "a plugin is disabled if it fails 10 times", %{state: state} do
132132
Runner.register(Crashes)
133133

134134
assert :crashes in Runner.enabled_plugins()

apps/plugin_runner/test/lexical/plugin/runner/coordinator_test.exs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule Lexical.Runner.CoordinatorTest do
44
alias Lexical.Project
55

66
use ExUnit.Case
7+
import Lexical.Test.EventualAssertions
78

89
setup do
910
{:ok, _} = start_supervised(Runner.Supervisor)
@@ -113,6 +114,7 @@ defmodule Lexical.Runner.CoordinatorTest do
113114
defp make_it_crash do
114115
for _ <- 1..10 do
115116
Runner.diagnose(%Document{}, notifier())
117+
assert_receive _
116118
end
117119
end
118120

@@ -121,6 +123,7 @@ defmodule Lexical.Runner.CoordinatorTest do
121123

122124
old_pid = Process.whereis(Runner.Coordinator)
123125
assert :exits in Runner.enabled_plugins()
126+
124127
Runner.diagnose(%Document{}, notifier())
125128

126129
assert_receive [], 500
@@ -135,11 +138,7 @@ defmodule Lexical.Runner.CoordinatorTest do
135138

136139
make_it_crash()
137140

138-
assert_receive [], 500
139-
assert_receive [], 500
140-
assert_receive [], 500
141-
142-
refute :crashy in Runner.enabled_plugins()
141+
refute_eventually(:crashy in Runner.enabled_plugins())
143142
end
144143

145144
test "slow plugins are disabled" do
@@ -149,11 +148,7 @@ defmodule Lexical.Runner.CoordinatorTest do
149148

150149
make_it_crash()
151150

152-
assert_receive []
153-
assert_receive []
154-
assert_receive []
155-
156-
refute :slow in Runner.enabled_plugins()
151+
refute_eventually(:slow in Runner.enabled_plugins())
157152
end
158153

159154
test "plugins that don't return lists are disabled" do
@@ -163,11 +158,7 @@ defmodule Lexical.Runner.CoordinatorTest do
163158

164159
make_it_crash()
165160

166-
assert_receive [], 500
167-
assert_receive [], 500
168-
assert_receive [], 500
169-
170-
refute :bad_return in Runner.enabled_plugins()
161+
refute_eventually(:bad_return in Runner.enabled_plugins())
171162
end
172163
end
173164
end

apps/server/.formatter.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Used by "mix format"
22
imported_deps =
33
if Mix.env() == :test do
4-
[:patch, :common]
4+
[:patch, :lexical_test]
55
else
6-
[:common]
6+
[:lexical_test]
77
end
88

99
locals_without_parens = [with_progress: 3]

hooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#! /usr/bin/env bash
2-
mix do format --check-formatted, credo
2+
MIX_ENV=test mix do format --check-formatted, credo
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
4+
export: [
5+
locals_without_parens: [
6+
assert_eventually: 1,
7+
assert_eventually: 2,
8+
refute_eventually: 1,
9+
refute_eventually: 2
10+
]
11+
]
412
]

0 commit comments

Comments
 (0)