Skip to content

Commit

Permalink
Return success if no file coverage target has been set
Browse files Browse the repository at this point in the history
Also add a child to test _ready() on autoload nodes with children
  • Loading branch information
jamie-pate committed Apr 17, 2023
1 parent 68cf02e commit 8cae469
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions Autoload1.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func _init():
# Called when the node enters the scene tree for the first time.
func _ready():
_ready = '1'
add_child(other_node)

func fmt(value: String) -> String:
emit_signal('formatting')
Expand Down
9 changes: 6 additions & 3 deletions OtherNode.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
extends Node

# I don't think we can fix the case where the _init() has any required arguments
# your code will have to allow these to be (re)initialized with no arguments
func _init(parent: Node = null):
var ready := false

func _init(parent: Node):
if parent:
parent.add_child(self)

func _ready():
ready = true

func fmt(value: String):
return "OtherNode(%s)" % [value]
7 changes: 4 additions & 3 deletions addons/coverage/Coverage.gd
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ func set_coverage_targets(total: float, file: float) -> void:

func coverage_passing() -> bool:
var all_files_passing := true
for script in coverage_collectors:
var script_percent = coverage_collectors[script].coverage_percent()
all_files_passing = all_files_passing && script_percent > _coverage_target_file
if _coverage_target_file < INF:
for script in coverage_collectors:
var script_percent = coverage_collectors[script].coverage_percent()
all_files_passing = all_files_passing && script_percent > _coverage_target_file
return coverage_percent() > _coverage_target_total && all_files_passing

# see ScriptCoverage.Verbosity for verbosity levels
Expand Down

0 comments on commit 8cae469

Please sign in to comment.