-
Notifications
You must be signed in to change notification settings - Fork 561
[tests] Stop disabling nullability. #25044
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
base: dev/rolf/src-nullability-misc
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| using System.Text; | ||
| using Xamarin.Utils; | ||
|
|
||
| #nullable disable // until we get around to fixing this file | ||
| #nullable enable | ||
|
|
||
| namespace Xamarin.Tests { | ||
| class XBuild { | ||
|
|
@@ -12,17 +12,17 @@ public static string ToolPath { | |
| } | ||
| } | ||
|
|
||
| public static string BuildXM (string project, string configuration = "Debug", string platform = "x86", string verbosity = null, TimeSpan? timeout = null, string [] arguments = null, string targets = "Clean,Build") | ||
| public static string BuildXM (string project, string configuration = "Debug", string platform = "x86", string? verbosity = null, TimeSpan? timeout = null, string []? arguments = null, string targets = "Clean,Build") | ||
| { | ||
| return Build (project, ApplePlatform.MacOSX, configuration, platform, verbosity, timeout, arguments, targets); | ||
| } | ||
|
|
||
| public static string BuildXI (string project, string configuration = "Debug", string platform = "iPhoneSimulator", string verbosity = null, TimeSpan? timeout = null, string [] arguments = null, string targets = "Clean,Build") | ||
| public static string BuildXI (string project, string configuration = "Debug", string platform = "iPhoneSimulator", string? verbosity = null, TimeSpan? timeout = null, string []? arguments = null, string targets = "Clean,Build") | ||
| { | ||
| return Build (project, ApplePlatform.iOS, configuration, platform, verbosity, timeout, arguments, targets); | ||
| } | ||
|
|
||
| static string Build (string project, ApplePlatform applePlatform, string configuration = "Debug", string platform = "iPhoneSimulator", string verbosity = null, TimeSpan? timeout = null, string [] arguments = null, string targets = "Clean,Build") | ||
| static string Build (string project, ApplePlatform applePlatform, string configuration = "Debug", string platform = "iPhoneSimulator", string? verbosity = null, TimeSpan? timeout = null, string []? arguments = null, string targets = "Clean,Build") | ||
| { | ||
| return ExecutionHelper.Execute (ToolPath, | ||
| new string [] { | ||
|
|
@@ -50,7 +50,7 @@ public static int Execute (string fileName, IList<string> arguments, TimeSpan? t | |
| return Execute (fileName, arguments, null, null, null, timeout); | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, string working_directory = null, Action<string> stdout_callback = null, Action<string> stderr_callback = null, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, string? working_directory = null, Action<string>? stdout_callback = null, Action<string>? stderr_callback = null, TimeSpan? timeout = null) | ||
| { | ||
| return Execute (fileName, arguments, timed_out: out var _, workingDirectory: working_directory, stdout_callback: stdout_callback, stderr_callback: stderr_callback, timeout: timeout); | ||
| } | ||
|
|
@@ -60,19 +60,19 @@ public static int Execute (string fileName, IList<string> arguments, out StringB | |
| return Execute (fileName, arguments, out output, null, null); | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, out StringBuilder output, string working_directory, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, out StringBuilder output, string? working_directory, TimeSpan? timeout = null) | ||
| { | ||
| output = new StringBuilder (); | ||
| return Execute (fileName, arguments, out var _, workingDirectory: working_directory, stdout: output, stderr: output, timeout: timeout); | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, out StringBuilder output, string working_directory, Dictionary<string, string> environment_variables, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, out StringBuilder output, string? working_directory, Dictionary<string, string?>? environment_variables, TimeSpan? timeout = null) | ||
| { | ||
| output = new StringBuilder (); | ||
| return Execute (fileName, arguments, out var _, workingDirectory: working_directory, stdout: output, stderr: output, timeout: timeout, environment_variables: environment_variables); | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, out bool timed_out, string workingDirectory = null, Dictionary<string, string> environment_variables = null, StringBuilder stdout = null, StringBuilder stderr = null, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, out bool timed_out, string? workingDirectory = null, Dictionary<string, string?>? environment_variables = null, StringBuilder? stdout = null, StringBuilder? stderr = null, TimeSpan? timeout = null) | ||
| { | ||
| var rv = Execution.RunAsync (fileName, arguments, workingDirectory: workingDirectory, environment: environment_variables, timeout: timeout).Result; | ||
| if (stdout is not null) | ||
|
|
@@ -81,11 +81,11 @@ public static int Execute (string fileName, IList<string> arguments, out bool ti | |
| stderr.Append (rv.Output.StandardError); | ||
| timed_out = rv.TimedOut; | ||
| if (rv.TimedOut) | ||
| Console.WriteLine ($"Command '{fileName} {StringUtils.FormatArguments (arguments)}' didn't finish in {timeout.Value.TotalMilliseconds} ms, and was killed.", timeout.Value.TotalMinutes); | ||
| Console.WriteLine ($"Command '{fileName} {StringUtils.FormatArguments (arguments)}' didn't finish in {timeout!.Value.TotalMilliseconds} ms, and was killed.", timeout!.Value.TotalMinutes); | ||
| return rv.ExitCode; | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, out bool timed_out, string workingDirectory = null, Dictionary<string, string> environment_variables = null, Action<string> stdout_callback = null, Action<string> stderr_callback = null, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, out bool timed_out, string? workingDirectory = null, Dictionary<string, string?>? environment_variables = null, Action<string>? stdout_callback = null, Action<string>? stderr_callback = null, TimeSpan? timeout = null) | ||
| { | ||
| if (stdout_callback is null) | ||
| stdout_callback = Console.WriteLine; | ||
|
|
@@ -95,24 +95,24 @@ public static int Execute (string fileName, IList<string> arguments, out bool ti | |
| var rv = Execution.RunWithCallbacksAsync (fileName, arguments, workingDirectory: workingDirectory, environment: environment_variables, standardOutput: stdout_callback, standardError: stderr_callback, timeout: timeout).Result; | ||
| timed_out = rv.TimedOut; | ||
| if (rv.TimedOut) | ||
| Console.WriteLine ($"Command '{fileName} {StringUtils.FormatArguments (arguments)}' didn't finish in {timeout.Value.TotalMilliseconds} ms, and was killed.", timeout.Value.TotalMinutes); | ||
| Console.WriteLine ($"Command '{fileName} {StringUtils.FormatArguments (arguments)}' didn't finish in {timeout!.Value.TotalMilliseconds} ms, and was killed.", timeout!.Value.TotalMinutes); | ||
|
||
| return rv.ExitCode; | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, out string output, TimeSpan? timeout = null) | ||
| public static int Execute (string fileName, IList<string> arguments, out string? output, TimeSpan? timeout = null) | ||
| { | ||
| var sb = new StringBuilder (); | ||
| var rv = Execute (fileName, arguments, timed_out: out var _, stdout: sb, stderr: sb, timeout: timeout); | ||
| output = sb.ToString (); | ||
| return rv; | ||
| } | ||
|
|
||
| public static int Execute (string fileName, IList<string> arguments, Dictionary<string, string> environmentVariables, StringBuilder stdout, StringBuilder stderr, TimeSpan? timeout = null, string workingDirectory = null) | ||
| public static int Execute (string fileName, IList<string> arguments, Dictionary<string, string?>? environmentVariables, StringBuilder? stdout, StringBuilder? stderr, TimeSpan? timeout = null, string? workingDirectory = null) | ||
| { | ||
| return Execute (fileName, arguments, timed_out: out var _, workingDirectory: workingDirectory, environment_variables: environmentVariables, stdout: stdout, stderr: stderr, timeout: timeout); | ||
| } | ||
|
|
||
| public static string Execute (string fileName, IList<string> arguments, bool throwOnError = true, Dictionary<string, string> environmentVariables = null, bool hide_output = false, TimeSpan? timeout = null) | ||
| public static string Execute (string fileName, IList<string> arguments, bool throwOnError = true, Dictionary<string, string?>? environmentVariables = null, bool hide_output = false, TimeSpan? timeout = null) | ||
| { | ||
| var rv = Execution.RunAsync (fileName, arguments, environment: environmentVariables, timeout: timeout).Result; | ||
| var output = rv.Output.MergedOutput; | ||
|
|
||
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.
This
Console.WriteLinecall passes an extra argument (timeout!.Value.TotalMinutes) that isn’t used by the interpolated string, and it also null-forgivestimeout. Either include the value in the message (add a placeholder/text) or remove the extra argument, and avoidtimeout!by handling thetimeout is nullcase.