feat(mkdwarfs): exit with code 2 in case of recoverable errors

This commit is contained in:
Marcus Holland-Moritz 2024-01-13 18:49:06 +01:00
parent f90bec0235
commit 95c50920f5
3 changed files with 11 additions and 4 deletions

View File

@ -419,6 +419,13 @@ Most other options are concerned with compression tuning:
Show full usage with all options, including defaults, compression level Show full usage with all options, including defaults, compression level
detail and supported compression algorithms. detail and supported compression algorithms.
## EXIT CODES
Upon successful completion, `mkdwarfs` will exit with exit code 0. If an
unrecoverable error occurs (i.e. no valid file system image has been produced),
it will exit with exit code 1. If any errors have occurred (e.g. not all input
files could be read), the exit code will be 2.
## CATEGORIZERS ## CATEGORIZERS
Categorizers will inspect the input files in the scanning phase and try to Categorizers will inspect the input files in the scanning phase and try to

View File

@ -1376,7 +1376,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
<< err.str(); << err.str();
} }
return prog.errors > 0; return prog.errors > 0 ? 2 : 0;
} }
int mkdwarfs_main(int argc, sys_char** argv) { int mkdwarfs_main(int argc, sys_char** argv) {

View File

@ -634,7 +634,7 @@ TEST_P(logging_test, fancy_output) {
mkdwarfs_tester t; mkdwarfs_tester t;
t.iol->set_terminal_fancy(true); t.iol->set_terminal_fancy(true);
t.os->set_access_fail("/somedir/ipsum.py"); // trigger an error t.os->set_access_fail("/somedir/ipsum.py"); // trigger an error
EXPECT_EQ(1, t.run("-l1 -i / -o - --categorize --num-workers=8 -S 22 " EXPECT_EQ(2, t.run("-l1 -i / -o - --categorize --num-workers=8 -S 22 "
"-L 16M --progress=none --log-level=" + "-L 16M --progress=none --log-level=" +
level)) level))
<< t.err(); << t.err();
@ -1971,7 +1971,7 @@ TEST(mkdwarfs_test, recoverable_errors) {
{ {
mkdwarfs_tester t; mkdwarfs_tester t;
t.os->set_access_fail("/somedir/ipsum.py"); t.os->set_access_fail("/somedir/ipsum.py");
EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); EXPECT_EQ(2, t.run("-i / -o - -l4")) << t.err();
EXPECT_THAT(t.err(), EXPECT_THAT(t.err(),
::testing::HasSubstr("filesystem created with 1 error")); ::testing::HasSubstr("filesystem created with 1 error"));
} }
@ -1980,7 +1980,7 @@ TEST(mkdwarfs_test, recoverable_errors) {
mkdwarfs_tester t; mkdwarfs_tester t;
t.os->set_access_fail("/somedir/ipsum.py"); t.os->set_access_fail("/somedir/ipsum.py");
t.os->set_access_fail("/baz.pl"); t.os->set_access_fail("/baz.pl");
EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); EXPECT_EQ(2, t.run("-i / -o - -l4")) << t.err();
EXPECT_THAT(t.err(), EXPECT_THAT(t.err(),
::testing::HasSubstr("filesystem created with 2 errors")); ::testing::HasSubstr("filesystem created with 2 errors"));
} }