Skip to content

Commit

Permalink
Test cases amended
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Apr 23, 2023
1 parent bcb8e53 commit 4dc6571
Show file tree
Hide file tree
Showing 71 changed files with 624 additions and 380 deletions.
331 changes: 165 additions & 166 deletions APLSource/Cider/Cider.aplc

Large diffs are not rendered by default.

115 changes: 81 additions & 34 deletions APLSource/Cider_uc.dyalog
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:Class Cider_UC
User Command class for the project manager "Cider"
Kai Jaeger
2023-03-15
2023-03-23

⎕IO1 ⎕ML1 ⎕WX3
MinimumVersionOfDyalog'18.0'
Expand Down Expand Up @@ -236,12 +236,12 @@
pathArgs._1
:EndIf
aliasDefsP.GetAliasFileContent
:If (,path),¨'[' '[?' '[?]'
:If path'[?]'
bool~aliasDefs[;2]{[;2]}P.ListOpenProjects 0
:If 0=pathSelectFromAliases boolaliasDefs
:Return
:EndIf
:ElseIf '['=1path
:ElseIf '[]'path[1,path]
:AndIf '*'=¯1path~'[]'
bool~aliasDefs[;2]{[;2]}P.ListOpenProjects 0
boolbool\(¯1path~'[]'){(⎕C()[2]).=⎕C }boolaliasDefs[;1]
Expand All @@ -260,7 +260,7 @@
:EndIf
:EndSelect
:EndIf
path⎕C('['path)path
path⎕C('[]'path[1,path])path
parmsP.CreateOpenParms''
parms.folderpath
parms.projectSpaceArgs.projectSpace
Expand Down Expand Up @@ -321,15 +321,19 @@
:Select ⎕C Cmd
:Case ⎕C'OpenProject'
r,'Takes a path to a folder that must contain a file "',configFilename,'" (JSON5).'
r,''
r,'The config file must specify all variables required by Cider, including "source".'
r,'The contents of "source" is then linked to "parent.projectSpace" by default.'
r,''
r,'If no folder is specified Cider looks for a file "',configFilename,'" in the'
r,'current directory. If no such file is found then...'
r,' * under Windows a dialog box is opened that allows you to navigate to the intended folder'
r,' * an error is thrown on non-Windows platforms'
r,''
r,'You may use an alias rather than a path; see -alias= for how to define an alias.'
r,'An alias must be embraced by square brackets, for exampel:'
r,' ]Cider.OpenProject [alias]'
r,'You can also ask Cider for a list of all known aliases with:'
r,' ]Cider.OpenProject [?]'
r,''
r,'-quiet: The user command prints messages to the session unless -quiet is specified.'
r,'-parent: The project is loaded into Cider.(parent.projectSpace) unless this is (temporarily)'
r,' overwritten by setting the -parent= and/or the -projectSpace= option(s).'
Expand All @@ -338,26 +342,19 @@
r,'-import: By default the namespace is linked to folder. By specifying the -import'
r,' flag this can be avoided: the code is then loaded into the workspace with the'
r,' Link.Import method, meaning that changes are not tracked.'
r,' This flag has also side effects: neither that status of any installed Tatin'
r,' packages is checked nor the Git status of the project.'
r,' With -import the status of neither Git nor any installed Tatin packages is checked.'
r,'-alias: In case you are going to work on a project frequently you may specify'
r,' -alias=name'
r,' Later on you may open the project with:'
r,' ]Cider.OpenProject [name]'
r,' You can also ask Cider for a list of all known aliases with:'
r,' ]Cider.OpenProject [?]'
r,' Cider will then allow you to select one of the projects.'
r,' (In order to remove an alias use ]Cider.ListAliases -edit)'
r,'-noPkgLoad: By default the Tatin packages from the installation folder(s) defined in the'
r,' config will be loaded. If you don''t want this specify -noPkgLoad'
r,'-watch Defaults to "both" but may be "ns" or "dir" instead.'
r,'-watch Defaults to "both" (if .NET is available) but may be "ns" or "dir" instead.'
r,' * "ns" means that changes in the workpace are saved on disk'
r,' * "dir" means that any changes on disk are brought into the WS'
r,' * "both" means that any changes in either "ns" or "dir" are reflected accordingly'
r,' However, note that currently "both" works only under Windows. On other platforms'
r,' "both" is identical with "ns" for the time being.'
r,' Note also that this change is temporary: it does NOT change the config file on disk'
r,' You are adviced to study the Link documentation on this for details.'
r,' However, currently "both" works only under Windows.'
r,' Note that the flag does NOT change the config file on disk'
r,' Refere to the Link documentation for details.'
:Case ⎕C'ListOpenProjects'
r,'Print a list with the namespaces of all currently opened projects.'
r,'Add the -verbose flag for more information. Then a matrix is returned with these columns:'
Expand Down Expand Up @@ -423,6 +420,8 @@
r,' * Nothing; equivalent to -all but the user will be asked for confirmation'
r,' * The -all flag, which closes all projects without further ado'
r,''
r,'Multiple projects must be separated by spaces or by commas.'
r,''
r,'Result:'
r,' * In case a particular project was specified a Boolean is reported, 1 indicating success'
r,' * If all projects are closed all names and theirs paths are reported'
Expand Down Expand Up @@ -600,10 +599,14 @@
:EndIf

{name}CreateConfigFile(filename name);config
{name}CreateConfigFile(filename name);config;globalCiderConfigFilename
Copies the config template file over and injects the last part of the path of "filename" as "projectSpace"
('The folder already hosts a file "',configFilename,'"')Assert~⎕NEXISTS filename
config⎕JSON('Dialect' 'JSON5')⎕NGET(P.##.TatinVars.HOME),'/',configFilename,'.template'
globalCiderConfigFilename⎕SE.Cider.GetCiderConfigHomeFolder,'cider.config.template'
:If 0=⎕NEXISTS globalCiderConfigFilename
globalCiderConfigFilename(⎕NCOPY P.##.FilesAndDirs.ExecNfunction)P.##.TatinVars.HOME,'/cider.config.template'
:EndIf
config⎕JSON('Dialect' 'JSON5')P.##.FilesAndDirs.NGET globalCiderConfigFilename
:If ~⎕SE.Cider.HasDotNet
config.LINK.watch'ns'
:EndIf
Expand All @@ -613,7 +616,26 @@
((~name⎕D,⎕A,'_∆⍙',⎕C ⎕A)/name)'_'
config.CIDER.projectSpacename
config⎕JSON('Dialect' 'JSON5')('Compact' 0)config
(config)⎕NPUT filename
(config)P.##.FilesAndDirs.NPUT filename

rGetUserConfigFileTemplate;folder;filename
Checks whether the user has already a personal config file template.
If not the generic Cider config file template is copied into the user's Cider home folder,
Eventually the template is returned.
folder⎕SE.Cider.GetCiderConfigHomeFolder
filenamefolder',/cider.config.template'
:If ~##.FilesAndDirs.Exists filename
:If 0<##.⎕NC'TatinVars'
filename ⎕NCOPY ##.TatinVars.HOME,'/cider.config.template'
:Else
filename ⎕NCOPY CiderConfig.HOME,'/cider.config.template'
:EndIf
:EndIf
:If

:EndIf
r⎕JSON('Dialect' 'JSON5')⎕NGET filename

(opCode path)OpenFileDialogBox caption;ref;res;filename
Expand All @@ -640,7 +662,7 @@


rCloseProject Args;list;names;bool;row;invalid;q;noop;report
rCloseProject Args;list;bool;row;invalid;q;noop;report;projectID;buff
r''
report1
:If 0=Args.Arguments
Expand All @@ -649,29 +671,36 @@
:Return
:Else
:If 1=noop
:If 1 YesOrNo'Sure you want close the project <',(list[1;]),'>?'
rP.CloseProject
:If 1 YesOrNo'Sure you want to close the project <',(list[1;]),'>?'
rbuffP.CloseProject
:Else
r'Cancelled by user' 0
:EndIf
:ElseIf Args.all
q'Currently there ',((1+1<noop)'is one'('are ',noop)),' project',((1<noop)/'s'),' opened - wanna close ',(1+1<noop)'it?' 'all of them?'
:OrIf YesOrNo q
rP.CloseProject
r+/P.CloseProject
'Something went wrong'Assert rlist
r1(⎕UCS 13),¨⎕FMT list
:EndIf
:EndIf
:Else
namesArgs.Arguments
:If 1invalid~{()'#⎕['}¨names
11 ⎕SIGNAL'Project name(s) must be fully qualified but are not: ',{,',',}/invalid/names
projectID{,' ',}/Args.Arguments Can be a namespace, a path or an alias
((projectID=',')/projectID)' '
projectID' '()projectID
projectIDTranslateAlias¨projectID
:If 0invalid(~/¨'/\'¨projectID)~({1 ⎕C ¯1+'.'}¨projectID),¨'#' '⎕SE'
(invalid/projectID)('#.'),¨invalid/projectID
:EndIf
:If 1invalid~{(⎕NS'').{0=⎕NC }~'[]'}¨names
11 ⎕SIGNAL'Invalid project name(s): ',{,',',}/invalid/names
:If 1invalid~{(⎕NS'').{0=⎕NC }~'[]'}¨projectID
11 ⎕SIGNAL'Invalid project name(s): ',{,',',}/invalid/projectID
:EndIf
listP.ListOpenProjects 0
r+/P.CloseProject¨names
invalid~((⎕C projectID)⎕C list[;1])(P.##.FilesAndDirs.NormalizePath projectID)P.##.FilesAndDirs.NormalizePath list[;2]
:If 1invalid
('Not an open Cider project: ',{,',',}/invalid/projectID)Assert/~invalid
:EndIf
r+/listP.CloseProject¨projectID
:EndIf
:If 0<r
:If ' '=10r
Expand Down Expand Up @@ -707,6 +736,17 @@
:EndIf

rTranslateAlias alias;aliase;row
:If '[]'alias[1,alias]
aliase⎕SE.Cider.GetAliasFileContent
rowaliase[;1]alias~'[]'
('Unknown alias: ',alias)Assert rowaliase
r2aliase[row;]
:Else
ralias
:EndIf

rShowHelp dummy;list;folder;flag;answer;msg
r''
folder1⎕NPARTS ##.SourceFile
Expand Down Expand Up @@ -878,11 +918,18 @@

{r}PerformConfigChecks config;buff;namespace;path
r0
:If 0<buffconfig.CIDER.tatinFolder
:If 0<buffconfig.CIDER.dependencies.tatin
:If '='buff
'Invalid config parameter ("dependencies.tatin" has more than one "=")'Assert 1='='+.=buff
(path namespace)'='()buff
'Invalid config parameter ("dependencies.tatin")'Assert 0=(⎕NS'').{⎕NC }namespace
:EndIf
:EndIf
:If 0<buffconfig.CIDER.dependencies_dev.tatin
:If '='buff
'Invalid config parm ("tatinFolder" has more than one "=")'Assert 1='='+.=buff
'Invalid config parameter ("dependencies_dev.tatin" has more than one "=")'Assert 1='='+.=buff
(path namespace)'='()buff
'Invalid config parm (Tatin folder)'Assert 0=(⎕NS'').{⎕NC }namespace
'Invalid config parameter ("dependencies_dev.tatin")'Assert 0=(⎕NS'').{⎕NC }namespace
:EndIf
:EndIf
Expand Down
4 changes: 3 additions & 1 deletion APLSource/TestCases/Test_Alias_007.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@

(rc msg res)∆UCMD'CloseProject [firlefanz1]'
msg Assert 0=rc
T.GoToTidyUp'Number of projects closed: 1'res
#.⎕EX'TEMP' #.⎕SHADOW'TEMP' 'TEMP'#.⎕NS''

(rc msg res)∆UCMD'OpenProject [firlefanz1] -parent=#.TEMP -alias=Firlefanz2 -quiet -watch=ns'
msg Assert 0=rc

aliase⎕SE.Cider.GetAliasFileContent

(rc msg res)∆UCMD'CloseProject [firlefanz1]'
(rc msg res)∆UCMD'CloseProject [firlefanz2]'
msg Assert 0=rc
T.GoToTidyUp'Number of projects closed: 1'res

T.GoToTidyUp('firlefanz1')aliase[;1]
T.GoToTidyUp~('firlefanz2')aliase[;1]
Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_Create_061.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
stop0
(rc msg res)stop ∆UCMD'CreateProject "',tempDir,'" -noEdit -acceptConfig -quiet'
T.GoToTidyUp 0=rc
T.GoToTidyUp 1+/'Invalid config parm (Tatin folder)'msg
T.GoToTidyUp 1+/'Invalid config parameter ("dependencies.tatin")'msg

RT._OK

Expand Down
8 changes: 3 additions & 5 deletions APLSource/TestCases/Test_Misc_003.aplf
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
RTest_Misc_003(stopFlag batchFlag);⎕TRAP;folder;parms;list;filename;cfg;was;rc;success;log;res
Exercise the ListOpenProjects function with ExecuteAfterProjectOpen set
Exercise the OpenProject function with ExecuteAfterProjectOpen set
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

'TEMP'#.⎕NS''
'TEMP2'#.⎕NS''
'TEMP2' 'TEMP'#.⎕NS¨''
#.TEMP2.∆FLAG0

folder∆GetTestPath⎕SI

filename##.Cider.Cider.GetCiderConfigFilename
cfg⎕JSON('Dialect' 'JSON5')⎕NGET filename


wascfg.{0=⎕nc'ExecuteAfterProjectOpen':'' ExecuteAfterProjectOpen}
wascfg.{0=⎕NC'ExecuteAfterProjectOpen':'' ExecuteAfterProjectOpen}
cfg.ExecuteAfterProjectOpen'#.TEMP2.ExecuteAfterProjectOpen'
#.TEMP2.⎕FX'ExecuteAfterProjectOpen config' '∆FLAG←1'
(⎕JSON('Compact' 0)('Dialect' 'JSON5')cfg)⎕NPUT filename 1
Expand Down
16 changes: 9 additions & 7 deletions APLSource/TestCases/Test_UC_001.aplf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
rTest_UC_001(stopFlag batchFlag);⎕TRAP;tempDir;parms;list;rc;msg;result;res;log
Exercise the user command on "CloseProject" with a not fully qualified name
Exercise the user command on "CloseProject" on a project that was loaded into a non-default "parent"
Should work anyway if there is just one project with that name
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
rT._Failed

#.⎕EX'Foo'
#.⎕EX'Goo' 'Goo'#.⎕NS''
tempDirFilesAndDirs.GetTempSubDir⎕SI
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')

Expand All @@ -15,19 +15,21 @@
parms.foldertempDir
parms.quietFlag1
parms.watch'ns'
parms.parent'#.Goo'
(res log)##.Cider.Cider.OpenProject parms

T.GoToTidyUp 0=list##.Cider.Cider.ListOpenProjects 0

(rc msg result)∆UCMD'CloseProject Foo'
T.GoToTidyUp~/'Project name(s) must be fully qualified but are not: Foo'msg
(rc msg result)∆UCMD'CloseProject #.Goo.Foo'
msg Assert rc=0
T.GoToTidyUp'Number of projects closed: 1'result

rT._OK

∆TidyUp:
{}∆UCMD'CloseProject #.Foo'
∆LINK'Break' '#.Foo' We DO NOT check here because when everything is working fine then it's not linked anymore.
{}∆UCMD'CloseProject #.Foo.Goo'
∆LINK'Break' '#.Foo.Goo' We DO NOT check here because when everything is working fine then it's not linked anymore.
rcFilesAndDirs.RmDir tempDir
Assert 0=+/rc
#.⎕EX'Foo'
#.⎕EX'Goo'
Done
23 changes: 0 additions & 23 deletions APLSource/TestCases/Test_UC_044.aplf

This file was deleted.

Loading

0 comments on commit 4dc6571

Please sign in to comment.