From 7b3bffd329ce57d5f30a94e34b54723d9864a775 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 22 May 2017 16:25:49 -0400 Subject: [PATCH] update some non-integration-test specs --- spec/rscons/builders/library_spec.rb | 14 ++++++- spec/rscons/builders/object_spec.rb | 23 +++++++++-- spec/rscons/builders/program_spec.rb | 14 ++++++- spec/rscons/environment_spec.rb | 62 +--------------------------- 4 files changed, 45 insertions(+), 68 deletions(-) diff --git a/spec/rscons/builders/library_spec.rb b/spec/rscons/builders/library_spec.rb index c8d82f1..6885322 100644 --- a/spec/rscons/builders/library_spec.rb +++ b/spec/rscons/builders/library_spec.rb @@ -6,12 +6,22 @@ module Rscons it "supports overriding AR construction variable" do expect(subject).to receive(:standard_build).with("AR prog.a", "prog.a", ["sp-ar", "rcs", "prog.a", "prog.o"], ["prog.o"], env, :cache) - subject.run("prog.a", ["prog.o"], :cache, env, "AR" => "sp-ar") + subject.run( + target: "prog.a", + sources: ["prog.o"], + cache: :cache, + env: env, + vars: {"AR" => "sp-ar"}) end it "supports overriding ARCMD construction variable" do expect(subject).to receive(:standard_build).with("AR prog.a", "prog.a", ["special", "AR!", "prog.o"], ["prog.o"], env, :cache) - subject.run("prog.a", ["prog.o"], :cache, env, "ARCMD" => ["special", "AR!", "${_SOURCES}"]) + subject.run( + target: "prog.a", + sources: ["prog.o"], + cache: :cache, + env: env, + vars: {"ARCMD" => ["special", "AR!", "${_SOURCES}"]}) end end end diff --git a/spec/rscons/builders/object_spec.rb b/spec/rscons/builders/object_spec.rb index 7845eab..358d829 100644 --- a/spec/rscons/builders/object_spec.rb +++ b/spec/rscons/builders/object_spec.rb @@ -13,7 +13,12 @@ module Rscons expect(File).to receive(:exists?).and_return(false) expect(cache).to receive(:register_build) - subject.run("mod.o", ["mod.c"], cache, env, "CCCMD" => ["llc", "${_SOURCES}"]) + subject.run( + target: "mod.o", + sources: ["mod.c"], + cache: cache, + env: env, + vars: {"CCCMD" => ["llc", "${_SOURCES}"]}) end it "supports overriding DEPFILESUFFIX construction variable" do @@ -24,11 +29,23 @@ module Rscons expect(File).to receive(:exists?).with("f.d").and_return(false) expect(cache).to receive(:register_build) - subject.run("f.o", ["in.c"], cache, env, "DEPFILESUFFIX" => ".d") + subject.run( + target: "f.o", + sources: ["in.c"], + cache: cache, + env: env, + vars: {"DEPFILESUFFIX" => ".d"}) end it "raises an error when given a source file with an unknown suffix" do - expect { subject.run("mod.o", ["mod.xyz"], :cache, env, {}) }.to raise_error /unknown input file type: "mod.xyz"/ + expect do + subject.run( + target: "mod.o", + sources: ["mod.xyz"], + cache: :cache, + env: env, + vars: {}) + end.to raise_error /unknown input file type: "mod.xyz"/ end end end diff --git a/spec/rscons/builders/program_spec.rb b/spec/rscons/builders/program_spec.rb index ec35081..7a42009 100644 --- a/spec/rscons/builders/program_spec.rb +++ b/spec/rscons/builders/program_spec.rb @@ -6,12 +6,22 @@ module Rscons it "supports overriding CC construction variable" do expect(subject).to receive(:standard_build).with("LD prog", "prog", ["sp-c++", "-o", "prog", "prog.o"], ["prog.o"], env, :cache) - subject.run("prog", ["prog.o"], :cache, env, "CC" => "sp-c++") + subject.run( + target: "prog", + sources: ["prog.o"], + cache: :cache, + env: env, + vars: {"CC" => "sp-c++"}) end it "supports overriding LDCMD construction variable" do expect(subject).to receive(:standard_build).with("LD prog.exe", "prog.exe", ["special", "LD!", "prog.o"], ["prog.o"], env, :cache) - subject.run("prog.exe", ["prog.o"], :cache, env, "LDCMD" => ["special", "LD!", "${_SOURCES}"]) + subject.run( + target: "prog.exe", + sources: ["prog.o"], + cache: :cache, + env: env, + vars: {"LDCMD" => ["special", "LD!", "${_SOURCES}"]}) end end end diff --git a/spec/rscons/environment_spec.rb b/spec/rscons/environment_spec.rb index d6ac557..9efd325 100644 --- a/spec/rscons/environment_spec.rb +++ b/spec/rscons/environment_spec.rb @@ -162,65 +162,6 @@ module Rscons end end - describe "#process" do - it "runs builders for all of the targets specified" do - env = Environment.new - env.Program("a.out", "main.c") - - cache = "cache" - expect(Cache).to receive(:instance).and_return(cache) - allow(cache).to receive(:clear_checksum_cache!) - expect(env).to receive(:run_builder).with(anything, "a.out", ["main.c"], cache, {}, allow_delayed_execution: true, setup_info: nil).and_return(true) - expect(cache).to receive(:write) - - env.process - end - - it "builds dependent targets first" do - env = Environment.new - env.Program("a.out", "main.o") - env.Object("main.o", "other.cc") - - cache = "cache" - expect(Cache).to receive(:instance).and_return(cache) - allow(cache).to receive(:clear_checksum_cache!) - expect(env).to receive(:run_builder).with(anything, "main.o", ["other.cc"], cache, {}, allow_delayed_execution: true, setup_info: nil).and_return("main.o") - expect(env).to receive(:run_builder).with(anything, "a.out", ["main.o"], cache, {}, allow_delayed_execution: true, setup_info: nil).and_return("a.out") - expect(cache).to receive(:write) - - env.process - end - - it "raises a BuildError when building fails" do - env = Environment.new - env.Program("a.out", "main.o") - env.Object("main.o", "other.cc") - - cache = "cache" - expect(Cache).to receive(:instance).and_return(cache) - allow(cache).to receive(:clear_checksum_cache!) - expect(env).to receive(:run_builder).with(anything, "main.o", ["other.cc"], cache, {}, allow_delayed_execution: true, setup_info: nil).and_return(false) - expect(cache).to receive(:write) - - expect { env.process }.to raise_error BuildError, /Failed.to.build.main.o/ - end - - it "writes the cache when the Builder raises an exception" do - env = Environment.new - env.Object("module.o", "module.c") - - cache = "cache" - expect(Cache).to receive(:instance).and_return(cache) - expect(cache).to receive(:clear_checksum_cache!) - allow(env).to receive(:run_builder) do |builder, target, sources, cache, vars| - raise "Ruby exception thrown by builder" - end - expect(cache).to receive(:write) - - expect { env.process }.to raise_error RuntimeError, /Ruby exception thrown by builder/ - end - end - describe "#build_command" do it "returns a command based on the variables in the Environment" do env = Environment.new @@ -264,8 +205,7 @@ module Rscons env = Environment.new(echo: :short) expect(env).to receive(:puts).with("short desc") expect(env).to receive(:system).with(*Rscons.command_executer, "a", "command").and_return(false) - expect($stdout).to receive(:write).with("Failed command was: ") - expect(env).to receive(:puts).with("a command") + expect($stdout).to receive(:puts).with("Failed command was: a command") env.execute("short desc", ["a", "command"]) end end