Skip to content

Commit

Permalink
[tests] Add a TestRuntime.NSLog function for easier debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Jun 12, 2023
1 parent fa8594e commit c414b23
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/common/TestRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,19 @@ public string Description {
public unsafe static bool IsARM64 {
get { return NXGetLocalArchInfo ()->Name.StartsWith ("arm64"); }
}

[DllImport ("__Internal")]
extern static void xamarin_log (IntPtr s);

// Calling Console.WriteLine from inside a test is rather annoying, because NUnit captures stdout and only
// shows it at the end of the test. That's not very helpful when the test crashing, or while debugging
// a test.
internal static void NSLog (string value)
{
var valuePtr = Marshal.StringToHGlobalUni (value);
xamarin_log (valuePtr);
Marshal.FreeHGlobal (valuePtr);
}
}

#if NET
Expand Down

0 comments on commit c414b23

Please sign in to comment.