Skip to content

Commit 9f5dfe7

Browse files
committed
completed work on nosource and added/updated tests (#18)
1 parent 09d645d commit 9f5dfe7

6 files changed

+55
-35
lines changed

Diff for: DyalogBuild.dyalog

+45-20
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
2032 04 28 MBaas, v1.81: Check: additional context info in msgs of failing checks - if -halt is set, we also display the calling line
9595
2032 05 10 MBaas, v1.82: DTest now counts and reports the number of "Checks" that were executed (calls of function Check)
9696
2023 05 20 MBaas, v1.83: DBuild: the icon-parameter of the target-directivy may use "./" to indicate path relative to the location of the .dyalogbuild file
97-
2023 06 05 MBaas, v1.84: DBuild: added "nousource" directive and option for TARGET to save a dws w/o source (neccessary when building for Classic & Unicode!)
97+
2023 07 05 MBaas, v1.84: DBuild: added "nousource" directive and option for TARGET to save a dws w/o source (neccessary when building for Classic & Unicode!)
9898

9999

100100
DEBUG⎕se.SALTUtils.DEBUG used for testing to disable error traps ⍝ BTW, m19091 for that being "⎕se" (instead of ⎕SE) even after Edit > Reformat.
@@ -273,7 +273,7 @@
273273
:EndIf
274274
275275

276-
{names}{options}LoadCode file_target_mode;target;file;whatWeHave;f1;f2;f3;fl;fls;sep;sf;source;res;mode;larg
276+
{names}{options}LoadCode file_target_mode;target;file;whatWeHave;f1;f2;f3;fl;fls;sep;sf;source;res;mode;larg;ref
277277
loads code from scriptfile (NB: file points to one existing file, no pattern etc.)
278278
Options defines SALT options
279279
file_target_mode: (filename )
@@ -314,10 +314,16 @@
314314
:Select lc 3⎕NPARTS fl
315315
:CaseList '.dyalog' '.aplc' '.aplf' '.apln' '.aplo' '.apli'
316316
:Trap DEBUG0 ↓↓↓↓ be sure to pass target as a ref, bad things may happen otherwise ()
317-
res0({0:: }target)0 ⎕SE.SALT.Load fl,' ',options
318-
319-
source←⎕SE.SALT.Load fl,' -source=no' ⍝ unfortunately need two calls to establish function & get source
320-
source←1⊃⎕NGET fl
317+
source1⎕NGET fl 1
318+
:If {(1=)1,}~(⎕NC target)0 9 deal with name clashes
319+
:andif (,'#'),target
320+
('target="',(target),'" exists already with ⎕NC=',(⎕NC target),' and is protected')⎕SIGNAL(/' -protect'options)/11
321+
⎕EX target
322+
:EndIf
323+
ref{0:: }target
324+
ref.⍙src⍙source
325+
res←ref⍎'2⎕fix ⍙src⍙'
326+
res2 ref.⎕FIX'file://',fl
321327
:Else
322328
res'*** Error executing "⎕SE.SALT.Load ',fl,' -target=',(target,options),'": ',NL
323329
res,⎕DMX.(OSError{,2(×2)/'") ("',2}Message{,,': '/×}DM,'') CompCheck: ignore
@@ -1566,12 +1572,8 @@
15661572
:Case 'target'
15671573
:If (,0)2 args.Switch'save'
15681574
:AndIf (('2'GetNumParam'save')0 1)
1569-
('Type' 'I') Log'Found TARGET-Entry with SAVE-parameter, but modifier -save=',(save),' overruled it'
1575+
('Type' 'I')Log'Found TARGET-Entry with SAVE-parameter, but modifier -save=',(save),' overruled it'
15701576
:ElseIf Targetnull
1571-
:if (,2)2 args.Switch'nosource'
1572-
:andif ('2'GetNumParam'nosource')arg.Switch'nosource'
1573-
('Type' 'I')Log'Found TARGET-Entry with nosource=',(GetParam'nosource'),', but modifier -nosource=',(),' overruled it'
1574-
:endif
15751577
TargetListi line params names values
15761578
:EndIf
15771579
:Else
@@ -1601,16 +1603,29 @@
16011603
:EndIf
16021604

16031605
n3LOGS
1606+
:If DyaVersion19
1607+
:If nosource>¯1 if this is set
1608+
:AndIf 0<GetParam'nosource' and the TARGET instruction also has a nosource param
1609+
:AndIf ('2'GetNumParam'nosource')nosource and they are different
1610+
('Type' 'W')Log'Found TARGET-Entry with nosource=',(GetParam'nosource'),', but modifier -nosource=',(nosource),' overruled it'
1611+
:EndIf
1612+
:If (1=GetNumParam'nosource')02 args.Switch'nosource'
1613+
:OrIf 1=2 args.Switch'nosource'
1614+
{}5171#
1615+
{}51720
1616+
:EndIf
1617+
:Else
1618+
:If 0<GetParam'nosource'
1619+
:OrIf nosoure>¯1
1620+
('Type' 'W')Log'Using "nosource" requires at least Version 19'
1621+
:EndIf
1622+
:EndIf
16041623
:If 0=n if no errors were found
16051624
:If (save1)0=1TargetList save switch was set, but no target instruction given
16061625
pretend we had one which save under name of build file
16071626
TargetList1 50('target: ',name)('wsid=',name)(,'wsid')(,name)
16081627
:EndIf
16091628
:If save
1610-
:If 1=GetNumParam'nosource'
1611-
:orif 1=2 args.Switch'nosource'
1612-
5171#
1613-
:EndIf
16141629
:For (i line params names values) :In TargetList
16151630
:If 0tmpGetParam'wsid' ''
16161631
LogError'wsid missing'
@@ -1640,6 +1655,7 @@
16401655
:If save0 2
16411656
:Continue
16421657
:EndIf
1658+
16431659
Apr 21-research found these vars referencing # (or elements of it) - get them out of the way temporarily
16441660
rfs0 2''
16451661
⎕EX¨'⎕SE.',¨'SALTUtils.spc.z' 'SALTUtils.spc.res'
@@ -1884,7 +1900,7 @@
18841900
msg,' when DTest expected an empty charvec to indicate success'
18851901
:EndIf
18861902
:Else
1887-
msg'code returned character value = "',msg,'"'
1903+
msg'code returned character value = "',(¯1,msg,⎕UCS 10),'"'
18881904
:If SuccessValue''
18891905
msg,' that did not match SuccessValue=',{' '=⎕DR :'''',,'''' 'num ',((0 1⍴⍴msg)'scalar ' 'vector '),}SuccessValue
18901906
:Else
@@ -2024,6 +2040,10 @@
20242040
r,'' 'Optional modifiers are:'
20252041
r,' -clear[=NCs] expunge all objects, optionally of specified nameclasses only'
20262042
r,' -halt halt on error rather than log and continue'
2043+
:If 19DyaVersion
2044+
r,' -nosource do not preserve "source-as-typed" (neccessary if you want to create workspaces'
2045+
r,' that can be used on Classic and Unicode Editions!)'
2046+
:EndIf
20272047
r,' -production remove links to source files (and execute code given in PROD instructions in buildfile)'
20282048
r,' -quiet[=n] only output actual errors (quiet=2 only writes them to log, not into session)'
20292049
r,' -save[=0|1|2] save the build workspace (overwrites TARGET''s save option). Note: we only save if no errors were logged during Build process. save=2: do NOT save, but set ⎕WSID (according to TARGET Instruction in buildfile)'
@@ -2243,10 +2263,15 @@
22432263
:EndIf
22442264

22452265
:If 2=⎕NC'⎕se._cita._memStats'
2246-
t{0::((1 30 ¯1 0)⎕FSTAC t)t ⎕FCREATE 0 ⎕FSTIE 0}(1⎕NPARTS file),'MemRep'
2247-
⎕SE._cita._memStats ⎕FAPPEND t
2248-
⎕SE._cita.∆cpu ⎕FAPPEND t
2249-
⎕FUNTIE t
2266+
:Trap 0
2267+
t{0::((1 30 ¯1 0)⎕FSTAC t)t ⎕FCREATE 0 ⎕FSTIE 0}(1⎕NPARTS file),'MemRep'
2268+
⎕SE._cita._memStats ⎕FAPPEND t
2269+
⎕SE._cita.∆cpu ⎕FAPPEND t
2270+
⎕FUNTIE t
2271+
:Else
2272+
'Caught error writing mem stats into ',(1⎕NPARTS file),'MemRep:'
2273+
(⎕JSON ⎕OPT'Compact' 0)⎕DMX
2274+
:EndTrap
22502275
:EndIf
22512276

22522277
write the logfile

Diff for: Tests/test_CompTools.aplf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
 r←test_CompTools
22
⍝ test the various compatibility tools...(which are also important to allow running DTest on all versions!)
33
r←''
4-
(⊂hw←'h∊llo' 'w∘rld')##.qNPUT(fl←##.TESTSOURCE,'/hello.txt')1 ⍝ test against UTF-8 data
4+
(⊂hw←'h∊llo' 'w∘rld')##.⎕NPUT(fl←##.TESTSOURCE,'/hello.txt')1 ⍝ test against UTF-8 data
55

66
:If hw Check 2↑⊃##.qNGET fl
7-
→fail Because'qNGET did not return what qNPUT wrote!' ⋄ :EndIf
7+
→fail Because'qNGET did not return what ⎕NPUT wrote!' ⋄ :EndIf
88

99

1010
→0

Diff for: Tests/test_DBuild_1.dyalog

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848
0 Because'ProdFlag did not have expected value "Production", but rather "',#.ProdFlag,'"' :EndIf
4949

5050
res##.Build args##.TESTSOURCE,'DBuild_nameclash.dyalogbuild -c -q=2 -s=0'
51-
:If 1 Check/'4 errors encountered.'res
51+
:If 1 Check/'6 errors encountered.'res
5252
0 Because'DBuild did not fail with 4 errors (3 nameclashes + final msg) while executing...',(⎕UCS 13),']DBuild ',args :EndIf

Diff for: Tests/test_DBuild_3.dyalog

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ sort←{⍵[⍋⍵]}
3333

3434
'ic'#.⎕NS'' ⎕SE.SALT.Load'InitConga -target=#.ic'
3535

36-
:If (¯1#.ic.⎕CR'InitConga')Check ¯1#.conga.⎕CR'InitConga'
36+
:If (##.dtb¨¯1#.ic.⎕CR'InitConga')Check #.conga.⎕CR'InitConga'
3737
0 Because'InitConga not loaded identically to ]LOAD' :EndIf
3838

3939
:If (,'HttpCommand')Check #.httpcommand.⎕NL ¯9

Diff for: Tests/test_DBuild_nameclash.dyalog

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
r''
33
res##.Build args##.TESTSOURCE,'DBuild_nameclash.dyalogbuild -c -q=2'
44

5-
:If 1 Check/'4 errors encountered.'res
5+
:If 1 Check/'6 errors encountered.'res
66
0 Because'DBuild did not fail with 4 errors while executing...',(⎕UCS 13),']DBuild ',args :EndIf

Diff for: Tests/test_nousource.aplf

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
r←test_nosource;n;sw;z;ch;bl
2-
3-
:For sw :In 0 1 '' ⍝ testing switch values
1+
r←test_nosource;n;sw;z;ch;bl;log
2+
r←''
3+
:For sw :In 0 1 '' ⍝ testing switch values
44
:For n :In 1 0 ⍝ and values for nosource as TARGET parameter
55
log←##.Build txt←##.TESTSOURCE,'nosource/test_nosource',(⍕n),'.dyalogbuild -q -c',((sw≢'')∧sw≢n)/' -nosource=',⍕sw
66
:If ''≡log
77
~0 Because'non-empty log after building "',txt,'"' ⋄ :EndIf
88

9-
z←(sw∊1 '')∨(sw≢0)∧n=1
9+
z←(sw≡1)∨(sw≢0)∧n=1 ⍝ z indicates expected effect of "nosource"
1010
:For ch :In 'fnWithBlanks' 'SourceHasBlanks' ⍝ functions to analyze
11-
bl←+/∊' '⍷,#.⎕VR ch
11+
bl←+/∊' '⍷∊62 #.⎕ATX ch
1212
:EndFor
1313
:If z ⍝ if blanks should have been remoced
1414
:If 0 Check 0<bl ⍝ and we found some...
1515
→0 Because'No blanks expected after building with arg "',txt,'"'
16-
:Else
17-
⎕←txt,' ',ch,' ',bl
1816
:EndIf
1917
:Else
2018
:If 0=bl ⍝ we did not remove blanks and there were none in the fn
21-
(⎕LC[1]+1)⎕STOP 1⊃⎕SI
2219
→0 Because'No extraneous blanks found in test fns after building with arg "',txt,'"'
23-
:Else
24-
⎕←txt,' ',ch,' ',bl
2520
:EndIf
2621
:EndIf
2722
:EndFor

0 commit comments

Comments
 (0)