-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[corefoundation] Fix TypeInitializationException in OSLog #7962
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
using CoreFoundation; | ||
using Foundation; | ||
using ObjCRuntime; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace MonoTouchFixtures.CoreFoundation { | ||
|
||
[TestFixture] | ||
[Preserve (AllMembers = true)] | ||
public class OSLogTest { | ||
|
||
[TestFixtureSetUp] | ||
public void SetUp () | ||
{ | ||
TestRuntime.AssertXcodeVersion (8,0); | ||
} | ||
|
||
[Test] | ||
public void Default () | ||
{ | ||
OSLog.Default.Log (OSLogLevel.Default, "monotouch-test / Default / Default"); | ||
// this will show in the application output (e.g. inside VSfM) | ||
} | ||
|
||
[Test] | ||
public void Custom () | ||
{ | ||
using (var log = new OSLog ("subsystem", "category")) { | ||
log.Log (OSLogLevel.Error, "monotouch-test / custom / Debug"); | ||
// this will show in the application output (e.g. inside VSfM) | ||
// and also inside Console.app under the simulator/device | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No Asserts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as it does to crash or throw here :P I think this is fine #YOLO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mandel-macaque not quite sure on what to assert (if it does not crash, like it would without the fix). Reading console.app is a quite troublesome from simulator and would not work on devices. Got any ideas ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is a way with http://www.cplusplus.com/reference/cstdio/freopen/ freopen stderr to a file, read wha was logged in the file. Maybe too much work :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with "not crashing is good enough". I could see redirects being brittle maybe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I won't stop you PR'ing that... but, for myself, messing with stderr, which is already used used by the test harness, seems more a problem than a solution :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a precedent for redirecting stderr... https://github.com/xamarin/maccore/blob/4c92d05de776e6166648f57ff26a5efab8c06363/tools/mlaunch/Xamarin.Hosting/Xamarin.Launcher/InstallationProxyService.cs#L95-L109 |
||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need a version check to avoid this test on older OSes.