Skip to content

Commit caf6f81

Browse files
authored
Merge pull request #9 from Da-Buche/dev
Add function to get current SKILL# version
2 parents 361a631 + cff9acf commit caf6f81

11 files changed

Lines changed: 128 additions & 17 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ bash: container
126126
.PHONY: shell
127127
shell: container ## Run SKILL interpreter in Shell mode.
128128
ifeq ($(OS_NAME),Linux)
129-
@/skill#/bin/shell
129+
@$$SKILL_SHARP_ROOT/bin/shell
130130
#@rlwrap docker exec -it rocky8-skill /skill#/bin/shell
131131
else
132132
@make container

skill/autoloaded/docgen.scm

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@
253253
));let ;when
254254
(fprintf port ")")
255255
;; Print output when defined
256-
(when (memq '@output (get name '?)) (fprintf port " => %s" (@pretty_print (get name '@output) t)))
256+
(when (and (memq '@output (get name '?))
257+
(neq (get name '@output) '__undefined__)
258+
)
259+
(fprintf port " => %s" (@pretty_print (get name '@output) t)))
257260
(getOutstring port)
258261
));with ;fun
259262

@@ -285,7 +288,11 @@
285288
;; Print info, warn and error messages when expected
286289
(letseq ( ( assertion (car assertions) )
287290
( input assertion->body_quoted )
288-
( output (car assertion->body_result) )
291+
;; Support skipped assertions
292+
( output (if (neq '\*slotUnbound\* assertion->body_result)
293+
(car assertion->body_result)
294+
assertion->body_expected
295+
) )
289296
( info (@nonblankstring? assertion->info_expected ) )
290297
( warn (@nonblankstring? assertion->warn_expected ) )
291298
( error (@nonblankstring? assertion->error_expected) )
@@ -305,7 +312,9 @@
305312
(fprintf port "<font color='%s'>;%s>%s</font>\n" color prefix (escape (clean_at_sign line)))
306313
));when ;foreach
307314
);foreach
308-
(fprintf port ";> %s\n" (escape (clean_at_sign (@pretty_print output ))))
315+
(unless error
316+
(fprintf port ";> %s\n" (escape (clean_at_sign (@pretty_print output ))))
317+
)
309318
(when (cdr assertions) (newline port))
310319
));let ;foreach
311320
(fprintf port "</pre>")
@@ -315,9 +324,10 @@
315324

316325
(@fun @docgen
317326
( @key
318-
( files ?type ( string ... ) )
319-
( init ?type string ?def (or (getShellEnvVar "SKILL_SHARP_INIT_COMMAND" ) "") )
320-
( before ?type string ?def (or (getShellEnvVar "SKILL_SHARP_BEFORE_COMMAND") "") )
327+
( source_files ?type ( string ... ) )
328+
( test_files ?type ( string ... )|nil ?def nil )
329+
( init ?type string ?def (or (getShellEnvVar "SKILL_SHARP_INIT_COMMAND" ) "") )
330+
( before ?type string ?def (or (getShellEnvVar "SKILL_SHARP_BEFORE_COMMAND") "") )
321331
( track_source
322332
?type t|nil
323333
?def (equal "TRUE" (getShellEnvVar "SKILL_SHARP_TRACK_SOURCE"))
@@ -335,13 +345,16 @@ Print associated documentation (as .fnd file content) to stdout."
335345
?out t|nil
336346
?global t
337347
(destructuringBind ( functions _variables _scheme _classes @optional _symbols )
338-
(@globals ?files files ?before (@str "(progn nil (inSkill (sklint)) {before})") ?init init)
348+
(@globals ?files source_files ?before (@str "(progn nil (inSkill (sklint)) {before})") ?init init)
339349
;; Load all files containing tests
340350
(@letf ( ( (status keepNLInString ) t )
341351
( (status saveInlineDoc ) t )
342352
( (getShellEnvVar "SKILL_SHARP_RUN_TEST") "TRUE" )
343353
)
344-
(foreach file files (@load file ?no_reload t))
354+
(foreach files (list source_files test_files)
355+
(foreach file files
356+
(@load file ?no_reload t ?fun 'loadi)
357+
))
345358
)
346359
;; Filter and sort functions
347360
(setq functions (setof function functions (and (getd function) (nequal "_" (substring function 1 1)))))

skill/autoloaded/lint.scm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,16 @@ NAME is the message reference."
372372
(unless (equal "NO_LINT" (nth 1 sexp)) (apply '_\@lint_default_rule sexp args))
373373
))
374374

375+
;; -------------------------------------------------------
376+
;; `muffleWarnings`
377+
;; -------------------------------------------------------
378+
379+
(_\@lint_rule
380+
?functions '( muffleWarnings )
381+
?control t
382+
?rule_fun '_\@lint_default_rule
383+
)
384+
375385
;; -------------------------------------------------------
376386
;; `if`, `when`, `unless`
377387
;; -------------------------------------------------------

skill/legacy.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ Warnings catched during evaluation can be fetched using `getMuffleWarnings'."
3333
;; Split warnings
3434
(@letf ( ( (rexMagic) nil )
3535
)
36-
(rexCompile "*WARNING*")
36+
(rexCompile "*WARNING* ")
3737
(setq str (rexReplace str "¶" 0))
3838
)
3939
(setq warnings
4040
;; Remove added warning in case it was printed before being catched
4141
(foreach mapcon _warnings (parseString str "¶")
4242
(unless (and (not (cdr _warnings)) (blankstrp (car _warnings)))
43-
(list (strcat "*WARNING*" (car _warnings)))
43+
(list (car _warnings))
4444
))
4545
)
4646
);when

skill/sharp.scm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
;; =======================================================
2929
3030
(@script_set_description "Run SKILL Sharp comamnds." )
31-
(@script_set_version "0.0.0" )
31+
(@script_set_version (@skill_sharp) )
3232
3333
(@script_add_argument
3434
?name "command"
@@ -145,7 +145,17 @@
145145
(lambda ( @rest args )
146146
(@debug "Running Docgen on {args}")
147147
(@setf (@woport) (@stderr))
148-
(@exit (if (@docgen ?files (@skill_files args)) 0 1))
148+
(let ( ( source_files nil )
149+
( test_files nil )
150+
)
151+
;; Segregate source and test files according to _test suffix
152+
(foreach file (@skill_files args)
153+
(if (pcreMatchp "_test\\.(ils?|scm)$" file)
154+
(push file test_files)
155+
(push file source_files)
156+
))
157+
(@exit (if (@docgen ?source_files source_files ?test_files test_files) 0 1))
158+
)
149159
))
150160
151161
;; -------------------------------------------------------

skill/utils.scm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ If NUM is negative, STR is right-padded instead."
244244
; str
245245
; )
246246

247+
(@fun @pascal_case
248+
( ( str ?type string )
249+
)
250+
?doc "Return STR in Pascal-Case. (i.e. first letter is upper-case, rest is lower-case."
251+
(strcat (upperCase (substring str 1 1)) (lowerCase (substring str 2)))
252+
)
253+
247254
;; =======================================================
248255
;; Numbers
249256
;; =======================================================
@@ -649,5 +656,29 @@ If END is not provided, END defaults to BEG minus 1 and BEG defaults to 0."
649656

650657
);closure
651658

659+
;; =======================================================
660+
;; Return SKILL# Version
661+
;; =======================================================
662+
663+
(@fun @skill_sharp
664+
( @key
665+
( min_version ?type string|nil ?def nil )
666+
)
667+
?doc "Return current SKILL# version.
668+
If MIN_VERSION is provided, then assert that current version is equal or higher.
669+
670+
This is intended to be used as following in SKILL# dependent files:
671+
`(assert (and (isCallable '@skill_sharp) (@skill_sharp ?min_version \"0.0.0\"))
672+
\"SKILL# version 0.0.0 or higher is required\")`"
673+
(letseq ( ( file (@realpath "$SKILL_SHARP_ROOT/VERSION") )
674+
( version (if (isFile file) (@read_file file) "0.0.0") )
675+
)
676+
(if (stringp min_version)
677+
(@assert (not (@alphalessp version min_version))
678+
"@skill_sharp - Minimum required version [{min_version}] is higher than current one [{version}].")
679+
version
680+
)
681+
));let ;fun
682+
652683
;*/
653684

spec/skill_sharp_spec.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ End
108108

109109
It 'generates documentation'
110110
When run env SKILL_SHARP_TRACK_SOURCE=TRUE \
111+
SKILL_SHARP_GLOBALS_LOAD=TRUE \
111112
bash -c 'mkdir -p ./doc/finder/SKILL/SKILL#/ && ./bin/sharp docgen ./skill/loader.scm ./test > "./doc/finder/SKILL/SKILL#/sharp.fnd"'
112113
The file './doc/finder/SKILL/SKILL#/sharp.fnd' should be exist
113114
The stdout should be blank

tcl/tcp_server.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ proc random_string {} {
3636
#exec openssl rand -base64 12 | tr , -
3737
set charset "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#%^-_=:."
3838
set charset [string map {"," ""} $charset]
39-
set password ""
39+
set password "P"
4040
for {set i 0} {$i < 16} {incr i} {
4141
append password [string index $charset [expr {int(rand() * [string length $charset])}]]
4242
}

test/autoloaded/docgen_test.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
?doc "Run `@docgen` on known files."
1515

1616
(@assertion
17-
(@docgen ?files (list (@realpath "$SKILL_SHARP_ROOT/metatest/globals/functions.ils")))
17+
(@docgen ?source_files (list (@realpath "$SKILL_SHARP_ROOT/metatest/docgen/defun_without_argument.il")))
1818
?out t
19-
?info "( \"nonlocal\"\n \"nonlocal()\"\n \"Missing documentation for function `nonlocal'.\"\n )"
19+
?info "( \"no_args\"\n \"no_args()\"\n \"This is a simple function without argument.\nIt always return 12.\"\n )"
2020
)
2121

2222
)

test/legacy_test.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
(@assertion
1818
(progn (muffleWarnings (warn "reported warning")) (getMuffleWarnings))
19-
?out '("*WARNING* reported warning")
19+
?out '("reported warning")
2020
)
2121

2222
)

0 commit comments

Comments
 (0)