Skip to content

Commit

Permalink
Separating W3C Test files from Issues and Pull Request (#1119)
Browse files Browse the repository at this point in the history
* Separating W3C Test files from Issues and Pull Request

 - Splitting the W3CTestSuite contents into W3CTestSuite and Issues
 - W3CTestSuite is now empty
 - W3CTestSuite contents will be automatically downloaded

* Apply Tests Split: updated SvgW3CTestRunner, Svg.UnitTests, Svg.Benchmarks

- The projects are modified to check if the W3C tests are downloaded, if not download it

* Resolved pull-request review issues
  • Loading branch information
paulushub authored Jan 11, 2024
1 parent 2e765f4 commit e9778e4
Show file tree
Hide file tree
Showing 1,721 changed files with 1,509 additions and 89,489 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,9 @@ MigrationBackup/
# JetBrains Rider
.idea/
*.sln.iml

# W3C Test Suites
Tests/W3CTestSuite/images
Tests/W3CTestSuite/png
Tests/W3CTestSuite/resources
Tests/W3CTestSuite/svg
129 changes: 129 additions & 0 deletions Tests/Issues/PassingTests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# List of test files relates to issues and pull-requests
__issue-015-01.svg
__issue-016-01.svg
__issue-034-01.svg
__issue-034-02.svg
__issue-036-01.svg
__issue-064-01.svg
__issue-064-02.svg
__issue-074-01.svg
__issue-082-01.svg
__issue-083-01.svg
__issue-084-01.svg
__issue-109-01.svg
__issue-114-01.svg
__issue-116-01.svg
__issue-123-01.svg
__issue-129-01.svg
__issue-131-01.svg
__issue-134-01.svg
__issue-143-01.svg
__issue-166-01.svg
__issue-191-01.svg
__issue-202-01.svg
__issue-214-01.svg
__issue-215-01.svg
__issue-223-01.svg
__issue-223-02.svg
__issue-224-01.svg
__issue-227-01.svg
__issue-227-02.svg
__issue-239-01.svg
__issue-242-01.svg
__issue-252-01.svg
__issue-279-01.svg
__issue-280-01.svg
__issue-280-02.svg
__issue-318-01.svg
__issue-323-02.svg
__issue-323-03.svg
__issue-329-01.svg
__issue-338-01_stroke_width.svg
__issue-342-01.svg
__issue-345-01.svg
__issue-354-01.svg
__issue-363-01.svg
__issue-385-01_Test_text-anchor-middle.svg
__issue-391-01.svg
__issue-398-01.svg
__issue-419-01.svg
__issue-436-01.svg
__issue-437-01.svg
__issue-437-02.svg
__issue-437-03.svg
__issue-460-01.svg
__issue-479-01.svg
__issue-488-01.svg
__issue-508-01.svg
__issue-541-01.svg
__issue-554-01.svg
__issue-554-02.svg
__issue-578-01.svg
__issue-592-01.svg
__issue-592-02.svg
__issue-622-01.svg
__issue-626-01.svg
__issue-634-01.svg
__issue-664-01.svg
__issue-675-01.svg
__issue-732-01.svg
__issue-744-01.svg
__issue-747-01.svg
__issue-755-01.svg
__issue-758-01.svg
__issue-769-01.svg
__issue-785-01.svg
__issue-830-01.svg
__issue-863-01.svg
__issue-886-01.svg
__issue-888-01.svg
__issue-917-01.svg
__issue-917-02.svg
__issue-941-01.svg
__issue-960-01.svg
__issue-966-01.svg
__issue-966-02.svg
__issue-989-01.svg
__issue-1101-01.svg
__pull_request-373-01.svg
__pull_request-374-01.svg
__pull_request-414-01.svg
__pull_request-433-01.svg
__pull_request-444-01.svg
__pull_request-462-01.svg
__pull_request-471-01.svg
__pull_request-492-01.svg
__pull_request-500-01.svg
__pull_request-500-02.svg
__pull_request-504-01.svg
__pull_request-537-01.svg
__pull_request-537-02.svg
__pull_request-551-01.svg
__pull_request-564-01.svg
__pull_request-564-02.svg
__pull_request-575-01.svg
__pull_request-640-01.svg
__pull_request-640-02.svg
__pull_request-642-01.svg
__pull_request-656-01.svg
__pull_request-656-02.svg
__pull_request-658-01.svg
__pull_request-659-01.svg
__pull_request-686-01.svg
__pull_request-690-01.svg
__pull_request-706-01.svg
__pull_request-727-01.svg
__pull_request-873-01.svg
__pull_request-873-02.svg
__pull_request-925-01.svg
__pull_request-925-02.svg
__pull_request-925-03.svg
__pull_request-925-04.svg
__pull_request-925-05.svg
__pull_request-961-01.svg
__pull_request-963-01.svg
__pull_request-1045-01.svg
__AJ_Digital_Camera.svg
__Telefunken_FuBK_test_pattern.svg
__tiger.svg
__title.svg
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions Tests/Svg.Benchmark/Svg.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="..\W3CTestSuite\svg\__AJ_Digital_Camera.svg">
<EmbeddedResource Include="..\Issues\svg\__AJ_Digital_Camera.svg">
<Link>Assets\__AJ_Digital_Camera.svg</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\W3CTestSuite\svg\__issue-134-01.svg">
<EmbeddedResource Include="..\Issues\svg\__issue-134-01.svg">
<Link>Assets\__issue-134-01.svg</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\W3CTestSuite\svg\__tiger.svg">
<EmbeddedResource Include="..\Issues\svg\__tiger.svg">
<Link>Assets\__tiger.svg</Link>
</EmbeddedResource>
</ItemGroup>
Expand Down
41 changes: 36 additions & 5 deletions Tests/Svg.UnitTests/ExCssSelectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ namespace Svg.UnitTests
[TestFixture]
public class ExCssSelectorTests
{
[OneTimeSetUp]
public void OneTimeSetUp()
{
TestsUtils.EnsureTestsExists(ImageTestDataSource.SuiteTestsFolder).Wait();
}

[Test]
[TestCase("struct-use-11-f")]
[TestCase("struct-use-10-f")]
Expand All @@ -29,7 +35,7 @@ public void RunAllSelectorTests(string baseName)
public void RunAllSelectorTests(string baseName, string folder)
{
var elementFactory = new SvgElementFactory();
var testSuite = Path.Combine(ImageTestDataSource.SuiteTestsFolder, "W3CTestSuite");
var testSuite = TestsUtils.GetPath(ImageTestDataSource.SuiteTestsFolder, baseName);
string basePath = folder ?? Path.Combine(testSuite, "svg");
var svgPath = Path.Combine(basePath, baseName + ".svg");

Expand Down Expand Up @@ -153,7 +159,7 @@ public void RunSelectorsOnSvgTests(TestSvg svg)
public void RunSelectorTests(string selector, string baseName)
{
var elementFactory = new SvgElementFactory();
var testSuite = Path.Combine(ImageTestDataSource.SuiteTestsFolder, "W3CTestSuite");
var testSuite = TestsUtils.GetPath(ImageTestDataSource.SuiteTestsFolder, baseName);
string basePath = testSuite;
var svgPath = Path.Combine(basePath, "svg", baseName + ".svg");
var styles = new List<ISvgNode>();
Expand Down Expand Up @@ -256,7 +262,7 @@ public void RunSelectorTests(string selector)
{
string baseName = "struct-use-11-f";
var elementFactory = new SvgElementFactory();
var testSuite = Path.Combine(ImageTestDataSource.SuiteTestsFolder, "W3CTestSuite");
var testSuite = TestsUtils.GetPath(ImageTestDataSource.SuiteTestsFolder, baseName);
string basePath = testSuite;
var svgPath = Path.Combine(basePath, "svg", baseName + ".svg");
var styles = new List<ISvgNode>();
Expand Down Expand Up @@ -326,6 +332,11 @@ private IEnumerable<SvgElement> QuerySelectorFizzlerAll(NonSvgElement elem, stri

public class TestSvg
{
static TestSvg()
{
TestsUtils.EnsureTestsExists(ImageTestDataSource.SuiteTestsFolder).Wait();
}

private readonly string _baseName;
private readonly string _folder;

Expand All @@ -346,7 +357,16 @@ public override string ToString()
public static IEnumerable<TestSvg> AllSvgs()
{
var basePath = ImageTestDataSource.SuiteTestsFolder;
var testSuite = Path.Combine(basePath, "W3CTestSuite", "svg");
var testSuite = Path.Combine(basePath, TestsUtils.W3CTests, "svg");
// Enumerate all Test Svgs
foreach(var baseName in Directory.EnumerateFiles(testSuite))
{
if (Path.GetExtension(baseName) == ".svg")
{
yield return new TestSvg(Path.GetFileNameWithoutExtension(baseName), testSuite);
}
}
testSuite = Path.Combine(basePath, TestsUtils.IssuesTests, "svg");
// Enumerate all Test Svgs
foreach(var baseName in Directory.EnumerateFiles(testSuite))
{
Expand All @@ -360,7 +380,18 @@ public static IEnumerable<TestSvg> AllSvgs()
public static IEnumerable<TestSvg> AllImageSvgs()
{
var basePath = ImageTestDataSource.SuiteTestsFolder;
var testSuite = Path.Combine(basePath, "W3CTestSuite", "images");
var testSuite = Path.Combine(basePath, TestsUtils.W3CTests, "images");
// Enumerate all Test Svgs
foreach(var baseName in Directory.EnumerateFiles(testSuite))
{
if (Path.GetExtension(baseName) == ".svg")
{
yield return new TestSvg(
Path.GetFileNameWithoutExtension(baseName),
testSuite);
}
}
testSuite = Path.Combine(basePath, TestsUtils.IssuesTests, "images");
// Enumerate all Test Svgs
foreach(var baseName in Directory.EnumerateFiles(testSuite))
{
Expand Down
39 changes: 27 additions & 12 deletions Tests/Svg.UnitTests/ImageComparisonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace Svg.UnitTests
[TestFixture]
public class ImageComparisonTest
{
[OneTimeSetUp]
public void OneTimeSetUp()
{
this.TestContext = TestContext.CurrentContext;
TestsUtils.EnsureTestsExists(ImageTestDataSource.SuiteTestsFolder).Wait();
}

public TestContext TestContext { get; set; }

#if NETSTANDARD || NETCOREAPP
Expand Down Expand Up @@ -53,14 +60,16 @@ public void CompareSvgImageWithReference(ImageTestDataSource.TestData testData)
{
basePath = Path.GetDirectoryName(basePath);
}
basePath = Path.Combine(Path.Combine(basePath, "Tests"), "W3CTestSuite");
var svgBasePath = Path.Combine(basePath, "svg");
// var svgBasePath = Path.Combine(basePath, "svg");
var baseName = testData.BaseName;
bool testSaveLoad = !baseName.StartsWith("#");
if (!testSaveLoad)
{
baseName = baseName.Substring(1);
}
var testsRoot = Path.Combine(basePath, "Tests");
basePath = TestsUtils.GetPath(testsRoot, baseName);
// basePath = Path.Combine(Path.Combine(basePath, "Tests"), "Issues");
var svgPath = Path.Combine(Path.Combine(basePath, "svg"), baseName + ".svg");
var pngPath = Path.Combine(Path.Combine(basePath, "png"), baseName + ".png");
CompareSvgImageWithReferenceImpl(baseName, svgPath, pngPath, testSaveLoad);
Expand Down Expand Up @@ -111,18 +120,19 @@ private void CompareSvgImageWithReferenceImpl(string baseName, string svgPath, s
/// of all considered W3C tests.
/// Can be used to enhance the difference calculation.
/// </summary>
// [TestFixture]
// [Test]
public void RecordDiffForAllSvgImagesWithReference()
{
#if NETSTANDARD || NETCOREAPP
var basePath = Path.Combine(ImageTestDataSource.SuiteTestsFolder, "W3CTestSuite");
#else
var basePath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestDirectory))); //TODO: Tthe get dir name was parsed from the testparams -> Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestRunDirectory)));
basePath = Path.Combine(Path.Combine(basePath, "Tests"), "W3CTestSuite");
#endif
string[] lines = File.ReadAllLines(@"..\..\..\..\Tests\Svg.UnitTests\all.csv");
var testsRoot = ImageTestDataSource.SuiteTestsFolder;
//string[] lines = File.ReadAllLines(@"..\..\..\..\Tests\Svg.UnitTests\all.csv");
string[] lines = File.ReadAllLines(Path.Combine(testsRoot, @"Svg.UnitTests\AllTests.csv"));
TestContext.Progress.WriteLine("RecordDiffForAllSvgImagesWithReference: Outputs");
foreach (var baseName in lines)
{
if (baseName.Equals("BaseName"))
continue; // Skip the column header
var basePath = TestsUtils.GetPath(testsRoot, baseName);

var svgPath = Path.Combine(Path.Combine(basePath, "svg"), baseName + ".svg");
var pngPath = Path.Combine(Path.Combine(basePath, "png"), baseName + ".png");
if (File.Exists(pngPath) && File.Exists(svgPath))
Expand All @@ -133,7 +143,7 @@ public void RecordDiffForAllSvgImagesWithReference()
using (var svgImage = LoadSvgImage(svgDoc, useFixedSize))
{
var difference = svgImage.PercentageDifference(pngImage);
Console.WriteLine(baseName + " " + (difference * 100.0).ToString());
TestContext.Progress.WriteLine(" " + baseName + " " + (difference * 100.0).ToString());
}
}
}
Expand Down Expand Up @@ -305,10 +315,15 @@ public override string ToString()
public static IEnumerable<TestData> PassingTests()
{
var basePath = SuiteTestsFolder;
var testSuite = Path.Combine(basePath, "W3CTestSuite");
var W3CPath = Path.Combine(basePath, TestsUtils.W3CTests);
var IssuesPath = Path.Combine(basePath, TestsUtils.IssuesTests);
var rows = new ImageTestDataSource().LoadRowsFromResourceCsv().Skip(1); // Skip header row
foreach (var row in rows)
{
var testSuite = row.StartsWith(TestsUtils.IssuesPrefix) ? IssuesPath : W3CPath;

yield return new TestData() { BasePath = testSuite, BaseName = row };
}
}

private const string ResourceIdentifier = "PassingTests.csv";
Expand Down
Loading

0 comments on commit e9778e4

Please sign in to comment.