mirror of
https://github.com/mudler/luet.git
synced 2025-09-13 05:42:52 +00:00
Do not use os.Exit in exportable packages (#286)
Fixes #285 Signed-off-by: David Cassany <dcassany@suse.com>
This commit is contained in:
committed by
GitHub
parent
4943ed6aef
commit
881bf03c3d
@@ -135,7 +135,7 @@ func (c *Context) Copy() types.Context {
|
|||||||
func (c *Context) Warning(mess ...interface{}) {
|
func (c *Context) Warning(mess ...interface{}) {
|
||||||
c.Logger.Warn(mess...)
|
c.Logger.Warn(mess...)
|
||||||
if c.Config.General.FatalWarns {
|
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{}) {
|
func (c *Context) Warnf(t string, mess ...interface{}) {
|
||||||
c.Logger.Warnf(t, mess...)
|
c.Logger.Warnf(t, mess...)
|
||||||
if c.Config.General.FatalWarns {
|
if c.Config.General.FatalWarns {
|
||||||
os.Exit(2)
|
panic("panic on warning")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ package logger
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -253,7 +252,7 @@ func (l *Logger) Tracef(t string, args ...interface{}) {
|
|||||||
|
|
||||||
func (l *Logger) Fatal(args ...interface{}) {
|
func (l *Logger) Fatal(args ...interface{}) {
|
||||||
l.send(log.LevelFatal, "", args...)
|
l.send(log.LevelFatal, "", args...)
|
||||||
os.Exit(1)
|
panic("fatal error")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Logger) Info(args ...interface{}) {
|
func (l *Logger) Info(args ...interface{}) {
|
||||||
|
@@ -67,7 +67,7 @@ testInstall() {
|
|||||||
testFullInstall() {
|
testFullInstall() {
|
||||||
output=$(luet install -y --config $tmpdir/luet.yaml test/d test/f test/e test/a)
|
output=$(luet install -y --config $tmpdir/luet.yaml test/d test/f test/e test/a)
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'cannot install' "$installst" "1"
|
assertEquals 'cannot install' "$installst" "2"
|
||||||
assertTrue 'package D installed' "[ ! -e '$tmpdir/testrootfs/d' ]"
|
assertTrue 'package D installed' "[ ! -e '$tmpdir/testrootfs/d' ]"
|
||||||
assertTrue 'package F installed' "[ ! -e '$tmpdir/testrootfs/f' ]"
|
assertTrue 'package F installed' "[ ! -e '$tmpdir/testrootfs/f' ]"
|
||||||
}
|
}
|
||||||
|
@@ -23,14 +23,14 @@ testBuildB() {
|
|||||||
mkdir $tmpdir/testbuild2
|
mkdir $tmpdir/testbuild2
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild2 test/b
|
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild2 test/b
|
||||||
buildst=$?
|
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() {
|
testBuildC() {
|
||||||
mkdir $tmpdir/testbuild3
|
mkdir $tmpdir/testbuild3
|
||||||
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild3 test/c
|
luet build --tree "$ROOT_DIR/tests/fixtures/virtuals" --debug --compression "gzip" --destination $tmpdir/testbuild3 test/c
|
||||||
buildst=$?
|
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() {
|
testBuildImage() {
|
||||||
|
@@ -60,7 +60,7 @@ testInstall() {
|
|||||||
luet install -y --config $tmpdir/luet.yaml test1/conflict test2/conflict
|
luet install -y --config $tmpdir/luet.yaml test1/conflict test2/conflict
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
assertEquals 'install test failed' "$installst" "1"
|
assertEquals 'install test failed' "$installst" "2"
|
||||||
#assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
|
#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 test2/conflict
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
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 --force --config $tmpdir/luet.yaml test2/conflict
|
||||||
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
|
||||||
installst=$?
|
installst=$?
|
||||||
|
@@ -67,7 +67,7 @@ testInstall() {
|
|||||||
testUpgrade() {
|
testUpgrade() {
|
||||||
out=$(luet upgrade -y --config $tmpdir/luet.yaml)
|
out=$(luet upgrade -y --config $tmpdir/luet.yaml)
|
||||||
installst=$?
|
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"
|
assertContains 'does find conflicts' "$out" "Error: file conflict found: file conflict between packages to be installed"
|
||||||
|
|
||||||
luet upgrade -y --config $tmpdir/luet.yaml --force
|
luet upgrade -y --config $tmpdir/luet.yaml --force
|
||||||
|
Reference in New Issue
Block a user