From e667046da86f50480a0772a287e562bc19a0dbfa Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 27 Dec 2013 13:35:16 -0500 Subject: [PATCH] add Environment#clear_targets() --- lib/rscons/environment.rb | 5 +++++ spec/rscons/environment_spec.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index ae12fad..44c69ea 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -162,6 +162,11 @@ module Rscons cache.write end + # Clear all targets registered for the Environment. + def clear_targets + @targets = {} + end + # Build a command line from the given template, resolving references to # variables using the Environment's construction variables and any extra # variables specified. diff --git a/spec/rscons/environment_spec.rb b/spec/rscons/environment_spec.rb index 329ff84..52b94a5 100644 --- a/spec/rscons/environment_spec.rb +++ b/spec/rscons/environment_spec.rb @@ -148,6 +148,18 @@ module Rscons end end + describe "#clear_targets" do + it "resets @targets to an empty hash" do + env = Environment.new + env.Program("a.out", "main.o") + expect(env.instance_variable_get(:@targets).keys).to eq(["a.out"]) + + env.clear_targets + + expect(env.instance_variable_get(:@targets).keys).to eq([]) + end + end + describe "#build_command" do it "returns a command based on the variables in the Environment" do env = Environment.new