guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/5] Automake custom test driver using SRFI-64.


From: Ludovic Courtès
Subject: Re: [PATCH 0/5] Automake custom test driver using SRFI-64.
Date: Sat, 02 Apr 2016 15:22:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Mathieu Lirzin <address@hidden> skribis:

> address@hidden (Ludovic Courtès) writes:
>
>> Mathieu Lirzin <address@hidden> skribis:
>>
>>> It is possible to directly checkout 'origin/wip-check' branch to review 
>>> these
>>> patches.  Thanks.
>>>
>>> Mathieu Lirzin (5):
>>>   tests: Silence %cpio-program.
>>>   build: Add a Guile custom test driver using SRFI-64.
>>>   tests: Silence guix-daemon.
>>>   tests: Silence %have-nix-hash?.
>>>   tests: Silence tar.
>>
>> I’m looking at it now.  My first question is whether we could avoid
>> silencing everything?
>>
>> I guess I got used to having an extra .log file containing “noise”, in
>> addition to the well-formatted .log file, and it’s proved useful on a
>> few occasions.
>
> Indeed, that would be great and desirable to have all the extra
> information in the log file.  'build-aux/test-driver' achieves it by
> simply forking and redirecting stdout and stderr to the log file, like
> this:
>
> # Test script is run here.
> "$@" >$log_file 2>&1
> estatus=$?
>
> I don't know if it is possible to replicate a redirection of all the
> error noises without forking the process.  for now I am using something
> similar to this:
>
>   (let ((log (open-output-file "tests/foo.log")))
>     (parameterize ((current-output-port log)
>                    (current-error-port log)
>                    (current-warning-port log))
>       (load-from-path "tests/foo.scm")
>       ...))
>
> But for example if tests/foo.scm calls ‘system’, the output will be
> displayed to the terminal not to the log file.  Do you know a way to fix
> that?

Indeed, I’ve thought about it, but in fact most or all of the “useful
noise” happens via ‘current-output-port’ and ‘current-error-port’, so
we’re not losing much.

If we want a 100% solution that works with child processes (like
‘cpio’), we should redirect the underlying file descriptors instead of
the ports:

  (let ((log (open-output-file "tests/foo.log" "w0"))) ;unbuffered
    (redirect-port (current-output-port) log)
    (redirect-port (current-error-port) log)
    ;; …
    )

I haven’t tried, but it should do the job.  (If it doesn’t, ‘close-fdes’
+ ‘dup2’ would certainly work.)

If you take this route, then the patches that silence ‘cpio’ and
‘nix-hash’ are probably no longer needed.  Up to you!

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]