43 lines
1.5 KiB
C#
Generated
43 lines
1.5 KiB
C#
Generated
// This file is auto-generated by alef — DO NOT EDIT.
|
|
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
|
// To regenerate: alef generate
|
|
// To verify freshness: alef verify --exit-code
|
|
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
using System;
|
|
using System.IO;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace Kreuzberg;
|
|
|
|
internal static class TestSetup
|
|
{
|
|
[ModuleInitializer]
|
|
internal static void Init()
|
|
{
|
|
// Walk up from the assembly directory until we find the repo root.
|
|
// Prefer a sibling test_documents/ directory (chdir into it so that
|
|
// fixture paths like "docx/fake.docx" resolve relative to it). If that
|
|
// is absent (web-crawler-style repos with no document fixtures), fall
|
|
// back to a sibling alef.toml or fixtures/ marker as the repo root.
|
|
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
DirectoryInfo? repoRoot = null;
|
|
while (dir != null)
|
|
{
|
|
var documentsCandidate = Path.Combine(dir.FullName, "test_documents");
|
|
if (Directory.Exists(documentsCandidate))
|
|
{
|
|
repoRoot = dir;
|
|
Directory.SetCurrentDirectory(documentsCandidate);
|
|
break;
|
|
}
|
|
if (File.Exists(Path.Combine(dir.FullName, "alef.toml"))
|
|
|| Directory.Exists(Path.Combine(dir.FullName, "fixtures")))
|
|
{
|
|
repoRoot = dir;
|
|
break;
|
|
}
|
|
dir = dir.Parent;
|
|
}
|
|
}
|
|
}
|