Hi Guix, I have some Guix scripts which take the form of manifests (--manifest=file), packages (--load=file), or are called using "guix repl". Some of these are complex enough to warrant writing unit tests for using srfi-64. However, I'm having some difficulty trying to work out how to run unit tests over procedures that are also used to descirbe manifests and repl scripts, and was looking for some advice - details below!
Normally in vanilla Guile I'd structure my code to call a main procedure using the Guile meta-switch, thus the script could also be imported by a test script using "use-modules" or executed using the meta-switch: https://www.gnu.org/software/guile/manual/html_node/The-Meta-Switch.html However there is no way of doing this (that I can figure out) when the script is being passed to "guix envrionment" or "guix repl" - meaning the contents of my "main" procedure cannot be bound by a function in the script. To try to work around this, I separated my scripts into a library module to be unit tested, and a short runner which will call into the library module to generate the manifest, however this approach produces unexpected behaviour - for example if I have a simple *gurobi-manifest.scm* like so: *(add-to-load-path (dirname (current-filename))) ;; put the script's location on the module path(use-modules (gurobi-transform-lib)) ;; load the script library(newline)(packages->manifest (list my-package-with-my-gurobi* * (specification->package "python"))) ;; add python for convenience* The procedure we call to generate the package - *my-package-with-my-gurobi*, is in a file called *gurobi-transform-lib.scm* in the same directory as the manifest above. The initial call to the *my-package-with-my-gurobi* succeeds (The stdout below shows this) but failure quickly follows, with a subsequent call to the library failing: *$ guix environment -m gurobi-manifest.scmSetting Gurobi Version: 9.1.2 <- everything looks OK to start withSetting Test Package: simmguix environment: error: failed to load 'gurobi-manifest.scm':ice-9/boot-9.scm:3329:6: In procedure resolve-interface:no code for module (gurobi-transform-lib)* *$* If I cut and paste the library and manifest into the same file everything works as expected. Thus the best workaround I have at the moment is to have the unit tests run directly from the manifest script, every time the manifest is used, but this is only practical for a very small number of unit tests, and even then it's a bit ugly. Can anyone suggest a better way of having the unit tests in a separate file which can import procedures used in repl or manifest scripts in such a way that they still work or can be used as repl or manifest scripts themselves? In the above example, I was hoping to have something like: *guix repl -- gurobi-transform-lib-tests.scm* Any ideas greatfully received! Cheers, Phil.