From bfaaaf614a1a2dc788a1b7de17761b5867aa9fee Mon Sep 17 00:00:00 2001 From: HLWeil Date: Thu, 29 Aug 2024 09:54:30 +0200 Subject: [PATCH] fix single dot in paths being interpreted as folder --- src/FileSystem/Path.fs | 1 + tests/ARCtrl/ARCtrl.Tests.fs | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/FileSystem/Path.fs b/src/FileSystem/Path.fs index a3c3ddf2..d5a0967d 100644 --- a/src/FileSystem/Path.fs +++ b/src/FileSystem/Path.fs @@ -34,6 +34,7 @@ let [] StudiesResourcesFolderName = "resources" let split(path: string) = path.Split(seperators, enum(3)) + |> Array.filter (fun p -> p <> "" && p <> ".") let combine (path1 : string) (path2 : string) : string = let path1_trimmed = path1.TrimEnd(seperators) diff --git a/tests/ARCtrl/ARCtrl.Tests.fs b/tests/ARCtrl/ARCtrl.Tests.fs index 26e71ccf..1ae71f6b 100644 --- a/tests/ARCtrl/ARCtrl.Tests.fs +++ b/tests/ARCtrl/ARCtrl.Tests.fs @@ -10,12 +10,16 @@ open ARCtrl.Spreadsheet open ARCtrl.Helper open FsSpreadsheet -let private tests_model = testList "model" [ - testCase "create" <| fun _ -> +let tests_create = testList "create" [ + testCase "empty" <| fun _ -> let arc = ARC() Expect.isNone arc.CWL "cwl" Expect.isNone arc.ISA "isa" - testCase "fromFilePath" <| fun _ -> +] + +let private tests_fromFilePaths = testList "fromFilePaths" [ + + testCase "simple" <| fun _ -> let input = [|@"isa.investigation.xlsx"; @".arc\.gitkeep"; @".git\config"; @".git\description"; @".git\HEAD"; @"assays\.gitkeep"; @"runs\.gitkeep"; @@ -47,6 +51,14 @@ let private tests_model = testList "model" [ Expect.isNone arc.ISA "isa" let actualFilePaths = arc.FileSystem.Tree.ToFilePaths() |> Array.sort Expect.equal actualFilePaths input "isSome fs" + testCase "correctContractsFor(.)AtBeginning" <| fun _ -> + let input = [| + @"./isa.investigation.xlsx" + @"./assays/TestAssay1/isa.assay.xlsx" + @"./studies/TestAssay1/isa.study.xlsx";|] + let arc = ARC.fromFilePaths(input) + let contracts = arc.GetReadContracts() + Expect.hasLength contracts 3 "should have read 3 contracts" ] let private simpleISAContracts = @@ -931,7 +943,8 @@ let tests_RenameStudy = testList "RenameStudy" [ ] let main = testList "ARCtrl" [ - tests_model + tests_create + tests_fromFilePaths tests_updateFileSystem tests_read_contracts tests_writeContracts