|
8 | 8 | using Microsoft.DotNet.Cli.Build; |
9 | 9 | using Microsoft.DotNet.CoreSetup.Test; |
10 | 10 | using Microsoft.DotNet.CoreSetup.Test.HostActivation; |
| 11 | +using Microsoft.DotNet.TestUtils; |
11 | 12 | using Xunit; |
12 | 13 |
|
13 | 14 | namespace HostActivation.Tests |
@@ -168,6 +169,65 @@ public void Info_ListEnvironment_LegacyPrefixDetection() |
168 | 169 | .And.HaveStdOutContaining("Detected COMPlus_* environment variable(s). Consider transitioning to DOTNET_* equivalent."); |
169 | 170 | } |
170 | 171 |
|
| 172 | + [Fact] |
| 173 | + public void Info_GlobalJson_InvalidJson() |
| 174 | + { |
| 175 | + using (TestArtifact workingDir = TestArtifact.Create(nameof(Info_GlobalJson_InvalidJson))) |
| 176 | + { |
| 177 | + string globalJsonPath = GlobalJson.Write(workingDir.Location, "{ \"sdk\": { }"); |
| 178 | + TestContext.BuiltDotNet.Exec("--info") |
| 179 | + .WorkingDirectory(workingDir.Location) |
| 180 | + .CaptureStdOut().CaptureStdErr() |
| 181 | + .Execute() |
| 182 | + .Should().Pass() |
| 183 | + .And.HaveStdOutContaining($"Invalid [{globalJsonPath}]") |
| 184 | + .And.HaveStdOutContaining("JSON parsing exception:") |
| 185 | + .And.NotHaveStdErr(); |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | + [Theory] |
| 190 | + [InlineData("9")] |
| 191 | + [InlineData("9.0")] |
| 192 | + [InlineData("9.0.x")] |
| 193 | + [InlineData("invalid")] |
| 194 | + public void Info_GlobalJson_InvalidData(string version) |
| 195 | + { |
| 196 | + using (TestArtifact workingDir = TestArtifact.Create(nameof(Info_GlobalJson_InvalidData))) |
| 197 | + { |
| 198 | + string globalJsonPath = GlobalJson.CreateWithVersion(workingDir.Location, version); |
| 199 | + TestContext.BuiltDotNet.Exec("--info") |
| 200 | + .WorkingDirectory(workingDir.Location) |
| 201 | + .CaptureStdOut().CaptureStdErr() |
| 202 | + .Execute() |
| 203 | + .Should().Pass() |
| 204 | + .And.HaveStdOutContaining($"Invalid [{globalJsonPath}]") |
| 205 | + .And.HaveStdOutContaining($"Version '{version}' is not valid for the 'sdk/version' value") |
| 206 | + .And.HaveStdOutContaining($"Invalid global.json is ignored for SDK resolution") |
| 207 | + .And.NotHaveStdErr(); |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | + [Theory] |
| 212 | + [InlineData("9.0.0")] |
| 213 | + [InlineData("9.1.99")] |
| 214 | + public void Info_GlobalJson_NonExistentFeatureBand(string version) |
| 215 | + { |
| 216 | + using (TestArtifact workingDir = TestArtifact.Create(nameof(Info_GlobalJson_NonExistentFeatureBand))) |
| 217 | + { |
| 218 | + string globalJsonPath = GlobalJson.CreateWithVersion(workingDir.Location, version); |
| 219 | + var result = TestContext.BuiltDotNet.Exec("--info") |
| 220 | + .WorkingDirectory(workingDir.Location) |
| 221 | + .CaptureStdOut().CaptureStdErr() |
| 222 | + .Execute() |
| 223 | + .Should().Pass() |
| 224 | + .And.HaveStdOutContaining($"Invalid [{globalJsonPath}]") |
| 225 | + .And.HaveStdOutContaining($"Version '{version}' is not valid for the 'sdk/version' value. SDK feature bands start at 1 - for example, {Version.Parse(version).ToString(2)}.100") |
| 226 | + .And.NotHaveStdOutContaining($"Invalid global.json is ignored for SDK resolution") |
| 227 | + .And.NotHaveStdErr(); |
| 228 | + } |
| 229 | + } |
| 230 | + |
171 | 231 | [Fact] |
172 | 232 | public void ListRuntimes() |
173 | 233 | { |
|
0 commit comments