From 5baa5b15bce0dbdaedd9f8ee4e0aa8d2e185f633 Mon Sep 17 00:00:00 2001 From: Kai Jaeger Date: Sat, 28 Dec 2024 19:48:26 +0100 Subject: [PATCH] Tests for .linkconfig added --- APLSource/.linkconfig | 11 +++++++- APLSource/Cider/CloseProject.aplf | 12 +++++---- APLSource/Cider/UC/LinkConfig.aplf | 4 +-- APLSource/TestCases/Test_Misc_010.aplf | 4 +-- APLSource/TestCases/Test_UC_200.aplf | 9 +++---- APLSource/TestCases/Test_UC_201.aplf | 27 +++++++++++++++++++ APLSource/TestCases/Test_UC_202.aplf | 21 +++++++++++++++ .../\342\210\206GetRefToCommTools.aplf" | 2 +- TestData/Boo-Project/APLSource/.linkconfig | 11 ++++++++ apl-package.json | 2 +- 10 files changed, 85 insertions(+), 18 deletions(-) create mode 100644 APLSource/TestCases/Test_UC_201.aplf create mode 100644 APLSource/TestCases/Test_UC_202.aplf create mode 100644 TestData/Boo-Project/APLSource/.linkconfig diff --git a/APLSource/.linkconfig b/APLSource/.linkconfig index d07045b4..288399a9 100644 --- a/APLSource/.linkconfig +++ b/APLSource/.linkconfig @@ -1 +1,10 @@ -{ LinkVersion: { ID: "4.0.20"}, Settings: { fastLoad: 1, forceFilenames: 1, watch: "both", }, } + +{ + LinkVersion: { ID: "4.0.20"}, + + Settings: { + fastLoad: 1, + forceFilenames: 1, + watch: "both", + }, +} diff --git a/APLSource/Cider/CloseProject.aplf b/APLSource/Cider/CloseProject.aplf index d4e37cfb..3d9b1142 100644 --- a/APLSource/Cider/CloseProject.aplf +++ b/APLSource/Cider/CloseProject.aplf @@ -24,14 +24,16 @@ projects←⊆projects :For project :In projects project←⍕project - :If (∧/~'/\'∊project)∧~(1⊃project)∊'#⎕' - buff←(({⊃(-+/∧\~'⎕'=⊃¨⍵)↑⍵}⎕NSI),'.'),project - ('Could not identify: ',project)Assert 9=⊃⎕NC buff - project←buff - :EndIf :If ∧/'[]'∊project ind←list[;4]⍳⊂⎕C project~'[]' :Else + :If (∧/~'/\'∊project)∧~(1⊃project)∊'#⎕' + buff←(({⊃(-+/∧\~'⎕'=⊃¨⍵)↑⍵}⎕NSI),'.'),project + :If 9≠⊃⎕NC buff + :Continue + :EndIf + project←buff + :EndIf ind←(⎕C list[;1])⍳⊂⎕C project :EndIf :If ind>≢list diff --git a/APLSource/Cider/UC/LinkConfig.aplf b/APLSource/Cider/UC/LinkConfig.aplf index a4bbcbdd..604a7fc3 100644 --- a/APLSource/Cider/UC/LinkConfig.aplf +++ b/APLSource/Cider/UC/LinkConfig.aplf @@ -1,5 +1,5 @@ r←LinkConfig Args;folder;path;editFlag;deleteFlag;cfg;linkCfgPath;json;ref - path←''Args.Switch Args._1 + path←{0≡⍵:'' ⋄ ⍵}Args._1 editFlag←Args.edit deleteFlag←Args.delete '-edit and -delete are mutually exclusive'Assert(deleteFlag+editFlag)∊0 1 @@ -17,7 +17,7 @@ :If 0=≢(∊ref.linkconfig)~' ' r←'Cancelled by user' :ElseIf json≢ref.linkconfig - :If 0=1 ##.CommTools.YesOrNo'SaveLinkConfigChanges@Save Link Config changes?' + :If 0=1 ##.CommTools.YesOrNo'SaveLinkConfigChanges@Save ',linkCfgPath,'?' r←'Cancelled by user' ⋄ →0 :Else (⊂ref.linkconfig)⎕NPUT linkCfgPath 1 diff --git a/APLSource/TestCases/Test_Misc_010.aplf b/APLSource/TestCases/Test_Misc_010.aplf index ee95cb07..c264ae5e 100644 --- a/APLSource/TestCases/Test_Misc_010.aplf +++ b/APLSource/TestCases/Test_Misc_010.aplf @@ -17,8 +17,8 @@ cfg←⊃⎕NGET filename ns←⎕JSON⍠('Dialect' 'JSON5')⊢cfg (⊂buff)⎕NPUT filename 1 ⍝ Paranoia - expected←'CIDER' 'SYSVARS' 'USER' ⍝ Cider itself does not have a LINK section anymore - →T.PassesIf expected≡' '~¨⍨↓ns.⎕NL 9 + expected←'CIDER' 'SYSVARS' 'USER' + →T.PassesIf expected≡(' '~¨⍨↓ns.⎕NL 9)~⊂'LINK' ⍝ Cider itself will not have a LINK section anymore soon r←T._OK ⍝Done diff --git a/APLSource/TestCases/Test_UC_200.aplf b/APLSource/TestCases/Test_UC_200.aplf index a0e8a0c8..0c13a3b4 100644 --- a/APLSource/TestCases/Test_UC_200.aplf +++ b/APLSource/TestCases/Test_UC_200.aplf @@ -1,14 +1,11 @@ - R←Test_UC_200(stopFlag batchFlag);⎕TRAP;rc;msg;res;stop;ns;expected + R←Test_UC_200(stopFlag batchFlag);⎕TRAP;rc;msg;res;stop ⍝ Print contents of a .linkconfig file to the session ⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N') R←T._Failed - ∘∘∘ stop←0 - (rc msg res)←stop ∆UCMD'ListTatinDependencies' + (rc msg res)←stop ∆UCMD'LinkConfig' Assert rc=0 - ns←##.Cider.Get_JSON5 #.Cider.CiderConfig.HOME,'/cider.config' - expected←FilesAndDirs.EnforceSlash∘FilesAndDirs.AddTrailingSep¨{⍵↑⍨¯1+⍵⍳'='}¨ns.CIDER.(dependencies dependencies_dev).tatin - →T.PassesIf∧/expected∊res[;] + →T.PassesIf ∨/'*** Link config file'⍷∊res ⍝Done diff --git a/APLSource/TestCases/Test_UC_201.aplf b/APLSource/TestCases/Test_UC_201.aplf new file mode 100644 index 00000000..2102fd0c --- /dev/null +++ b/APLSource/TestCases/Test_UC_201.aplf @@ -0,0 +1,27 @@ + R←Test_UC_201(stopFlag batchFlag);⎕TRAP;rc;msg;res;stop;ref;tempDir;json;ns +⍝ Let the user edit a Link config file + ⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N') + R←T._Failed + + :If ~batchFlag + CommTools.Pause'This test needs you: when an edit window pops up, change "CiderTest" from 1 to 2, then close the window.' + :EndIf + + tempDir←∆GetFolderInTempDir⊃⎕SI + tempDir ⎕NCOPY ##.CiderConfig.HOME,'/TestData/Boo-Project' + + ref←∆GetRefToCommTools + ref.AddAutomation'YesOrNo' 'SaveLinkConfigChanges@' 'y' + + stop←0 + (rc msg res)←stop ∆UCMD'LinkConfig ',tempDir,'/Boo-Project -edit' + Assert rc=0 + →T.GoToTidyUp'Changes got saved, but are not reflected in the workspace!'≢res + json←⊃⎕NGET tempDir,'/Boo-Project/APLSource/.linkconfig' + ns←⎕JSON⍠('Dialect' 'JSON5')⊢json + →T.GoToTidyUp 2≠ns.CiderTest + +∆TidyUp: + ref.Cleanup + {}FilesAndDirs.RmDirByForce tempDir +⍝Done diff --git a/APLSource/TestCases/Test_UC_202.aplf b/APLSource/TestCases/Test_UC_202.aplf new file mode 100644 index 00000000..331168fe --- /dev/null +++ b/APLSource/TestCases/Test_UC_202.aplf @@ -0,0 +1,21 @@ + R←Test_UC_202(stopFlag batchFlag);⎕TRAP;rc;msg;res;stop;tempDir;ref +⍝ Let the user delete a Link config file + ⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N') + R←T._Failed + + tempDir←∆GetFolderInTempDir⊃⎕SI + tempDir ⎕NCOPY ##.CiderConfig.HOME,'/TestData/Boo-Project' + Assert ⎕NEXISTS tempDir,'/Boo-Project/APLSource/.linkconfig' + + ref←∆GetRefToCommTools + ref.AddAutomation'YesOrNo' 'DeleteLinkConfig@' 'y' + + stop←0 + (rc msg res)←stop ∆UCMD'LinkConfig ',tempDir,'/Boo-Project -delete' + Assert rc=0 + →T.GoToTidyUp 0≠⎕NEXISTS tempDir,'/Boo-Project/APLSource/.linkconfig' + +∆TidyUp: + ref.Cleanup + {}FilesAndDirs.RmDirByForce tempDir +⍝Done diff --git "a/APLSource/TestCases/\342\210\206GetRefToCommTools.aplf" "b/APLSource/TestCases/\342\210\206GetRefToCommTools.aplf" index 30d3b34a..2a4f47dd 100644 --- "a/APLSource/TestCases/\342\210\206GetRefToCommTools.aplf" +++ "b/APLSource/TestCases/\342\210\206GetRefToCommTools.aplf" @@ -1,7 +1,7 @@ r←∆GetRefToCommTools ⍝ Depending of whether there is a variable "DEVLOPMENT" set in ⎕SE.Cider and it is 1 ⍝ this function returns a ref to Cider in either ⎕SE or #. -⍝ This is an important destinction in case the variables in CoommTools nees to be specified +⍝ This is an important destinction in case the variables in CommTools nees to be specified ⍝ to pretend a human being making decisions/selections. :If 0<⎕SE.Cider.⎕NC'DEVELOPMENT' :AndIf 0<⎕SE.Cider.DEVELOPMENT diff --git a/TestData/Boo-Project/APLSource/.linkconfig b/TestData/Boo-Project/APLSource/.linkconfig new file mode 100644 index 00000000..633d1dc6 --- /dev/null +++ b/TestData/Boo-Project/APLSource/.linkconfig @@ -0,0 +1,11 @@ + +{ + LinkVersion: { ID: "4.0.20"}, + + Settings: { + fastLoad: 1, + forceFilenames: 1, + watch: "both", + }, + CiderTest: 1, +} diff --git a/apl-package.json b/apl-package.json index 1e23f71a..b9e9e301 100644 --- a/apl-package.json +++ b/apl-package.json @@ -21,5 +21,5 @@ tags: "project-management", tatin_version: "0.103.0", userCommandScript: "APLSource/Cider_UC.dyalog", - version: "0.46.0-beta-21+869", + version: "0.46.0-beta-22+870", }