Skip to content

Commit b4cf331

Browse files
authored
Add test coverage as CI artifacts (#155)
* Simplify packages * Test Covefe * Somehow everything have a smaller size * Default to netcoreapp3.1 * Buildable Typography tests * Note * Ios buildable * Update Test.yml * Reference commit for bug report * Hopefully this works now * Increase Ios tolerance... * Coverage successful? * RIP Ios Tests * Fix local tests * RIP Ios Tests * Update Test.yml * Lock that object * Delete NuGet.config
1 parent 21dd9fe commit b4cf331

File tree

360 files changed

+189
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+189
-238
lines changed

.github/workflows/Test.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v2
1414
with:
1515
submodules: 'recursive'
16-
- name: Setup .NET Core
16+
- name: Setup .NET Core # Required to execute ReportGenerator
1717
uses: actions/setup-dotnet@v1
1818
with:
1919
dotnet-version: '3.1.302'
@@ -51,13 +51,22 @@ jobs:
5151
"CSharpMath.Xaml.Tests.NuGet"\
5252
"Typography/Typography.TextBreak/Typography.TextBreak.UnitTests"
5353
do
54-
dotnet add "$p" package Microsoft.NET.Test.Sdk # Update is required for GitHubActionsTestLogger to print anything
55-
dotnet add "$p" package GitHubActionsTestLogger
56-
# -r for restore
57-
dotnet msbuild -r -p:Configuration=Release -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }} -p:PackageReleaseNotes="$RELEASE_NOTES" "$p"
58-
# --no-build because building again will produce additional NuGet packages without the PackageVersion setting above
59-
dotnet test "$p" --no-build -c Release -l GitHubActions --blame
54+
# --collect:"XPlat Code Coverage" means collect test coverage with https://github.com/coverlet-coverage/coverlet
55+
dotnet test "$p" -c Release -l GitHubActions --blame --collect:"XPlat Code Coverage" -r .testcoverage -p:PackageReleaseNotes="$RELEASE_NOTES" -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }}
6056
done
57+
- name: Run ReportGenerator on Test Coverage results
58+
uses: danielpalme/ReportGenerator-GitHub-Action@4.6.4
59+
with:
60+
reports: '.testcoverage/**/*.*' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
61+
targetdir: '.testcoverage/report' # REQUIRED # The directory where the generated report should be saved.
62+
reporttypes: 'Html' # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
63+
title: 'CSharpMath test coverage results' # Optional title.
64+
tag: ${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }} # Optional tag or build version.
65+
- name: Upload CSharpMath test coverage results as CI artifacts
66+
uses: actions/upload-artifact@v2
67+
with:
68+
name: CSharpMath test coverage results
69+
path: .testcoverage/
6170
- name: Upload CSharpMath.Rendering.Tests results as CI artifacts
6271
uses: actions/upload-artifact@v2
6372
if: always() # Run even when a previous step failed: https://stackoverflow.com/a/58859404/5429648
@@ -83,11 +92,12 @@ jobs:
8392
dotnet nuget add source https://nuget.pkg.github.com/verybadcat/index.json -n github -u verybadcat -p ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
8493
for x in `ls .nupkgs/*.nupkg` # Don't let GitHub Releases interpret .snupkg as .nupkg
8594
do
95+
# The GitHub Package registry does not support .snupkg files so we specify --no-symbols
8696
# Use --skip-duplicate since we want re-runs of this workflow to succeed in case of network issues
87-
dotnet nuget push $x --source "github" --skip-duplicate
97+
dotnet nuget push $x --no-symbols --source "github" --skip-duplicate
8898
done
8999
# Following command does not work... https://github.com/NuGet/Home/issues/9867
90-
# dotnet nuget push .nupkgs/*.nupkg --source "github" --skip-duplicate # Don't let GitHub Releases interpret .snupkg as .nupkg
100+
# dotnet nuget push .nupkgs/*.nupkg --no-symbols --source "github" --skip-duplicate # Don't let GitHub Releases interpret .snupkg as .nupkg
91101
Ios:
92102
runs-on: macos-latest
93103
steps:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ CSharpMath.Rendering.Tests/*/*.*.png
88
# For CSharpMath.Xaml.Tests.NuGet
99
CSharpMath.Xaml.Tests.NuGet/Test.*.png
1010

11-
# Ignore generated .nupkgs
11+
# Ignore generated content
1212
/.nupkgs
13+
/.testcoverage
1314

1415
## END Specifically added for CSharpMath
1516

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
</PropertyGroup>
6-
72
<ItemGroup>
83
<Compile Include="..\CSharpMath.Apple\BackEnd\JsonMathTable.cs" Link="_Helpers\BackEnd\JsonMathTable.cs" />
94
<Compile Include="..\CSharpMath.Apple\BackEnd\IFontMeasurer.cs" Link="_Helpers\BackEnd\IFontMeasurer.cs" />
@@ -12,12 +7,7 @@
127
<Compile Include="..\CSharpMath.Apple\Resources\ManifestResources.cs" Link="_Helpers\Resources\ManifestResources.cs" />
138
<Compile Include="..\CSharpMath.Apple\Resources\ManifestResourceProvider.cs" Link="_Helpers\Resources\ManifestResourceProvider.cs" />
149
<EmbeddedResource Include="_Helpers\Resources\latinmodern-math.json" />
15-
<Content Include="Xunit.runner.json">
16-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17-
</Content>
1810
<ProjectReference Include="..\CSharpMath\CSharpMath.csproj" />
1911
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
20-
<PackageReference Include="xunit" Version="2.4.1" />
21-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
2212
</ItemGroup>
23-
</Project>
13+
</Project>

CSharpMath.CoreTests/LaTeXParserTest.cs

Lines changed: 109 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,113 +1021,115 @@ public void TestCases2() {
10211021

10221022
[Fact]
10231023
public void TestCustom() {
1024-
var input = @"\lcm(a,b)";
1025-
var builder = new LaTeXParser(input);
1026-
var (list, error) = builder.Build();
1027-
Assert.Null(list);
1028-
Assert.Equal(@"Invalid command \lcm", error);
1029-
1030-
LaTeXSettings.CommandSymbols.Add(@"\lcm", new LargeOperator("lcm", false));
1031-
list = ParseLaTeX(input);
1032-
Assert.Collection(list,
1033-
CheckAtom<LargeOperator>("lcm"),
1034-
CheckAtom<Open>("("),
1035-
CheckAtom<Variable>("a"),
1036-
CheckAtom<Punctuation>(","),
1037-
CheckAtom<Variable>("b"),
1038-
CheckAtom<Close>(")")
1039-
);
1040-
Assert.Equal(@"\lcm (a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1041-
1042-
LaTeXSettings.CommandSymbols.Add(@"lcm", new LargeOperator("lcm", false));
1043-
LaTeXSettings.CommandSymbols.Add(@"lcm12", new LargeOperator("lcm12", false));
1044-
LaTeXSettings.CommandSymbols.Add(@"lcm1234", new LargeOperator("lcm1234", false));
1045-
LaTeXSettings.CommandSymbols.Add(@"lcm1235", new LargeOperator("lcm1235", false));
1046-
1047-
// Does not match custom atoms added above
1048-
list = ParseLaTeX("lc(a,b)");
1049-
Assert.Collection(list,
1050-
CheckAtom<Variable>("l"),
1051-
CheckAtom<Variable>("c"),
1052-
CheckAtom<Open>("("),
1053-
CheckAtom<Variable>("a"),
1054-
CheckAtom<Punctuation>(","),
1055-
CheckAtom<Variable>("b"),
1056-
CheckAtom<Close>(")")
1057-
);
1058-
Assert.Equal(@"lc(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1059-
1060-
// Baseline for lookup as a non-command (not starting with \)
1061-
list = ParseLaTeX("lcm(a,b)");
1062-
Assert.Collection(list,
1063-
CheckAtom<LargeOperator>("lcm"),
1064-
CheckAtom<Open>("("),
1065-
CheckAtom<Variable>("a"),
1066-
CheckAtom<Punctuation>(","),
1067-
CheckAtom<Variable>("b"),
1068-
CheckAtom<Close>(")")
1069-
);
1070-
Assert.Equal(@"\lcm (a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1071-
1072-
// Originally in https://github.com/verybadcat/CSharpMath/pull/143,
1073-
// the non-command dictionary of LaTeXCommandDictionary were implemented with a trie.
1074-
// With the above LaTeXSettings.CommandSymbols.Add calls, it would have looked like:
1075-
// [l] -> l[cm] -> lcm[12] -> @lcm12[3] -> lcm123[4]
1076-
// ^--> lcm123[5]
1077-
// where [square brackets] denote added characters compared to previous node
1078-
// and the @at sign denotes the node without an atom to provide
1079-
// Here we ensure that all behaviours of the trie carry over to the new SortedSet implementation
1080-
1081-
// Test lookup fallbacks when trie node key (lcm12) does not fully match input (lcm1)
1082-
list = ParseLaTeX("lcm1(a,b)");
1083-
Assert.Collection(list,
1084-
CheckAtom<LargeOperator>("lcm"),
1085-
CheckAtom<Number>("1"),
1086-
CheckAtom<Open>("("),
1087-
CheckAtom<Variable>("a"),
1088-
CheckAtom<Punctuation>(","),
1089-
CheckAtom<Variable>("b"),
1090-
CheckAtom<Close>(")")
1091-
);
1092-
Assert.Equal(@"\lcm 1(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1093-
1094-
// Test lookup success for trie node between above case and below case
1095-
list = ParseLaTeX("lcm12(a,b)");
1096-
Assert.Collection(list,
1097-
CheckAtom<LargeOperator>("lcm12"),
1098-
CheckAtom<Open>("("),
1099-
CheckAtom<Variable>("a"),
1100-
CheckAtom<Punctuation>(","),
1101-
CheckAtom<Variable>("b"),
1102-
CheckAtom<Close>(")")
1103-
);
1104-
Assert.Equal(@"lcm12(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1105-
1106-
// Test lookup fallbacks when trie node key (lcm123) fully matches input (lcm123) but has no atoms to provide
1107-
list = ParseLaTeX("lcm123(a,b)");
1108-
Assert.Collection(list,
1109-
CheckAtom<LargeOperator>("lcm12"),
1110-
CheckAtom<Number>("3"),
1111-
CheckAtom<Open>("("),
1112-
CheckAtom<Variable>("a"),
1113-
CheckAtom<Punctuation>(","),
1114-
CheckAtom<Variable>("b"),
1115-
CheckAtom<Close>(")")
1116-
);
1117-
Assert.Equal(@"lcm123(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1118-
1119-
// Add a new shorter entry to ensure that the longest key matches instead of the last one
1120-
LaTeXSettings.CommandSymbols.Add(@"lcm123", new LargeOperator("lcm123", false));
1121-
list = ParseLaTeX("lcm1234(a,b)");
1122-
Assert.Collection(list,
1123-
CheckAtom<LargeOperator>("lcm1234"),
1124-
CheckAtom<Open>("("),
1125-
CheckAtom<Variable>("a"),
1126-
CheckAtom<Punctuation>(","),
1127-
CheckAtom<Variable>("b"),
1128-
CheckAtom<Close>(")")
1129-
);
1130-
Assert.Equal(@"lcm1234(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1024+
lock (LaTeXSettings.Commands) {
1025+
var input = @"\lcm(a,b)";
1026+
var builder = new LaTeXParser(input);
1027+
var (list, error) = builder.Build();
1028+
Assert.Null(list);
1029+
Assert.Equal(@"Invalid command \lcm", error);
1030+
1031+
LaTeXSettings.CommandSymbols.Add(@"\lcm", new LargeOperator("lcm", false));
1032+
list = ParseLaTeX(input);
1033+
Assert.Collection(list,
1034+
CheckAtom<LargeOperator>("lcm"),
1035+
CheckAtom<Open>("("),
1036+
CheckAtom<Variable>("a"),
1037+
CheckAtom<Punctuation>(","),
1038+
CheckAtom<Variable>("b"),
1039+
CheckAtom<Close>(")")
1040+
);
1041+
Assert.Equal(@"\lcm (a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1042+
1043+
LaTeXSettings.CommandSymbols.Add(@"lcm", new LargeOperator("lcm", false));
1044+
LaTeXSettings.CommandSymbols.Add(@"lcm12", new LargeOperator("lcm12", false));
1045+
LaTeXSettings.CommandSymbols.Add(@"lcm1234", new LargeOperator("lcm1234", false));
1046+
LaTeXSettings.CommandSymbols.Add(@"lcm1235", new LargeOperator("lcm1235", false));
1047+
1048+
// Does not match custom atoms added above
1049+
list = ParseLaTeX("lc(a,b)");
1050+
Assert.Collection(list,
1051+
CheckAtom<Variable>("l"),
1052+
CheckAtom<Variable>("c"),
1053+
CheckAtom<Open>("("),
1054+
CheckAtom<Variable>("a"),
1055+
CheckAtom<Punctuation>(","),
1056+
CheckAtom<Variable>("b"),
1057+
CheckAtom<Close>(")")
1058+
);
1059+
Assert.Equal(@"lc(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1060+
1061+
// Baseline for lookup as a non-command (not starting with \)
1062+
list = ParseLaTeX("lcm(a,b)");
1063+
Assert.Collection(list,
1064+
CheckAtom<LargeOperator>("lcm"),
1065+
CheckAtom<Open>("("),
1066+
CheckAtom<Variable>("a"),
1067+
CheckAtom<Punctuation>(","),
1068+
CheckAtom<Variable>("b"),
1069+
CheckAtom<Close>(")")
1070+
);
1071+
Assert.Equal(@"\lcm (a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1072+
1073+
// Originally in https://github.com/verybadcat/CSharpMath/pull/143,
1074+
// the non-command dictionary of LaTeXCommandDictionary were implemented with a trie.
1075+
// With the above LaTeXSettings.CommandSymbols.Add calls, it would have looked like:
1076+
// [l] -> l[cm] -> lcm[12] -> @lcm12[3] -> lcm123[4]
1077+
// ^--> lcm123[5]
1078+
// where [square brackets] denote added characters compared to previous node
1079+
// and the @at sign denotes the node without an atom to provide
1080+
// Here we ensure that all behaviours of the trie carry over to the new SortedSet implementation
1081+
1082+
// Test lookup fallbacks when trie node key (lcm12) does not fully match input (lcm1)
1083+
list = ParseLaTeX("lcm1(a,b)");
1084+
Assert.Collection(list,
1085+
CheckAtom<LargeOperator>("lcm"),
1086+
CheckAtom<Number>("1"),
1087+
CheckAtom<Open>("("),
1088+
CheckAtom<Variable>("a"),
1089+
CheckAtom<Punctuation>(","),
1090+
CheckAtom<Variable>("b"),
1091+
CheckAtom<Close>(")")
1092+
);
1093+
Assert.Equal(@"\lcm 1(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1094+
1095+
// Test lookup success for trie node between above case and below case
1096+
list = ParseLaTeX("lcm12(a,b)");
1097+
Assert.Collection(list,
1098+
CheckAtom<LargeOperator>("lcm12"),
1099+
CheckAtom<Open>("("),
1100+
CheckAtom<Variable>("a"),
1101+
CheckAtom<Punctuation>(","),
1102+
CheckAtom<Variable>("b"),
1103+
CheckAtom<Close>(")")
1104+
);
1105+
Assert.Equal(@"lcm12(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1106+
1107+
// Test lookup fallbacks when trie node key (lcm123) fully matches input (lcm123) but has no atoms to provide
1108+
list = ParseLaTeX("lcm123(a,b)");
1109+
Assert.Collection(list,
1110+
CheckAtom<LargeOperator>("lcm12"),
1111+
CheckAtom<Number>("3"),
1112+
CheckAtom<Open>("("),
1113+
CheckAtom<Variable>("a"),
1114+
CheckAtom<Punctuation>(","),
1115+
CheckAtom<Variable>("b"),
1116+
CheckAtom<Close>(")")
1117+
);
1118+
Assert.Equal(@"lcm123(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1119+
1120+
// Add a new shorter entry to ensure that the longest key matches instead of the last one
1121+
LaTeXSettings.CommandSymbols.Add(@"lcm123", new LargeOperator("lcm123", false));
1122+
list = ParseLaTeX("lcm1234(a,b)");
1123+
Assert.Collection(list,
1124+
CheckAtom<LargeOperator>("lcm1234"),
1125+
CheckAtom<Open>("("),
1126+
CheckAtom<Variable>("a"),
1127+
CheckAtom<Punctuation>(","),
1128+
CheckAtom<Variable>("b"),
1129+
CheckAtom<Close>(")")
1130+
);
1131+
Assert.Equal(@"lcm1234(a,b)", LaTeXParser.MathListToLaTeX(list).ToString());
1132+
}
11311133
}
11321134

11331135
[Theory]

CSharpMath.CoreTests/LaTeXSettingsTests.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ namespace CSharpMath.CoreTests {
66
public class LaTeXSettingsTests {
77
[Fact]
88
public void ForAsciiHandlesAllInputs() {
9-
for (char i = '\0'; i <= sbyte.MaxValue; i++)
10-
switch (i) {
11-
case '\\': // The command character is handled specially
12-
case '$': // Unimplemented
13-
case '#': // Unimplemented
14-
case '~': // Unimplemented
15-
Assert.DoesNotContain(LaTeXSettings.Commands, kvp => kvp.Key == i.ToString());
16-
break;
17-
default:
18-
Assert.Contains(LaTeXSettings.Commands, kvp => kvp.Key == i.ToString());
19-
break;
20-
}
9+
lock (LaTeXSettings.Commands)
10+
for (char i = '\0'; i <= sbyte.MaxValue; i++)
11+
switch (i) {
12+
case '\\': // The command character is handled specially
13+
case '$': // Unimplemented
14+
case '#': // Unimplemented
15+
case '~': // Unimplemented
16+
Assert.DoesNotContain(LaTeXSettings.Commands, kvp => kvp.Key == i.ToString());
17+
break;
18+
default:
19+
Assert.Contains(LaTeXSettings.Commands, kvp => kvp.Key == i.ToString());
20+
break;
21+
}
2122
}
2223
[Fact]
2324
public void CommandForAtomIgnoresInnerLists() {

CSharpMath.CoreTests/Xunit.runner.json

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<GenerateProgramFile>false</GenerateProgramFile>
6-
</PropertyGroup>
7-
1+
<Project Sdk="Microsoft.NET.Sdk">
82
<ItemGroup>
9-
<PackageReference Include="xunit" Version="2.4.1" />
10-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
11-
<ProjectReference Include="..\CSharpMath\CSharpMath.csproj" />
123
<ProjectReference Include="..\CSharpMath.Editor\CSharpMath.Editor.csproj" />
13-
<ProjectReference Include="..\CSharpMath.Rendering\CSharpMath.Rendering.csproj" />
14-
<Compile Include="RandomKeyboardInputsTest.fs" />
154
</ItemGroup>
16-
17-
</Project>
5+
</Project>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<OutputType>Exe</OutputType>
54
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<StartupObject>CSharpMath.Editor.Tests.Visualizer.Checker</StartupObject>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<ProjectReference Include="..\CSharpMath.Editor\CSharpMath.Editor.csproj" />
1010
<ProjectReference Include="..\CSharpMath.Editor.Tests\CSharpMath.Editor.Tests.csproj" />
1111
</ItemGroup>
12-
1312
</Project>

0 commit comments

Comments
 (0)