From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSq4E-0004Ik-Tg for guix-patches@gnu.org; Tue, 12 Jun 2018 16:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSq4E-0007PF-1b for guix-patches@gnu.org; Tue, 12 Jun 2018 16:39:02 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:37533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSq4D-0007P7-TK for guix-patches@gnu.org; Tue, 12 Jun 2018 16:39:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fSq4D-0007oR-NB for guix-patches@gnu.org; Tue, 12 Jun 2018 16:39:01 -0400 Subject: [bug#31788] [PATCH] tests: Honor the return value of 'start-service'. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180611220508.17320-1-clement@lassieur.org> <87r2lbokjl.fsf@gnu.org> <87y3fjhiwj.fsf@lassieur.org> Date: Tue, 12 Jun 2018 22:38:38 +0200 In-Reply-To: <87y3fjhiwj.fsf@lassieur.org> ("=?UTF-8?Q?Cl=C3=A9ment?= Lassieur"'s message of "Tue, 12 Jun 2018 22:03:24 +0200") Message-ID: <877en3oi41.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Cc: 31788@debbugs.gnu.org Cl=C3=A9ment Lassieur skribis: > Ludovic Court=C3=A8s writes: > >> Hi Cl=C3=A9ment, >> >> Cl=C3=A9ment Lassieur skribis: >> >>> Since commit dc7b3e56337ee9d8dcd8fe7d5cab71ef536d024f, 'start-service' = returns >>> the Shepherd's representation of the service as a sexp, and '#f' if the >>> service fails to start. Also, it doesn't throw an exception when the s= ervice >>> fails to start, so relying on an exception instead of relying on its re= turn >>> value is a false positive. >> >> Looking at =E2=80=98invoke-action=E2=80=99 (used by =E2=80=98start-servi= ce=E2=80=99) in (gnu services >> herd), it seems that an exception is raised upon error: >> >> (('reply ('version 0 x ...) ('result y) ('error error) >> ('messages messages)) >> (for-each display-message messages) >> (raise-shepherd-error error) >> #f) > > But that's for Shepherd errors. When a service fails to start, it's not > a Shepherd error, so if my understanding is correct '(cont result)' > should be called. With result being '#f'. Oh, you=E2=80=99re right, sorry for the confusion. So on success =E2=80=98start-service=E2=80=99 returns a truth value, and we=E2=80=99re fi= ne. I=E2=80=99m not entirely sure about things like this: - (test-eq "service running" - 'running! + (test-assert "service running" (marionette-eval '(begin (use-modules (gnu services herd)) - (start-service 'mcron) - 'running!) + (start-service 'mcron)) marionette)) =E2=80=98start-service=E2=80=99 in this case returns a number (the PID), an= d I think =E2=80=98test-assert=E2=80=99 reports a failure when the value is not exact= ly #t. Isn=E2=80=99t it the case? Ludo=E2=80=99.