-
Notifications
You must be signed in to change notification settings - Fork 435
Expand file tree
/
Copy pathOmniSharpTests.cs
More file actions
76 lines (65 loc) · 3.29 KB
/
Copy pathOmniSharpTests.cs
File metadata and controls
76 lines (65 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Security.AccessControl;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
/// <summary>
/// OmniSharp tests to ensure it works with a source-built sdk.
/// </summary>
public class OmniSharpTests : SdkTests
{
// Update version as new releases become available: https://github.com/OmniSharp/omnisharp-roslyn/releases
private const string OmniSharpReleaseVersion = "1.39.14";
private string OmniSharpDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), nameof(OmniSharpTests));
public OmniSharpTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
[SkippableTheory(Config.ExcludeOmniSharpEnv, skipOnTrueEnv: true, skipArchitectures: new[] { "ppc64le", "s390x" })]
[InlineData(DotNetTemplate.BlazorWasm)]
[InlineData(DotNetTemplate.ClassLib)]
[InlineData(DotNetTemplate.Console)]
[InlineData(DotNetTemplate.MSTest)]
[InlineData(DotNetTemplate.Mvc)]
[InlineData(DotNetTemplate.NUnit)]
[InlineData(DotNetTemplate.Web)]
[InlineData(DotNetTemplate.WebApp)]
[InlineData(DotNetTemplate.WebApi)]
[InlineData(DotNetTemplate.Worker)]
[InlineData(DotNetTemplate.XUnit)]
public async void VerifyScenario(DotNetTemplate template)
{
await InitializeOmniSharp();
string templateName = template.GetName();
string projectName = $"{nameof(OmniSharpTests)}_{templateName}";
string projectDirectory = DotNetHelper.ExecuteNew(templateName, projectName);
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess(
DotNetHelper.DotNetPath,
$"{Path.Combine(OmniSharpDirectory, "OmniSharp.dll")} -- -s {projectDirectory}",
OutputHelper,
logOutput: true,
millisecondTimeout: 5000,
configureCallback: (process) => DotNetHelper.ConfigureProcess(process, projectDirectory));
Assert.NotEqual(0, executeResult.Process.ExitCode);
Assert.DoesNotContain("ERROR", executeResult.StdOut);
Assert.DoesNotContain("ERROR", executeResult.StdErr);
Assert.DoesNotContain("command not found", executeResult.StdErr, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("No such file or directory", executeResult.StdErr, StringComparison.OrdinalIgnoreCase);
}
private async Task InitializeOmniSharp()
{
if (!Directory.Exists(OmniSharpDirectory))
{
using HttpClient client = new();
string omniSharpTarballFile = $"omnisharp-linux-{Config.TargetArchitecture}-net6.0.tar.gz";
Uri omniSharpTarballUrl = new($"https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v{OmniSharpReleaseVersion}/{omniSharpTarballFile}");
await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile, OutputHelper);
Directory.CreateDirectory(OmniSharpDirectory);
Utilities.ExtractTarball(omniSharpTarballFile, OmniSharpDirectory, OutputHelper);
}
}
}