Skip to content

Commit

Permalink
Bug fix in UnInstallPackages and restructured tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Sep 30, 2023
1 parent 9b47d99 commit fda6260
Show file tree
Hide file tree
Showing 984 changed files with 456 additions and 134,115 deletions.
159 changes: 124 additions & 35 deletions APLSource/APLProcess.aplc
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
:Class APLProcess
Start (and eventually dispose of) an APL Process.\\
By default the version of Dyalog APL a new process is going to be created from defines which version
Start (and optionally dispose of) an APL Process.\\
By default the version of Dyalog APL a new process is going to be created from defines, which version
of APL will be started, be it development or runtime.\\
You can change that by first creating a parameter space by calling `CreateParms`, then making the necessary
adjustments, and finally passing that namespace as parameter to `⎕NEW` when instantiating `APLProcess`.\\
Instead of passing a parameter space to the constructor you can also pass a simple text vector, specifying a
workspace and possibly other command line parameters like, say, `MAXWS=32GB` and the like.\\
Whether it is a parameter space or a character vector, when passed as argument to `⎕NEW` is must be a nested
vecor, for example:\\
```
⎕NEW APLProcess (,⊂parmspace) ⍝ parameter space
⎕NEW APLProcess (,⊂'') ⍝ Character vector
```
Notes:
* This class is designed for test cases that require one or more additional instances of APL for some reason.
For that reason it does not offer encryption for a RIDE.\\
That's why it does not offer encryption for a RIDE.\\
This restriction might be lifted at a later stage depending on demand.
* The destructor of this class will attempt to kill the process that was started.\\
* The destructor of this class will attempt to kill the process that was started (only relevant with `ait←0`).\\

⎕IO1 ⎕ML1

rVersion
See also `History`
:Access Public Shared
r'APLProcess' '0.5.1' '2021-05-08' Still work in progress, especially on the Mac
r'APLProcess' '0.7.0' '2023-09-26' Without Ride all fine, with Ride the Mac is still posing problems

rHistory
:Access Public Shared
* 0.7.0 from 2023-09-26
* Now APLProcess can use .NET or .NET Framework (former version only worked with .NET Framework)
* 0.6.0 from 2021-05-27
* BREAKING CHANGE: the property `LogFilename` has been renamed: `OutputFilename`
* With `Wait←1` a return code is returned now
* A parameter space is now copied rather than modified
* Problems on Linux fixed
* Problems on Mac-OS fixed accept when you need a Ride
* 0.5.1 from 2021-05-08
* Bug fix: addressing APLTreeUtils2 did not always work
* 0.5.0 from 2021-05-02
Expand All @@ -34,7 +49,7 @@
* Package config file corrected
* 0.4.0 from 2021-01-29
* Fully transformed into a Tatin package
r{+/\()=' '}{''}¨{/''=¨}{+/\()=' '}¨1⎕NR⎕SI
r{+/\()=' '}{''}¨{/''=¨}{+/\()=' '}¨1⎕NR⎕SI Proc

:Field Public Instance Args'' Command line parameter (but not session_file!).
Expand Down Expand Up @@ -65,6 +80,13 @@
:EndProperty

:Property LogFilename
:Access Public Instance
rget
rProc.LogFilename
:EndProperty

:Property ExitCode
The exit code of the process. ¯1 means undefined.
:Access Public Instance
Expand Down Expand Up @@ -94,12 +116,13 @@
make_common
:If 2=⎕NC'y'
:AndIf (y)0 1
'Invalid right argument'Assert{16::0 1' '=10}y
:AndIf ' '=10y
commandliney
parmSpace
:ElseIf 0≡≡y
:AndIf 9=⎕NC'y'
parmSpacey
parmSpace⎕NS y
commandline
:Else
'Invalid right argument: must be either a parameter space or a text vector (command line)'Assert 0
Expand All @@ -117,7 +140,7 @@
parmSpace.CommandLineArgs1,/' ',¨buff
:EndIf
'Invalid window style'Assert(parmSpace.WindowsStyle)'Hidden' 'Maximized' 'Minimized' 'Normal'
(RidePort OUT_FILE WorkspaceName Args _Wait)parmSpace.(RidePort LogFilename WorkspaceName CommandLineArgs Wait)
(RidePort OUT_FILE WorkspaceName Args _Wait)parmSpace.(RidePort OutputFilename WorkspaceName CommandLineArgs Wait)
PATHSourcePath
Start parmSpace
Expand All @@ -129,18 +152,21 @@
APLTreeUtils2(⊃⊃⎕CLASS ⎕THIS).##.APLTreeUtils2

Start ps;psi;pid;cmd;host;port;keyfile;exe;z;output;args;Z;qdmx;ride
Start ps;Z;args;cmd;exe;host;keyfile;output;pid;port;psi;qdmx;ride;z
:If 0=ps.Exe
ps.Exe(GetRuntimeNameps.Runtime)GetCurrentExecutable else, deduce it
:EndIf
Exeps.Exe
ride''
:If 0ps.RidePort
ride'RIDE_INIT="SERVE:*:',(ps.RidePort),'" RIDE_SPAWNED=1 '
:Else
ride'RIDE_INIT= '
:EndIf
argsps.CommandLineArgs
args,(0<ps.LogFilename)/' LOG_FILE="',ps.LogFilename,'" '
NB Always set RIDE_INIT to override current process setting
args,(0<ps.OutputFilename)/' LOG_FILE="',ps.OutputFilename,'" '
output(1+×OUT_FILE)'/dev/null'OUT_FILE
Proc.LogFilename(7390),'/APLProcess-Logfile-',{⎕RL+/⎕TS ?}100000
:Select APLTreeUtils2.GetOperatingSystem
:Case 'Win'
:If ~ps.Runtime
Expand All @@ -156,42 +182,91 @@
:EndIf
:EndIf
cmdps.Exe
⎕USING'System,System.dll'

⎕USINGUsingSystemDiagnostics
psi⎕NEW Diagnostics.ProcessStartInfo,ps.Exe(({0=: '"',(~'"'),'" '}ps.WorkspaceName),args)
psi.WindowStyleDiagnostics.ProcessWindowStyle.ps.WindowsStyle
ProcDiagnostics.Process.Start psi
:If ps.Wait
Proc.WaitForExit
:EndIf
:Case 'Lin'
cmdride,' '
:If ps.Wait
cmd'"',ps.Exe,'" ',ps.WorkspaceName
cmd'"',ps.Exe,'"'
:If 0ride
cmd,' +s -q'
:EndIf
cmd,' "',(ps.WorkspaceName~'"'),'"'
cmd,' ',args
cmd,' ',ride
cmd,' 0<&- >/dev/null 2>&1'
Z⎕SH cmd
_ExitCode0
:If ps.RidePort=0
cmd,' 0<&-'
:EndIf
cmd,' 1>',output
cmd,,' 2>',Proc.LogFilename
:Trap 0
Z⎕SH cmd
_ExitCode0
:Else
qdmx⎕DMX
_ExitCode{{⊃⊃(//)⎕VFI¯1+' '}}qdmx.Message
:EndTrap
Proc.HasExited1
:Else
output(1+×OUT_FILE)'/dev/null'OUT_FILE
cmd'{ ',args,' ',ride,' "',ps.Exe,'" +s -q ',ps.WorkspaceName,' -c APLPPID=$PPID 0<&- 1>',output,' 2>&1 & } ; echo $!'
cmd'{ ',ride
cmd,{0=: ,' '}args
cmd,' "',ps.Exe,'"'
:If 0ride
cmd,' +s -q'
:EndIf
cmd,' "',(ps.WorkspaceName~'"'),'"'
:If ps.RidePort=0
cmd,' 0<&-'
:EndIf
cmd,' 1>',output
cmd,,' 2>',Proc.LogFilename
cmd,' & }'
cmd,'; echo $!'
pid⎕SH cmd
Proc.Id⊃⊃(//)⎕VFIpid
Proc.HasExited0
:EndIf
Proc.StartTime⎕TS
:Case 'Mac'
cmdride,' '
:If ps.Wait
cmdride
cmd,'"',ps.Exe,'" ',ps.WorkspaceName
cmd,' ',args
cmd,' 0<&- >/dev/null 2>&1'
Z⎕SH cmd
_ExitCode0
cmd,'"',ps.Exe,'" '
:If 0ride
cmd,' +s -q'
:EndIf
cmd,' "',(ps.WorkspaceName~' '),'"'
cmd,{0=: ' ',}args
:If ps.RidePort=0
cmd,' 0<&-'
cmd,' 1>',output
cmd,,' 2>',Proc.LogFilename
:Else
'Riding into a runtime is not implemented yet'⎕SIGNAL 11
:EndIf
:Trap 0
Z⎕SH cmd
_ExitCode0
:Else
qdmx⎕DMX
_ExitCode{{⊃⊃(//)⎕VFI¯1+' '}}qdmx.Message
:EndTrap
Proc.HasExited1
Proc.Id0
:Else
output(1+×OUT_FILE)'/dev/null'OUT_FILE
cmd'{ ',cmd,' ',ps.Exe,' +s -q ',ps.WorkspaceName,' -c APLPPID=$PPID 0<&- 1>',output,' 2>&1 & } ; echo $!'
cmd'{ ',cmd,' "',(ps.Exe~' '),'" "',(ps.WorkspaceName~' '),'" -c APLPPID=$PPID'
:If ps.RidePort=0
cmd,' 0<&-'
cmd,' 1>',output
cmd,,' 2>',Proc.LogFilename
cmd,'} ; echo $!'
:Else
'Riding into a runtime is not implemented yet'⎕SIGNAL 11/ps.Runtime
:EndIf
pid⎕SH cmd
Proc.Id⊃⊃(//)⎕VFIpid
Proc.HasExited0
Expand All @@ -217,7 +292,7 @@
|------------------|-------------|
| `CommandLineArg` | By default empty. Optional command line parameters passed to `Exe`. (Don't specify a session file here!)|
| `Exe` | Defaults to `''` which means that the same EXE is executed the instance was created from. Can also be a fully qualified name of the exe to be run.|
| `LogFilename` | By default empty, meaning that any output is thrown away. If this is specified it is expected to be the name of a file.|
| `OutputFilename` | By default empty, meaning that any output is thrown away. If this is specified it is expected to be the name of a file.|
| `RidePort` | By default 0 (no effect). When a positive integer > 0 this is used as port number for `RIDE_INIT`.|
| `Runtime` | Boolean that defaults to 0. Is ignored in case `Exe` is not empty.|
| `SessionFile` | Defaults to 0 which means no session file is loaded. A 1 will load the default DSE file. May also be the fully qualified path to a DSE file.|
Expand All @@ -227,7 +302,7 @@
r⎕NS''
r.CommandLineArgs''
r.Exe''
r.LogFilename''
r.OutputFilename''
r.RidePort0
r.Runtime0
r.SessionFile0
Expand All @@ -237,6 +312,14 @@
r.⎕FX'r←∆List;⎕IO' '⎕IO←⎕ML←1' 'r←{(⍵,[1.5]⎕nc¨⊂¨⍵),⍎¨⍵}(⊂''∆List'')~⍨⎕NL-2 9 3' Vars, refs and niladic functions

rGetLog
:Access Public Instance
r''
:If ⎕NEXISTS Proc.LogFilename
r⎕NGET Proc.LogFilename
:EndIf

WaitForKill(limit interval);count
:If 0<Proc.⎕NL-2
:If ~{0::1 .HasExited}Proc
Expand All @@ -260,7 +343,7 @@
'gmfn'⎕NA'U4 kernel32|GetModuleFileName* P =T[] U4'
r/gmfn 0(1024' ')1024
:If 0=r
⎕USING'System,system.dll'
⎕USINGUsingSystemDiagnostics
r2 ⎕NQ'.' 'GetEnvironment' 'DYALOG'
rr,(~(¯1r)'\/')/'/' Add separator if necessary
rr,(Diagnostics.Process.GetCurrentProcess.ProcessName),'.exe'
Expand Down Expand Up @@ -294,11 +377,7 @@
:Access Public Instance
Boolean that is 1 if and only if the process started by `APLProcess` has stopped running.
Under Windows .NET tells us. On non-Windows platforms we need to check
:If 'Win'APLTreeUtils2.GetOperatingSystem
rProc.HasExited
:Else
r0=Proc.Id OS.GetTaskList 0 0 0
:EndIf
r0=Proc.Id OS.GetTaskList 0 0 0

rGetPID
Expand Down Expand Up @@ -338,4 +417,14 @@

Assert{'' (,1),:r1 ⎕ML1 ⎕SIGNAL 1(),11}

rIsNetCore
:Access public shared
r(,'1'),2 ⎕NQ'.' 'GetEnvironment' 'DYALOG_NETCORE'

rUsingSystemDiagnostics
:Access public shared
r(1+IsNetCore)'System,System.dll' 'System,System.Diagnostics.Process'

:EndClass
9 changes: 7 additions & 2 deletions APLSource/Admin/RunTestServer.aplf
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{r}RunTestServer y;trapFlag;testFlag;iniFile
{r}RunTestServer y;trapFlag;testFlag;iniFile;args;bool
This function is used to run a test server started by the Tatin test cases.
`testFlag`, if 1, allows additional commands to be executed useful only for tests.
`trapFlag`, if specified and 1, overwites any INI settings and activates error trapping.
⎕TRAP0 'S'
r
⎕IO1 ⎕ML1
(testFlag trapFlag)2y,(y)¯1 ¯1
iniFile'./TestServer/Server/server.ini'
args2 ⎕NQ #'GetCommandLineArgs'
:If /bool'SERVERPATH='{1 ⎕C()}¨args
iniFile((1+'serverPath')argsbool),'/Server/server.ini'
:Else
iniFile'./TestServer/Server/server.ini'
:EndIf
riniFile(PrepareTestServer ##.Plodder.Run)testFlag trapFlag
##.Server.∆SHUTDOWN0
Done
10 changes: 7 additions & 3 deletions APLSource/Client/CheckBuildList.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
check again. If that does not help an error is thrown.
force{0<⎕NC : 0}' force'
folderReg.AddSlash folder
filename2folder,Reg.DependenciesFilename
filename1folder,Reg.BuildListFilename
filename2folder,Reg.DependenciesFilename
:If ~force
ts1GetFileTime filename1
Tatin always writes the dependency file first and the build list next to file,
yet the timestamps in the milliseconds sometimes pretend it to be the other way round.
Therefore we add one second to make sure that we only re-build the build list when the
dependency file has really been modified by a user with an editor.
ts11 GetFileTime filename1
ts2GetFileTime filename2
:EndIf
treeReadBuildList filename1
depsReadDependencyList filename2
deps_RemoveAlias¨deps
:If force
:If rforce
:OrIf rts2>ts1
:If F.IsFile filename1
bdeps_RemoveAlias¨tree[;2] Check consistency
Expand Down
10 changes: 8 additions & 2 deletions APLSource/Client/GetFileTime.aplf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
dtGetFileTime filename
dt{addFlag}GetFileTime filename
Returns "Last modified" for "filename".\\
dt60 ⎕DT7⊃⊃('type' 3)F.Dir filename
If `addFlag` is specified and 1 one second is added to the time stamp.
dt60 ⎕DT6⊃⊃('type' 3)F.Dir filename
:If 0<⎕NC'addFlag'
'Invalid left argument'Assert addFlag0 1
:AndIf addFlag
dt0.000001+dt
:EndIf
3 changes: 2 additions & 1 deletion APLSource/Client/ReadPackageConfigFile.aplf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cfgReadPackageConfigFile path;cfg_file;cfg;buff;Reg
Takes path to a package and returns the config file for that package as a namespace populated with variables.\\
`path` may or may not carry the filename.
`path` may or may not carry the filename.\\
If the config file could not be found and empty vector is returned.
Reg##.Registry
pathReplaceRegistryAlias path
:If Reg.IsHTTP path
Expand Down
11 changes: 11 additions & 0 deletions APLSource/Client/UnInstallPackages.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@
:EndIf
:EndIf
:If 0=newPrincipalPkgs
cfgReadPackageConfigFile folder,RemoveAlias packageID_2
:If 0<cfg.⎕NC'userCommandScript'
:AndIf 0<cfg.userCommandScript Is it a user command?!
F.DeleteFile folder,,/1⎕NPARTS cfg.userCommandScript
:EndIf
F.RmDir folder,RemoveAlias packageID_2
F.DeleteFile folder,¨'apl-buildlist.json' 'apl-dependencies.txt'
↓ This may happen when the last user command package was un-installed, for example:
:If 0=F.Dir folder,'/*'
(rc msg)F.RmDirByForce folder
:EndIf
list,packageID_2
:Else
:If 0<packageID_2
Expand Down
4 changes: 4 additions & 0 deletions APLSource/Registry/History.apla
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
(
'* 0.101.2 ⋄ 2023-09-29'
' * Bug fix in `UnInstallPackages`'
' * Internal changes'
' * A test run does not cause a plethora of "changed" messages by Git anymore'
'* 0.101.1 ⋄ 2023-09-26'
' * Bug fix in `]Tatin.UpdateTatin`'
'* 0.101.0 ⋄ 2023-09-25'
Expand Down
Loading

0 comments on commit fda6260

Please sign in to comment.