From 6ce3d59ad9783d6019f2c1537e42c2eb2f2ec1f0 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 25 Feb 2019 21:13:57 -0500 Subject: [PATCH] Add integration test for copying multiple sources with Copy builder --- build_tests/typical/copy_multiple.rb | 5 +++ lib/rscons/util.rb | 2 +- spec/build_tests_spec.rb | 63 +++++++++++++++++++--------- 3 files changed, 49 insertions(+), 21 deletions(-) create mode 100644 build_tests/typical/copy_multiple.rb diff --git a/build_tests/typical/copy_multiple.rb b/build_tests/typical/copy_multiple.rb new file mode 100644 index 0000000..91aa97f --- /dev/null +++ b/build_tests/typical/copy_multiple.rb @@ -0,0 +1,5 @@ +build do + Environment.new do |env| + env.Copy("dest", ["copy.rb", "copy_multiple.rb"]) + end +end diff --git a/lib/rscons/util.rb b/lib/rscons/util.rb index c54df87..710e2dc 100644 --- a/lib/rscons/util.rb +++ b/lib/rscons/util.rb @@ -39,7 +39,7 @@ module Rscons if paths.size == 1 paths.first else - "#{paths.first} (#{paths.size - 1})" + "#{paths.first} (+#{paths.size - 1})" end end diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index cc8d4f1..f9e3e82 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -953,6 +953,49 @@ EOF end end + context "Copy builder" do + it "copies a file to the target file name" do + test_dir("typical") + + result = run_rscons(rsconscript: "copy.rb") + expect(result.stderr).to eq "" + expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"] + + result = run_rscons(rsconscript: "copy.rb") + expect(result.stderr).to eq "" + expect(result.stdout).to eq "" + + expect(File.exists?("inst.exe")).to be_truthy + expect(File.read("inst.exe", mode: "rb")).to eq(File.read("copy.rb", mode: "rb")) + + FileUtils.rm("inst.exe") + result = run_rscons(rsconscript: "copy.rb") + expect(result.stderr).to eq "" + expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"] + end + + it "copies multiple files to the target directory name" do + test_dir("typical") + + result = run_rscons(rsconscript: "copy_multiple.rb") + expect(result.stderr).to eq "" + expect(lines(result.stdout)).to include *["Copy copy.rb (+1) => dest"] + + result = run_rscons(rsconscript: "copy_multiple.rb") + expect(result.stderr).to eq "" + expect(result.stdout).to eq "" + + expect(Dir.exists?("dest")).to be_truthy + expect(File.exists?("dest/copy.rb")).to be_truthy + expect(File.exists?("dest/copy_multiple.rb")).to be_truthy + + FileUtils.rm_rf("dest") + result = run_rscons(rsconscript: "copy_multiple.rb") + expect(result.stderr).to eq "" + expect(lines(result.stdout)).to include *["Copy copy.rb (+1) => dest"] + end + end + context "Install buildler" do it "copies a file to the target file name" do test_dir("typical") @@ -974,26 +1017,6 @@ EOF expect(lines(result.stdout)).to include *["Install install.rb => inst.exe"] end - it "operates the same as a Copy builder" do - test_dir("typical") - - result = run_rscons(rsconscript: "copy.rb") - expect(result.stderr).to eq "" - expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"] - - result = run_rscons(rsconscript: "copy.rb") - expect(result.stderr).to eq "" - expect(result.stdout).to eq "" - - expect(File.exists?("inst.exe")).to be_truthy - expect(File.read("inst.exe", mode: "rb")).to eq(File.read("copy.rb", mode: "rb")) - - FileUtils.rm("inst.exe") - result = run_rscons(rsconscript: "copy.rb") - expect(result.stderr).to eq "" - expect(lines(result.stdout)).to include *["Copy copy.rb => inst.exe"] - end - it "copies a file to the target directory name" do test_dir("typical")