Skip to content

Commit

Permalink
Merge pull request #3 from aclemons/return_codes
Browse files Browse the repository at this point in the history
Differentiate nitra results through exit codes
  • Loading branch information
ben-scully authored Jul 18, 2018
2 parents b7e2b91 + e1cdea5 commit c10ac4c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Nitra is a multi-process, optionally multi-server rspec and cucumber runner that
## Philosophy
* Nitra attempts to do the simplest thing possible
* Nitra (ab)uses unix primitives where possible
* Nitra doesn't do thing that unix alnext_file does better (eg. rsync)
* Nitra doesn't do things that unix already does better (eg. rsync)
* IPC is accomplished via pipes and select
* Forking is used heavily for several reasons
* Running nitra locally should be easy
Expand Down
17 changes: 16 additions & 1 deletion bin/nitra
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,20 @@ Nitra::CommandLine.new(configuration, ARGV)
if configuration.slave_mode
Nitra::Slave::Server.new.run
else
exit Nitra::Master.new(configuration, ARGV).run ? 0 : 1
result = Nitra::Master.new(configuration, ARGV).run

case result
when Nitra::Master::ABORTED
exit 1
when Nitra::Master::TEST_FAILURES
exit 2
when Nitra::Master::FAILURE
exit 3
when Nitra::Master::UNPROCESSED_FILES
exit 4
when Nitra::Master::SUCCESS
exit 0
else
exit 127
end
end
18 changes: 17 additions & 1 deletion lib/nitra/master.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
class Nitra::Master
attr_reader :configuration, :files_by_framework

ABORTED = :aborted
FAILURE = :failure
SUCCESS = :success
TEST_FAILURES = :test_failures
UNPROCESSED_FILES = :unprocessed_files

def initialize(configuration, files = nil)
@configuration = configuration
if configuration.frameworks.any?
Expand Down Expand Up @@ -43,7 +49,17 @@ def run
formatter.finish
burndown.finish configuration.burndown_report if configuration.burndown_report

!$aborted && progress.files_completed == progress.file_count && progress.failure_count.zero? && !progress.failure
if $aborted
ABORTED
elsif progress.files_completed != progress.file_count
UNPROCESSED_FILES
elsif progress.failure_count.positive?
TEST_FAILURES
elsif progress.failure
FAILURE
else
SUCCESS
end
end

protected
Expand Down

0 comments on commit c10ac4c

Please sign in to comment.