diff --git a/Makefile b/Makefile index e4e398d..fda2356 100644 --- a/Makefile +++ b/Makefile @@ -45,12 +45,15 @@ check-api: assert-SCRIPT_CALL assert-bats ## FIXME: How do I use node/npm so it finds the 'seguid' module? check-api/seguid-javascript: - $(MAKE) check-api SCRIPT_CALL="node" SCRIPT_PREAMBLE="const { seguid, lsseguid, ldseguid, csseguid, cdseguid } = require('seguid')" SCRIPT_PRINT_FMT="console.log(%s)" + $(MAKE) check-api SCRIPT_CALL="node" SCRIPT_PREAMBLE="const { seguid, lsseguid, ldseguid, csseguid, cdseguid } = require('seguid')" SCRIPT_PRINT_FMT="console.log(%s)" SCRIPT_ARGS_SEP=", " check-api/seguid-python: - $(MAKE) check-api SCRIPT_CALL="python" SCRIPT_PREAMBLE="from seguid import *" SCRIPT_PRINT_FMT="out=%s\nif isinstance(out, tuple):\n out=' '.join(out)\nprint(out)" + $(MAKE) check-api SCRIPT_CALL="python" SCRIPT_PREAMBLE="from seguid import *" SCRIPT_PRINT_FMT="out=%s\nif isinstance(out, tuple):\n out=' '.join(out)\nprint(out)" SCRIPT_ARGS_SEP=", " check-api/seguid-r: - $(MAKE) check-api SCRIPT_CALL="Rscript --no-init-file" SCRIPT_PREAMBLE="library(seguid)" SCRIPT_PRINT_FMT="cat(%s)" + $(MAKE) check-api SCRIPT_CALL="Rscript --no-init-file" SCRIPT_PREAMBLE="library(seguid)" SCRIPT_PRINT_FMT="cat(%s)" SCRIPT_ARGS_SEP=", " + +check-api/seguid-tcl: + $(MAKE) check-api SCRIPT_CALL="tclsh" SCRIPT_PREAMBLE="source ../src/base64.tcl; source ../src/sha1.tcl; source ../src/seguid.tcl;" SCRIPT_PRINT_FMT="puts stdout [%s]" SCRIPT_ARGS_SEP=" " SCRIPT_CALL_FMT="%s %s" check-api/ALL: check-api/seguid-python check-api/seguid-r diff --git a/tests-api/utils.sh b/tests-api/utils.sh index 6dd9a50..ee04ebc 100644 --- a/tests-api/utils.sh +++ b/tests-api/utils.sh @@ -10,8 +10,14 @@ setup_api_test() { script_print_fmt="${SCRIPT_PRINT_FMT:-print(%s)}" echo "script_print_fmt: ${script_print_fmt}" - script_args_sep="${SCRIPT_ARGS_SEP:-, }" - echo "script_args_sep: ${script_args_sep}" + script_args_sep="${SCRIPT_ARGS_SEP}" + if [[ -z ${script_args_sep} ]]; then + script_args_sep=" " + fi + echo "script_args_sep: '${script_args_sep}'" + + script_call_fmt="${SCRIPT_CALL_FMT:-%s(%s)}" + echo "script_call_fmt: ${script_call_fmt}" } @@ -48,7 +54,7 @@ api_call() { ## Add script preamble printf "%s\n" "${script_preamble[@]}" > "${tf}" ## Generate API call - call="${fcn}($(args_to_string "${args[@]}"))" + call=$(printf "${script_call_fmt}" "${fcn}" "$(args_to_string "${args[@]}")") ## Wrap API call in print statement call=$(printf "${script_print_fmt}" "${call}") printf "%s\n" "${call}" >> "${tf}"