Hi Jérémy, On Fri, 07 Oct 2022 at 10:41, jer...@korwin-zmijowski.fr wrote:
> I feel not able to take decision about the proper way right now. > So as a step forward I wrote a test to capture the behavior expected. > Please have a look at it as it's the starting point for me. > Next, I can implement the error handler, making the previous test to > pass. > As the test checks the behaviour, it will let enough space to change > implementation later without invalitating the test. Nice to start by the test! :-) > (define-module (tests scripts build) > #:use-module (srfi srfi-64) > #:use-module (ice-9 exceptions) > #:use-module (guix scripts build) > #:use-module (srfi srfi-34)) > > (test-begin "scripts") > > (define DUMMY_DEFINITION_PATH "/tmp/a.scm") > > (define (create-dummy-definition) > (call-with-output-file DUMMY_DEFINITION_PATH > (lambda (port) > (format port > "(use-modules (gnu packages) (guix packages) (guix gexp)) > (package (inherit (specification->package \"hello\")) (source (local-file > \"a.scm\")))")))) > > (define (delete-dummy-definition) > (delete-file DUMMY_DEFINITION_PATH)) > > (test-group-with-cleanup "build" > > (create-dummy-definition) > > (test-equal "package definition as only source" > "/gnu/store/7mnkrg9bmybgyf1dn5n67di6ng6qvhkz-a.scm" > (guard > (ex > ((exception? ex) #f)) > (guix-build "-f" DUMMY_DEFINITION_PATH "--source"))) Well, this test looks good to me. However, I would lower what the procedure under test. For instance, package-source-derivation in guix/packages.scm or show-derivation-outputs, as Josselin pointed [1]. 1: <https://yhetil.org/guix/87k05y2yjc....@jpoiret.xyz> > > (delete-dummy-definition)) > > (test-end "scripts") Cheers, simon