commit: 5174c29d4c8475d93f5635c56251064a415b1f57
parent ccf476a4c83771dc573ba474562b847367308291
Author: feld <feld@feld.me>
Date: Tue, 13 Aug 2024 20:16:09 +0000
Merge branch 'fix-random-test-errors' into 'develop'
Fix random test failures, revert auto-retry failed tests
See merge request pleroma/pleroma!4221
Diffstat:
4 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
@@ -133,7 +133,7 @@ unit-testing-1.13.4-otp-25:
script: &testing_script
- mix ecto.create
- mix ecto.migrate
- - mix pleroma.test_runner --cover --preload-modules
+ - mix test --cover --preload-modules
coverage: '/^Line total: ([^ ]*%)$/'
artifacts:
reports:
diff --git a/changelog.d/fix-test-failures.skip b/changelog.d/fix-test-failures.skip
diff --git a/lib/mix/tasks/pleroma/test_runner.ex b/lib/mix/tasks/pleroma/test_runner.ex
@@ -1,25 +0,0 @@
-defmodule Mix.Tasks.Pleroma.TestRunner do
- @shortdoc "Retries tests once if they fail"
-
- use Mix.Task
-
- def run(args \\ []) do
- case System.cmd("mix", ["test"] ++ args, into: IO.stream(:stdio, :line)) do
- {_, 0} ->
- :ok
-
- _ ->
- retry(args)
- end
- end
-
- def retry(args) do
- case System.cmd("mix", ["test", "--failed"] ++ args, into: IO.stream(:stdio, :line)) do
- {_, 0} ->
- :ok
-
- _ ->
- exit(1)
- end
- end
-end
diff --git a/test/mix/tasks/pleroma/uploads_test.exs b/test/mix/tasks/pleroma/uploads_test.exs
@@ -3,12 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.UploadsTest do
+ alias Pleroma.Config
alias Pleroma.Upload
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: false
import Mock
setup_all do
+ prep_uploads()
Mix.shell(Mix.Shell.Process)
on_exit(fn ->
@@ -18,6 +20,8 @@ defmodule Mix.Tasks.Pleroma.UploadsTest do
:ok
end
+ setup do: clear_config([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)
+
describe "running migrate_local" do
test "uploads migrated" do
with_mock Upload,
@@ -53,4 +57,15 @@ defmodule Mix.Tasks.Pleroma.UploadsTest do
end
end
end
+
+ defp prep_uploads do
+ upload_dir = Config.get([Pleroma.Uploaders.Local, :uploads])
+
+ if not File.exists?(upload_dir) || File.ls!(upload_dir) == [] do
+ File.mkdir_p(upload_dir)
+
+ Path.join([upload_dir, "file.txt"])
+ |> File.touch()
+ end
+ end
end