Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
2 changes: 0 additions & 2 deletions tests/COVERAGE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Property Coverage Report

Generated: 2026-06-19 09:47 UTC

## PCB Primitive Types

| Type | Files | Primitives | JSON Props | Mapped | Missing | Coverage |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public void GenerateCoverageReport()
var sb = new StringBuilder();
sb.AppendLine("# Property Coverage Report");
sb.AppendLine();
sb.AppendLine($"Generated: {DateTime.UtcNow:yyyy-MM-dd HH:mm} UTC");
sb.AppendLine();

// PCB types
sb.AppendLine("## PCB Primitive Types");
Expand Down Expand Up @@ -121,10 +119,13 @@ public void GenerateCoverageReport()
sb.AppendLine();
}

// Write the report
// Write the report only when its content changed, so a plain test run
// leaves the working tree clean.
var reportPath = Path.Combine(GetTestDataPath(), "..", "tests", "COVERAGE.md");
reportPath = Path.GetFullPath(reportPath);
File.WriteAllText(reportPath, sb.ToString());
var report = sb.ToString();
if (!File.Exists(reportPath) || File.ReadAllText(reportPath) != report)
File.WriteAllText(reportPath, report);

// Also output to test console
Assert.True(true, sb.ToString());
Expand Down
24 changes: 18 additions & 6 deletions tests/OriginalCircuit.Altium.Tests/RoundTrip/FileComparisonTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO.Compression;
using System.Text;
using OpenMcdf;
using OriginalCircuit.Altium.Serialization.Readers;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -16,24 +17,35 @@ public FileComparisonTest(ITestOutputHelper output)
}

[SkippableFact]
public void CompareOriginalAndWrittenPcbLib()
public async Task CompareOriginalAndWrittenPcbLib()
{
var origPath = GetDataPath("TestData", "Generated", "Individual", "PCB", "BODY_3D_STEP.PcbLib");
var writtenPath = GetDataPath("TestData", "Generated", "Individual", "PCB", "BODY_3D_STEP_CHECKSUM0.PcbLib");
if (!File.Exists(origPath) || !File.Exists(writtenPath)) { Skip.If(true, "Test data not available"); return; }
if (!File.Exists(origPath)) { Skip.If(true, "Test data not available"); return; }

// Regenerate the written variant in memory (zeroed model checksums, as
// RawDataPreservationTest saves it) instead of depending on a file on disk.
await using var origRead = File.OpenRead(origPath);
var library = new PcbLibReader().Read(origRead);
foreach (var model in library.Models)
model.Checksum = 0;
using var writtenMs = new MemoryStream();
await library.SaveAsync(writtenMs);

_output.WriteLine("=== ORIGINAL ===");
DumpCompoundFile(origPath);

_output.WriteLine("\n\n=== WRITTEN ===");
DumpCompoundFile(writtenPath);
_output.WriteLine($"In-memory zero-checksum variant ({writtenMs.Length} bytes)");
writtenMs.Position = 0;
using (var writtenDump = RootStorage.Open(writtenMs, StorageModeFlags.LeaveOpen))
DumpStorage(writtenDump, "");

// Now do a detailed byte comparison of each stream
_output.WriteLine("\n\n=== STREAM-BY-STREAM COMPARISON ===");
using var origFs = File.OpenRead(origPath);
using var origCf = RootStorage.Open(origFs, StorageModeFlags.LeaveOpen);
using var writtenFs = File.OpenRead(writtenPath);
using var writtenCf = RootStorage.Open(writtenFs, StorageModeFlags.LeaveOpen);
writtenMs.Position = 0;
using var writtenCf = RootStorage.Open(writtenMs, StorageModeFlags.LeaveOpen);

CompareStorage(origCf, writtenCf, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public async Task PcbLib_SaveWithZeroChecksum()
model.Checksum = 0;
}

// Save to a new file next to the original
var outPath = GetDataPath("TestData", "Generated", "Individual", "PCB", "BODY_3D_STEP_CHECKSUM0.PcbLib");
// Save outside the repository — writing into TestData would dirty the working
// tree on every run (the OLE directory FILETIMEs differ between writes).
var outPath = Path.Combine(Path.GetTempPath(), "BODY_3D_STEP_CHECKSUM0.PcbLib");
await library.SaveAsync(outPath, new OriginalCircuit.Eda.Models.SaveOptions());
_output.WriteLine($"Saved to: {outPath}");
}
Expand Down