tinyyarn

scenario testing of Unix command line tools
Log | Files | Refs | README | LICENSE

commit 066ecb27359e84c23e0d12a14eae30586c25dc5b
parent 6abe801825372a613b12a09e83534e1a46a2871f
Author: Richard Ipsum <richardipsum@vx21.xyz>
Date:   Wed, 23 Dec 2020 15:33:43 +0000

Use return from main not os.exit, return 0 at end

Also return 1 when exiting with usage() or help().

Diffstat:
Mtyarn.lua.in | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/tyarn.lua.in b/tyarn.lua.in @@ -579,12 +579,12 @@ function main() if parsed_args["help"] then tyarn.help() - os.exit(0) + return 1 end if #parsed_args < 2 then tyarn.usage() - os.exit(0) + return 1 end if parsed_args["debug"] or DEBUG then @@ -609,7 +609,7 @@ function main() if scenario_list == nil then io.stderr:write(string.format("No scenarios found in '%s'\n", scenario_filepath)) - os.exit(1) + return 1 end for i = 2, #parsed_args do @@ -619,7 +619,7 @@ function main() for _, scenario_name in ipairs(scenario_list) do if seen[scenario_name] then io.stderr:write(string.format("Duplicate scenario: '%s'\n", scenario_name)) - os.exit(1) + return 1 end seen[scenario_name] = true @@ -634,7 +634,7 @@ function main() if parsed_args["exit_early"] then print(string.format("%d/%d: %s: FAILED", n, #scenario_list, scenario_name)) - os.exit(1) + return 1 end failed[scenario_name] = failed_step @@ -646,7 +646,7 @@ function main() if not seen_scenario then io.stderr:write("No scenarios\n") - os.exit(1) + return 1 end if nfailed > 0 then @@ -659,10 +659,11 @@ function main() else print(string.format("ERROR: Test suite FAILED in %d scenario", nfailed)) end - os.exit(1) + return 1 end write_progress_final('Scenario test suite PASS') + return 0 end -main() +os.exit(main())