Hide logs during test unless a test fails

Currently `mix test` prints a slew of logs in the terminal
with messages from different tests intermsparsed. Globally
enabling capture log hides log messages unless a test fails
reducing noise and making it easier to anylse the important
(from failed tests) messages.

Compiler warnings and a few messages not printed via Logger
still show up but its much more readable than before.

Ported from: 3aed111a42
This commit is contained in:
Mark Felder 2024-06-18 10:50:31 -04:00 committed by Oneric
parent 0ab2f2ab45
commit 07539f7825
14 changed files with 5 additions and 22 deletions

View file

@ -51,7 +51,6 @@ test "error if file with custom settings doesn't exist" do
clear_config(:configurable_from_database, true) clear_config(:configurable_from_database, true)
end end
@tag capture_log: true
test "config migration refused when deprecated settings are found" do test "config migration refused when deprecated settings are found" do
clear_config([:media_proxy, :whitelist], ["domain_without_scheme.com"]) clear_config([:media_proxy, :whitelist], ["domain_without_scheme.com"])
assert config_records() == [] assert config_records() == []

View file

@ -189,7 +189,6 @@ defp spoofed_object_with_ids(
:ok :ok
end end
@tag capture_log: true
test "it works when fetching the OP actor errors out" do test "it works when fetching the OP actor errors out" do
# Here we simulate a case where the author of the OP can't be read # Here we simulate a case where the author of the OP can't be read
assert {:ok, _} = assert {:ok, _} =

View file

@ -814,7 +814,6 @@ test "gets an existing user by fully qualified nickname, case insensitive" do
assert user == fetched_user assert user == fetched_user
end end
@tag capture_log: true
test "returns nil if no user could be fetched" do test "returns nil if no user could be fetched" do
{:error, fetched_user} = User.get_or_fetch_by_nickname("nonexistant@social.heldscal.la") {:error, fetched_user} = User.get_or_fetch_by_nickname("nonexistant@social.heldscal.la")
assert fetched_user == "not found nonexistant@social.heldscal.la" assert fetched_user == "not found nonexistant@social.heldscal.la"
@ -871,7 +870,6 @@ test "if nicknames clash, the old user gets a prefix with the old id to the nick
assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org" assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
end end
@tag capture_log: true
test "it returns the old user if stale, but unfetchable" do test "it returns the old user if stale, but unfetchable" do
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800) a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)

View file

@ -573,7 +573,6 @@ test "it inserts an incoming activity into the database", %{conn: conn} do
assert Activity.get_by_ap_id(data["id"]) assert Activity.get_by_ap_id(data["id"])
end end
@tag capture_log: true
test "it inserts an incoming activity into the database" <> test "it inserts an incoming activity into the database" <>
"even if we can't fetch the user but have it in our db", "even if we can't fetch the user but have it in our db",
%{conn: conn} do %{conn: conn} do
@ -1074,7 +1073,6 @@ test "it clears `unreachable` federation status of the sender", %{conn: conn, da
assert Instances.reachable?(sender_host) assert Instances.reachable?(sender_host)
end end
@tag capture_log: true
test "it removes all follower collections but actor's", %{conn: conn} do test "it removes all follower collections but actor's", %{conn: conn} do
[actor, recipient] = insert_pair(:user) [actor, recipient] = insert_pair(:user)
@ -1138,7 +1136,6 @@ test "it requires authentication", %{conn: conn} do
assert json_response(ret_conn, 200) assert json_response(ret_conn, 200)
end end
@tag capture_log: true
test "forwarded report", %{conn: conn} do test "forwarded report", %{conn: conn} do
admin = insert(:user, is_admin: true) admin = insert(:user, is_admin: true)
actor = insert(:user, local: false) actor = insert(:user, local: false)
@ -1215,7 +1212,6 @@ test "forwarded report", %{conn: conn} do
) )
end end
@tag capture_log: true
test "forwarded report from mastodon", %{conn: conn} do test "forwarded report from mastodon", %{conn: conn} do
admin = insert(:user, is_admin: true) admin = insert(:user, is_admin: true)
actor = insert(:user, local: false) actor = insert(:user, local: false)

View file

@ -114,7 +114,6 @@ test "returns error when activity not `Create` type" do
assert Relay.publish(activity) == {:error, "Not implemented"} assert Relay.publish(activity) == {:error, "Not implemented"}
end end
@tag capture_log: true
test "returns error when activity not public" do test "returns error when activity not public" do
activity = insert(:direct_note_activity) activity = insert(:direct_note_activity)
assert Relay.publish(activity) == {:error, false} assert Relay.publish(activity) == {:error, false}

View file

@ -83,7 +83,6 @@ test "it works for incoming announces, fetching the announced object" do
assert(Activity.get_create_by_object_ap_id(data["object"])) assert(Activity.get_create_by_object_ap_id(data["object"]))
end end
@tag capture_log: true
test "it works for incoming announces with an existing activity" do test "it works for incoming announces with an existing activity" do
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "hey"}) {:ok, activity} = CommonAPI.post(user, %{status: "hey"})
@ -136,7 +135,6 @@ test "it works for incoming announces with an inlined activity" do
assert object.data["content"] == "this is a private toot" assert object.data["content"] == "this is a private toot"
end end
@tag capture_log: true
test "it rejects incoming announces with an inlined activity from another origin" do test "it rejects incoming announces with an inlined activity from another origin" do
Tesla.Mock.mock(fn Tesla.Mock.mock(fn
%{method: :get} -> %Tesla.Env{status: 404, body: ""} %{method: :get} -> %Tesla.Env{status: 404, body: ""}

View file

@ -86,7 +86,6 @@ test "it fails for incoming deletes with spoofed origin" do
assert match?({:error, _}, Transmogrifier.handle_incoming(data)) assert match?({:error, _}, Transmogrifier.handle_incoming(data))
end end
@tag capture_log: true
test "it works for incoming user deletes" do test "it works for incoming user deletes" do
%{ap_id: ap_id} = insert(:user, ap_id: "http://mastodon.example.org/users/admin") %{ap_id: ap_id} = insert(:user, ap_id: "http://mastodon.example.org/users/admin")

View file

@ -57,7 +57,6 @@ test "it ignores an incoming notice if we already have it" do
assert activity == returned_activity assert activity == returned_activity
end end
@tag capture_log: true
test "it fetches reply-to activities if we don't have them" do test "it fetches reply-to activities if we don't have them" do
data = data =
File.read!("test/fixtures/mastodon-post-activity.json") File.read!("test/fixtures/mastodon-post-activity.json")
@ -537,7 +536,6 @@ test "returns object with inReplyTo when denied incoming reply", %{data: data} d
assert modified_object["inReplyTo"] == [] assert modified_object["inReplyTo"] == []
end end
@tag capture_log: true
test "returns modified object when allowed incoming reply", %{data: data} do test "returns modified object when allowed incoming reply", %{data: data} do
object_with_reply = object_with_reply =
Map.put( Map.put(

View file

@ -561,7 +561,6 @@ test "returns nil when cannot normalize object" do
end) =~ ":valid_uri_scheme" end) =~ ":valid_uri_scheme"
end end
@tag capture_log: true
test "returns {:ok, %Object{}} for success case" do test "returns {:ok, %Object{}} for success case" do
assert {:ok, %Object{}} = assert {:ok, %Object{}} =
Transmogrifier.get_obj_helper( Transmogrifier.get_obj_helper(

View file

@ -79,7 +79,6 @@ test "search", %{conn: conn} do
assert status["id"] == to_string(activity.id) assert status["id"] == to_string(activity.id)
end end
@tag capture_log: true
test "constructs hashtags from search query", %{conn: conn} do test "constructs hashtags from search query", %{conn: conn} do
results = results =
conn conn

View file

@ -152,7 +152,6 @@ test "filtering", %{conn: conn, user: user} do
end end
describe "public" do describe "public" do
@tag capture_log: true
test "the public timeline", %{conn: conn} do test "the public timeline", %{conn: conn} do
user = insert(:user) user = insert(:user)
@ -810,7 +809,6 @@ test "filtering", %{user: user, conn: conn} do
describe "hashtag" do describe "hashtag" do
setup do: oauth_access(["n/a"]) setup do: oauth_access(["n/a"])
@tag capture_log: true
test "hashtag timeline", %{conn: conn} do test "hashtag timeline", %{conn: conn} do
following = insert(:user) following = insert(:user)

View file

@ -67,7 +67,6 @@ test "performs sending notifications" do
assert Impl.perform(notif) == {:ok, [:ok, :ok]} assert Impl.perform(notif) == {:ok, [:ok, :ok]}
end end
@tag capture_log: true
test "returns error if notif does not match " do test "returns error if notif does not match " do
assert Impl.perform(%{}) == {:error, :unknown_type} assert Impl.perform(%{}) == {:error, :unknown_type}
end end
@ -76,7 +75,6 @@ test "successful message sending" do
assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok assert Impl.push_message(@message, @sub, @api_key, %Subscription{}) == :ok
end end
@tag capture_log: true
test "fail message sending" do test "fail message sending" do
assert Impl.push_message( assert Impl.push_message(
@message, @message,

View file

@ -190,7 +190,6 @@ test "prevents spoofing" do
end end
end end
@tag capture_log: true
test "prevents forgeries" do test "prevents forgeries" do
Tesla.Mock.mock(fn Tesla.Mock.mock(fn
%{url: "https://bad.com/.well-known/webfinger?resource=acct:meanie@bad.com"} -> %{url: "https://bad.com/.well-known/webfinger?resource=acct:meanie@bad.com"} ->

View file

@ -3,7 +3,11 @@
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
os_exclude = if :os.type() == {:unix, :darwin}, do: [skip_on_mac: true], else: [] os_exclude = if :os.type() == {:unix, :darwin}, do: [skip_on_mac: true], else: []
ExUnit.start(exclude: [:federated, :erratic] ++ os_exclude)
ExUnit.start(
capture_log: true,
exclude: [:federated, :erratic] ++ os_exclude
)
Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, :manual) Ecto.Adapters.SQL.Sandbox.mode(Pleroma.Repo, :manual)