Skip to content

Commit

Permalink
Tests for .linkconfig added
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Dec 29, 2024
1 parent 41c7c07 commit 5baa5b1
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 18 deletions.
11 changes: 10 additions & 1 deletion APLSource/.linkconfig
Original file line number Diff line number Diff line change
@@ -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",
},
}
12 changes: 7 additions & 5 deletions APLSource/Cider/CloseProject.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
projectsprojects
:For project :In projects
projectproject
:If (/~'/\'project)~(1project)'#⎕'
buff(({(-+/\~''=¨)}⎕NSI),'.'),project
('Could not identify: ',project)Assert 9=⎕NC buff
projectbuff
:EndIf
:If /'[]'project
indlist[;4]⎕C project~'[]'
:Else
:If (/~'/\'project)~(1project)'#⎕'
buff(({(-+/\~''=¨)}⎕NSI),'.'),project
:If 9⎕NC buff
:Continue
:EndIf
projectbuff
:EndIf
ind(⎕C list[;1])⎕C project
:EndIf
:If ind>list
Expand Down
4 changes: 2 additions & 2 deletions APLSource/Cider/UC/LinkConfig.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rLinkConfig Args;folder;path;editFlag;deleteFlag;cfg;linkCfgPath;json;ref
path''Args.Switch Args._1
path{0:'' }Args._1
editFlagArgs.edit
deleteFlagArgs.delete
'-edit and -delete are mutually exclusive'Assert(deleteFlag+editFlag)0 1
Expand All @@ -17,7 +17,7 @@
:If 0=(ref.linkconfig)~' '
r'Cancelled by user'
:ElseIf jsonref.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
Expand Down
4 changes: 2 additions & 2 deletions APLSource/TestCases/Test_Misc_010.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -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

rT._OK
Done
9 changes: 3 additions & 6 deletions APLSource/TestCases/Test_UC_200.aplf
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
RTest_UC_200(stopFlag batchFlag);⎕TRAP;rc;msg;res;stop;ns;expected
RTest_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')
RT._Failed

∘∘∘
stop0
(rc msg res)stop ∆UCMD'ListTatinDependencies'
(rc msg res)stop ∆UCMD'LinkConfig'
Assert rc=0
ns##.Cider.Get_JSON5 #.Cider.CiderConfig.HOME,'/cider.config'
expectedFilesAndDirs.EnforceSlashFilesAndDirs.AddTrailingSep¨{¯1+'='}¨ns.CIDER.(dependencies dependencies_dev).tatin
T.PassesIf/expectedres[;]
T.PassesIf /'*** Link config file'res

Done
27 changes: 27 additions & 0 deletions APLSource/TestCases/Test_UC_201.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
RTest_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')
RT._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'

stop0
(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 2ns.CiderTest

∆TidyUp:
ref.Cleanup
{}FilesAndDirs.RmDirByForce tempDir
Done
21 changes: 21 additions & 0 deletions APLSource/TestCases/Test_UC_202.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
RTest_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')
RT._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'

stop0
(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
2 changes: 1 addition & 1 deletion APLSource/TestCases/∆GetRefToCommTools.aplf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 11 additions & 0 deletions TestData/Boo-Project/APLSource/.linkconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

{
LinkVersion: { ID: "4.0.20"},

Settings: {
fastLoad: 1,
forceFilenames: 1,
watch: "both",
},
CiderTest: 1,
}
2 changes: 1 addition & 1 deletion apl-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

0 comments on commit 5baa5b1

Please sign in to comment.