Skip to content

Commit f683589

Browse files
jpnurmiclaude
andcommitted
test: clean up dotnet signal test assertions and comments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1884cab commit f683589

2 files changed

Lines changed: 16 additions & 29 deletions

File tree

tests/fixtures/dotnet_signal/Platforms/Android/MainActivity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ protected override void OnResume()
1818
{
1919
var databasePath = FilesDir?.AbsolutePath + "/.sentry-native";
2020

21-
// Post the test to the main thread's message queue so it runs
22-
// after OnResume returns and the activity is fully started.
21+
// Post to the message queue so the activity finishes starting
22+
// before the crash test runs. Without this, "am start -W" may hang.
2323
new Handler(Looper.MainLooper!).Post(() =>
2424
{
2525
Program.RunTest(new[] { arg }, databasePath);

tests/test_dotnet_signals.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ def test_dotnet_signals_inproc(cmake):
102102
dotnet_run_stdout, dotnet_run_stderr = dotnet_run.communicate()
103103

104104
# the program handles the `NullReferenceException`, so the Native SDK won't register a crash.
105-
assert (
106-
dotnet_run.returncode == 0
107-
), f"Managed exception run failed.\nstdout:\n{dotnet_run_stdout}\nstderr:\n{dotnet_run_stderr}"
108-
assert (
109-
"NullReferenceException" not in dotnet_run_stderr
105+
assert dotnet_run.returncode == 0
106+
assert not (
107+
"NullReferenceException" in dotnet_run_stderr
110108
), f"Managed exception run failed.\nstdout:\n{dotnet_run_stdout}\nstderr:\n{dotnet_run_stderr}"
111109
database_path = project_fixture_path / ".sentry-native"
112110
assert database_path.exists(), "No database-path exists"
@@ -223,11 +221,9 @@ def test_aot_signals_inproc(cmake):
223221
dotnet_run_stdout, dotnet_run_stderr = dotnet_run.communicate()
224222

225223
# the program handles the `NullReferenceException`, so the Native SDK won't register a crash.
226-
assert (
227-
dotnet_run.returncode == 0
228-
), f"Managed exception run failed.\nstdout:\n{dotnet_run_stdout}\nstderr:\n{dotnet_run_stderr}"
229-
assert (
230-
"NullReferenceException" not in dotnet_run_stderr
224+
assert dotnet_run.returncode == 0
225+
assert not (
226+
"NullReferenceException" in dotnet_run_stderr
231227
), f"Managed exception run failed.\nstdout:\n{dotnet_run_stdout}\nstderr:\n{dotnet_run_stderr}"
232228
database_path = tmp_path / ".sentry-native"
233229
assert database_path.exists(), "No database-path exists"
@@ -425,36 +421,27 @@ def has_envelope():
425421

426422
# managed exception: handled, no crash
427423
logcat = run_android_managed_exception()
428-
print("=== managed exception logcat ===\n", logcat)
429-
assert (
430-
"NullReferenceException" not in logcat
431-
), "Managed exception leaked.\nlogcat:\n{}".format(logcat)
432-
assert wait_for(
433-
lambda: dir_exists(db)
434-
), "No database-path exists.\nlogcat:\n{}".format(logcat)
424+
assert not (
425+
"NullReferenceException" in logcat
426+
), f"Managed exception leaked.\nlogcat:\n{logcat}"
427+
assert wait_for(lambda: dir_exists(db)), "No database-path exists"
435428
assert not file_exists(db + "/last_crash"), "A crash was registered"
436429
assert not has_envelope(), "Unexpected envelope found"
437430

438431
# unhandled managed exception: Mono calls exit(1), the native SDK
439432
# should not register a crash (sentry-dotnet handles this at the
440433
# managed layer via UnhandledExceptionRaiser)
441434
logcat = run_android_unhandled_managed_exception()
442-
print("=== unhandled managed exception logcat ===\n", logcat)
443435
assert (
444436
"NullReferenceException" in logcat
445-
), "Expected NullReferenceException.\nlogcat:\n{}".format(logcat)
446-
assert wait_for(
447-
lambda: dir_exists(db)
448-
), "No database-path exists.\nlogcat:\n{}".format(logcat)
437+
), f"Expected NullReferenceException.\nlogcat:\n{logcat}"
438+
assert wait_for(lambda: dir_exists(db)), "No database-path exists"
449439
assert not file_exists(db + "/last_crash"), "A crash was registered"
450440
assert not has_envelope(), "Unexpected envelope found"
451441

452442
# native crash
453-
logcat = run_android_native_crash()
454-
print("=== native crash logcat ===\n", logcat)
455-
assert wait_for(
456-
lambda: file_exists(db + "/last_crash")
457-
), "Crash marker missing.\nlogcat:\n{}".format(logcat)
443+
run_android_native_crash()
444+
assert wait_for(lambda: file_exists(db + "/last_crash")), "Crash marker missing"
458445
assert wait_for(has_envelope), "Crash envelope is missing"
459446

460447
finally:

0 commit comments

Comments
 (0)