This commit is contained in:
Francesco Mecca 2024-12-07 11:56:29 +01:00
parent bbeb9e1540
commit d5537d3448
6 changed files with 20 additions and 11 deletions

View file

@ -5,3 +5,10 @@ test_reports:
dotnet test --collect "XPlat Code Coverage" --results-directory /tmp/pentole_reports/ dotnet test --collect "XPlat Code Coverage" --results-directory /tmp/pentole_reports/
mv /tmp/pentole_reports/*/coverage.cobertura.xml . mv /tmp/pentole_reports/*/coverage.cobertura.xml .
reportgenerator -targetdir:coverlet/reports -reporttypes:HtmlInline_AzurePipelines -reports:coverage.cobertura.xml reportgenerator -targetdir:coverlet/reports -reporttypes:HtmlInline_AzurePipelines -reports:coverage.cobertura.xml
clean:
rm Pentole/bin Pentole/obj tests/bin tests/obj -fr
docs: test
fsdocs build --output pentole

View file

@ -4,12 +4,13 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>Pentole</PackageId> <PackageId>Pentole</PackageId>
<Version>0.0.1</Version> <Version>0.0.3</Version>
<Authors>Francesco Mecca</Authors> <Authors>Francesco Mecca</Authors>
<Company>Bugless24</Company> <Company>Bugless24</Company>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="logginghelpers.fs" />
<Compile Include="binaryprefix.fs" /> <Compile Include="binaryprefix.fs" />
<Compile Include="pervasives.fs" /> <Compile Include="pervasives.fs" />
<Compile Include="string.fs" /> <Compile Include="string.fs" />
@ -22,6 +23,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Nunit" Version="4.2.1" /> <PackageReference Include="Nunit" Version="4.2.1" />
<PackageReference Include="Serilog" Version="4.2.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -16,7 +16,7 @@ let realpath (path: string) =
if ptr = IntPtr.Zero then if ptr = IntPtr.Zero then
let errno = Marshal.GetLastWin32Error() let errno = Marshal.GetLastWin32Error()
let error = Marshal.PtrToStringAuto(_strerror errno) let error = Marshal.PtrToStringAuto(_strerror errno)
Error $"realpath failed: {error} ({errno})" Error $"realpath failed: {error} ({errno}), path={path}"
else else
let result = Marshal.PtrToStringAuto ptr let result = Marshal.PtrToStringAuto ptr
Marshal.FreeHGlobal ptr Marshal.FreeHGlobal ptr

View file

@ -110,9 +110,9 @@ let is_normalized (path_: Path) =
// impure functions // impure functions
// https://docs.python.org/3.8/library/pathlib.html // https://docs.python.org/3.8/library/pathlib.html
module FileSystem =
let resolve = function let resolve = function
| Absolute path -> | Absolute path ->
Native.realpath path |> Result.map Path.of_string Native.realpath path |> Result.bind Path.of_string
| Relative path -> | Relative path ->
Native.realpath path |> Result.map Path.of_string Native.realpath path |> Result.bind Path.of_string

View file

@ -3,14 +3,12 @@ module Pentole.Pervasives
/// <summary> /// <summary>
/// The identity function. /// The identity function.
/// </summary> /// </summary>
/// <param name="x"></param>
let identity = id let identity = id
/// <summary> /// <summary>
/// Pass the object to a function and return the object unchanged. /// Pass the object to a function and return the object unchanged.
/// Useful in the middle of pipelines to see what values are being passed or log /// Useful in the middle of pipelines to see what values are being passed or log
/// </summary> /// </summary>
/// <xparam name="x"></param>
let tee fun_ obj = let tee fun_ obj =
fun_ obj fun_ obj
obj obj

View file

@ -41,7 +41,7 @@ let resolve_test () =
let test (s:string) = let test (s:string) =
s s
|> Path.of_string |> Path.of_string
|> Result.bind resolve |> Result.map FileSystem.resolve
|> Result.get |> Result.get
let p (n: string ) = Path.of_string n |> Result.get let p (n: string ) = Path.of_string n |> Result.get