2022-03-03 08:02:48 -06:00
|
|
|
// 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;
|
2023-06-22 22:11:11 +00:00
|
|
|
using System.Security.AccessControl;
|
2022-03-03 08:02:48 -06:00
|
|
|
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>
|
2023-10-12 09:28:42 -05:00
|
|
|
public class OmniSharpTests : SdkTests
|
2022-03-03 08:02:48 -06:00
|
|
|
{
|
2023-07-27 13:51:11 -05:00
|
|
|
// Update version as new releases become available: https://github.com/OmniSharp/omnisharp-roslyn/releases
|
2024-01-02 09:28:29 -06:00
|
|
|
private const string OmniSharpReleaseVersion = "1.39.11";
|
2023-07-27 13:51:11 -05:00
|
|
|
|
2023-09-06 14:51:12 -07:00
|
|
|
private string OmniSharpDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), nameof(OmniSharpTests));
|
2022-03-03 08:02:48 -06:00
|
|
|
|
|
|
|
public OmniSharpTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
|
|
|
|
|
2023-08-28 20:02:11 +05:30
|
|
|
[SkippableTheory(Config.ExcludeOmniSharpEnv, skipOnTrueEnv: true, skipArchitectures: new[] { "ppc64le", "s390x" })]
|
2022-03-03 08:02:48 -06:00
|
|
|
[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(
|
|
|
|
Path.Combine(OmniSharpDirectory, "run"),
|
|
|
|
$"-s {projectDirectory}",
|
|
|
|
OutputHelper,
|
|
|
|
logOutput: true,
|
|
|
|
millisecondTimeout: 5000,
|
2023-08-23 06:29:20 -07:00
|
|
|
configureCallback: (process) => DotNetHelper.ConfigureProcess(process, projectDirectory));
|
2022-03-03 08:02:48 -06:00
|
|
|
|
|
|
|
Assert.NotEqual(0, executeResult.Process.ExitCode);
|
|
|
|
Assert.DoesNotContain("ERROR", executeResult.StdOut);
|
|
|
|
Assert.DoesNotContain("ERROR", executeResult.StdErr);
|
|
|
|
}
|
|
|
|
|
|
|
|
private async Task InitializeOmniSharp()
|
|
|
|
{
|
|
|
|
if (!Directory.Exists(OmniSharpDirectory))
|
|
|
|
{
|
|
|
|
using HttpClient client = new();
|
2022-04-14 16:20:25 -05:00
|
|
|
string omniSharpTarballFile = $"omnisharp-linux-{Config.TargetArchitecture}.tar.gz";
|
2023-07-27 13:51:11 -05:00
|
|
|
Uri omniSharpTarballUrl = new($"https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v{OmniSharpReleaseVersion}/{omniSharpTarballFile}");
|
2022-04-14 16:20:25 -05:00
|
|
|
await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile, OutputHelper);
|
2022-03-03 08:02:48 -06:00
|
|
|
|
|
|
|
Directory.CreateDirectory(OmniSharpDirectory);
|
2023-06-08 16:09:53 +02:00
|
|
|
Utilities.ExtractTarball(omniSharpTarballFile, OmniSharpDirectory, OutputHelper);
|
2023-07-13 19:37:41 -07:00
|
|
|
|
2023-06-21 12:34:44 -05:00
|
|
|
// Ensure the run script is executable (see https://github.com/OmniSharp/omnisharp-roslyn/issues/2547)
|
2023-06-22 22:11:11 +00:00
|
|
|
File.SetUnixFileMode($"{OmniSharpDirectory}/run", UnixFileMode.UserRead | UnixFileMode.UserExecute);
|
2022-03-03 08:02:48 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|