Do not use os.Exit in exportable packages (#286)

Fixes #285

Signed-off-by: David Cassany <dcassany@suse.com>
This commit is contained in:
David Cassany Viladomat
2022-01-12 08:57:41 +01:00
committed by GitHub
parent 4943ed6aef
commit 881bf03c3d
6 changed files with 9 additions and 10 deletions

View File

@@ -135,7 +135,7 @@ func (c *Context) Copy() types.Context {
func (c *Context) Warning(mess ...interface{}) {
c.Logger.Warn(mess...)
if c.Config.General.FatalWarns {
os.Exit(2)
panic("panic on warning")
}
}
@@ -146,7 +146,7 @@ func (c *Context) Warn(mess ...interface{}) {
func (c *Context) Warnf(t string, mess ...interface{}) {
c.Logger.Warnf(t, mess...)
if c.Config.General.FatalWarns {
os.Exit(2)
panic("panic on warning")
}
}

View File

@@ -17,7 +17,6 @@ package logger
import (
"fmt"
"os"
"path"
"regexp"
"runtime"
@@ -253,7 +252,7 @@ func (l *Logger) Tracef(t string, args ...interface{}) {
func (l *Logger) Fatal(args ...interface{}) {
l.send(log.LevelFatal, "", args...)
os.Exit(1)
panic("fatal error")
}
func (l *Logger) Info(args ...interface{}) {

View File

@@ -67,7 +67,7 @@ testInstall() {
testFullInstall() {
output=$(luet install -y --config $tmpdir/luet.yaml test/d test/f test/e test/a)
installst=$?
assertEquals 'cannot install' "$installst" "1"
assertEquals 'cannot install' "$installst" "2"
assertTrue 'package D installed' "[ ! -e '$tmpdir/testrootfs/d' ]"
assertTrue 'package F installed' "[ ! -e '$tmpdir/testrootfs/f' ]"
}

View File

@@ -23,14 +23,14 @@ testBuildB() {
mkdir $tmpdir/testbuild2
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild2 test/b
buildst=$?
assertEquals 'builds of B expected to fail. It depends on a virtual' "$buildst" "1"
assertEquals 'builds of B expected to fail. It depends on a virtual' "$buildst" "2"
}
testBuildC() {
mkdir $tmpdir/testbuild3
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild3 test/c
buildst=$?
assertEquals 'builds of C expected to fail. Steps with no source image' "$buildst" "1"
assertEquals 'builds of C expected to fail. Steps with no source image' "$buildst" "2"
}
testBuildImage() {

View File

@@ -60,7 +60,7 @@ testInstall() {
luet install -y --config $tmpdir/luet.yaml test1/conflict test2/conflict
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
installst=$?
assertEquals 'install test failed' "$installst" "1"
assertEquals 'install test failed' "$installst" "2"
#assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
}
@@ -72,7 +72,7 @@ testReInstall() {
luet install -y --config $tmpdir/luet.yaml test2/conflict
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
installst=$?
assertEquals 'install test succeeded' "$installst" "1"
assertEquals 'install test succeeded' "$installst" "2"
luet install -y --force --config $tmpdir/luet.yaml test2/conflict
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
installst=$?

View File

@@ -67,7 +67,7 @@ testInstall() {
testUpgrade() {
out=$(luet upgrade -y --config $tmpdir/luet.yaml)
installst=$?
assertEquals 'install test succeeded' "$installst" "1"
assertEquals 'install test succeeded' "$installst" "2"
assertContains 'does find conflicts' "$out" "Error: file conflict found: file conflict between packages to be installed"
luet upgrade -y --config $tmpdir/luet.yaml --force