diff mbox series

[kvm-unit-tests] travis.yml: Prevent 'script' section from premature exit

Message ID 20200113195102.44756-1-wainersm@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] travis.yml: Prevent 'script' section from premature exit | expand

Commit Message

Wainer dos Santos Moschetta Jan. 13, 2020, 7:51 p.m. UTC
The 'script' section finishes its execution prematurely whenever
a shell's exit is called. If the intention is to force
Travis to flag a build/test failure then the correct approach
is erroring any build command. In this change, it executes a
sub-shell process and exit 1, so that Travis capture the return
code and interpret it as a build error.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
---
 .travis.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Huth Jan. 14, 2020, 4:48 p.m. UTC | #1
On 13/01/2020 20.51, Wainer dos Santos Moschetta wrote:
> The 'script' section finishes its execution prematurely whenever
> a shell's exit is called. If the intention is to force
> Travis to flag a build/test failure then the correct approach
> is erroring any build command. In this change, it executes a
> sub-shell process and exit 1, so that Travis capture the return
> code and interpret it as a build error.
> 
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> ---
>  .travis.yml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index 091d071..a4405c3 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -119,5 +119,5 @@ before_script:
>  script:
>    - make -j3
>    - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
> -  - if grep -q FAIL results.txt ; then exit 1 ; fi
> -  - if ! grep -q PASS results.txt ; then exit 1 ; fi
> +  - if grep -q FAIL results.txt ; then $(exit 1) ; fi
> +  - if ! grep -q PASS results.txt ; then $(exit 1) ; fi

Basically a good idea, but I think we can even simplify these two lines
into:

 grep -q PASS results.txt && ! grep -q FAIL results.txt

If you agree, could you update your patch and send a v2?

 Thanks,
  Thomas
Wainer dos Santos Moschetta Jan. 14, 2020, 5:47 p.m. UTC | #2
On 1/14/20 2:48 PM, Thomas Huth wrote:
> On 13/01/2020 20.51, Wainer dos Santos Moschetta wrote:
>> The 'script' section finishes its execution prematurely whenever
>> a shell's exit is called. If the intention is to force
>> Travis to flag a build/test failure then the correct approach
>> is erroring any build command. In this change, it executes a
>> sub-shell process and exit 1, so that Travis capture the return
>> code and interpret it as a build error.
>>
>> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>> ---
>>   .travis.yml | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/.travis.yml b/.travis.yml
>> index 091d071..a4405c3 100644
>> --- a/.travis.yml
>> +++ b/.travis.yml
>> @@ -119,5 +119,5 @@ before_script:
>>   script:
>>     - make -j3
>>     - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
>> -  - if grep -q FAIL results.txt ; then exit 1 ; fi
>> -  - if ! grep -q PASS results.txt ; then exit 1 ; fi
>> +  - if grep -q FAIL results.txt ; then $(exit 1) ; fi
>> +  - if ! grep -q PASS results.txt ; then $(exit 1) ; fi
> Basically a good idea, but I think we can even simplify these two lines
> into:
>
>   grep -q PASS results.txt && ! grep -q FAIL results.txt

Indeed this is a better idea.

>
> If you agree, could you update your patch and send a v2?

Sure, I will send the v2 with your proposed changes. Thanks!

- Wainer

>
>   Thanks,
>    Thomas
diff mbox series

Patch

diff --git a/.travis.yml b/.travis.yml
index 091d071..a4405c3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -119,5 +119,5 @@  before_script:
 script:
   - make -j3
   - ACCEL="${ACCEL:-tcg}" ./run_tests.sh -v $TESTS | tee results.txt
-  - if grep -q FAIL results.txt ; then exit 1 ; fi
-  - if ! grep -q PASS results.txt ; then exit 1 ; fi
+  - if grep -q FAIL results.txt ; then $(exit 1) ; fi
+  - if ! grep -q PASS results.txt ; then $(exit 1) ; fi