spec/integration/go_spec.rb in vx-builder-0.4.0 vs spec/integration/go_spec.rb in vx-builder-0.5.0
- old
+ new
@@ -1,40 +1,72 @@
require 'spec_helper'
+require 'yaml'
+require 'tmpdir'
+require 'fileutils'
describe "(integration) go" do
- let(:build_configuration) {
- Vx::Builder::BuildConfiguration.from_yaml(config)
- }
- let(:matrix) { Vx::Builder.matrix build_configuration }
- let(:task) { create :task }
- let(:script) { Vx::Builder.script(task, source) }
- subject { matrix }
+ let(:path) { Dir.tmpdir + "/vx-builder-test" }
- def write_script_to_filter(prefix)
+ before do
+ FileUtils.rm_rf(path)
+ FileUtils.mkdir_p(path)
+ end
+ after { FileUtils.rm_rf(path) }
+
+ def write_script_to_filter(prefix, script)
+=begin
File.open(fixture_path("integration/go/#{prefix}before_script.sh"), 'w') do |io|
io << script.to_before_script
end
File.open(fixture_path("integration/go/#{prefix}after_script.sh"), 'w') do |io|
io << script.to_after_script
end
File.open(fixture_path("integration/go/#{prefix}script.sh"), 'w') do |io|
io << script.to_script
end
+=end
end
- context "language" do
- let(:config) { fixture("integration/go/language/config.yml") }
- let(:source) { matrix.build.first }
+ def build(file, options = {})
+ config = Vx::Builder::BuildConfiguration.from_yaml(file)
+ matrix = Vx::Builder.matrix config
+ options[:task] ||= create(:task)
+ script = Vx::Builder.script(options[:task], matrix.build.first)
+ OpenStruct.new script: script, matrix: matrix
+ end
- before { write_script_to_filter "language/" }
+ context "(generation)" do
+ let(:file) { fixture("integration/go/language/config.yml") }
+ let(:b) { build(file) }
+ before { write_script_to_filter "language/", b.script }
it "should generate one configuration" do
- expect(matrix.build).to have(1).item
+ expect(b.matrix.build).to have(1).item
end
it "should generate valid scripts" do
- expect(script.to_before_script).to eq fixture("integration/go/language/before_script.sh")
- expect(script.to_script).to eq fixture("integration/go/language/script.sh")
- expect(script.to_after_script).to eq fixture("integration/go/language/after_script.sh")
+ expect(b.script.to_before_script).to eq fixture("integration/go/language/before_script.sh")
+ expect(b.script.to_script).to eq fixture("integration/go/language/script.sh")
+ expect(b.script.to_after_script).to eq fixture("integration/go/language/after_script.sh")
+ end
+ end
+
+ it "should succesfuly run lang/go", real: true do
+ file = {"language" => "go"}.to_yaml
+ task = create(
+ :task,
+ sha: "HEAD",
+ branch: "lang/go"
+ )
+
+ b = build(file, task: task)
+ Dir.chdir(path) do
+ File.open("script.sh", "w") do |io|
+ io.write "set -e\n"
+ io.write b.script.to_before_script
+ io.write b.script.to_script
+ end
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
+ expect($?.to_i).to eq 0
end
end
end