Merge pull request #14333 from michaelnebel/csharp/windowsunittests

C#: Also run extractor unit tests on a windows runner.
This commit is contained in:
Michael Nebel
2023-09-29 15:28:26 +02:00
committed by GitHub
3 changed files with 9 additions and 5 deletions

View File

@@ -65,7 +65,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ github.token }}
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
@@ -78,6 +81,7 @@ jobs:
dotnet test -p:RuntimeFrameworkVersion=7.0.2 extractor/Semmle.Extraction.Tests
dotnet test -p:RuntimeFrameworkVersion=7.0.2 autobuilder/Semmle.Autobuild.CSharp.Tests
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests"
shell: bash
stubgentest:
runs-on: ubuntu-latest
steps:

View File

@@ -68,7 +68,7 @@ public static class StubGenerator
var stubPath = FileUtils.NestPaths(logger, outputPath, path.Replace(".dll", ".cs"));
stubPaths.Add(stubPath);
using var fileStream = new FileStream(stubPath, FileMode.Create, FileAccess.Write);
using var writer = new StreamWriter(fileStream, new UTF8Encoding(false));
using var writer = new StreamWriter(fileStream, new UTF8Encoding(false)) { NewLine = "\n" };
var visitor = new StubVisitor(writer, relevantSymbol);

View File

@@ -13,7 +13,7 @@ namespace Semmle.Extraction.Tests;
/// </summary>
public class StubGeneratorTests
{
// [Fact]
[Fact]
public void StubGeneratorFieldTest()
{
// Setup
@@ -36,7 +36,7 @@ public const string MyField2 = default;
Assert.Equal(expected, stub);
}
// [Fact]
[Fact]
public void StubGeneratorMethodTest()
{
// Setup
@@ -61,7 +61,7 @@ public int M1(string arg1) => throw null;
var st = CSharpSyntaxTree.ParseText(source);
var compilation = CSharpCompilation.Create(null, new[] { st });
var sb = new StringBuilder();
var visitor = new StubVisitor(new StringWriter(sb), new RelevantSymbolStub());
var visitor = new StubVisitor(new StringWriter(sb) { NewLine = "\n" }, new RelevantSymbolStub());
compilation.GlobalNamespace.Accept(visitor);
return sb.ToString();
}