Skip to content

Commit

Permalink
Minitest support
Browse files Browse the repository at this point in the history
  • Loading branch information
shiroyasha committed Mar 29, 2017
1 parent 71adf6a commit 6808530
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
5 changes: 5 additions & 0 deletions exe/minitest_booster
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env ruby

require "test_boosters"

exit(TestBoosters::Boosters::Minitest.new.run)
1 change: 1 addition & 0 deletions lib/test_boosters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ module TestBoosters
require "test_boosters/boosters/cucumber"
require "test_boosters/boosters/go_test"
require "test_boosters/boosters/ex_unit"
require "test_boosters/boosters/minitest"
end
2 changes: 1 addition & 1 deletion lib/test_boosters/boosters/ex_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize
end

def split_configuration_path
ENV["EX_UNIT_TEST_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/ex_unit_split_configuration.json"
ENV["EX_UNIT_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/ex_unit_split_configuration.json"
end

end
Expand Down
17 changes: 17 additions & 0 deletions lib/test_boosters/boosters/minitest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module TestBoosters
module Boosters
class Minitest < Base

FILE_PATTERN = "test/**/*/_test.rb".freeze

def initialize
super(FILE_PATTERN, split_configuration_path, "ruby")
end

def split_configuration_path
ENV["MINITEST_SPLIT_CONFIGURATION_PATH"] || "#{ENV["HOME"]}/minitest_split_configuration.json"
end

end
end
end
27 changes: 27 additions & 0 deletions spec/lib/test_boosters/boosters/minitest_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "spec_helper"

describe TestBoosters::Boosters::Minitest do
before do
allow(TestBoosters::CliParser).to receive(:parse).and_return(:job_index => 10, :job_count => 32)
end

subject(:booster) { described_class.new }

describe "#split_configuration_path" do
before { ENV["MINITEST_SPLIT_CONFIGURATION_PATH"] = "/tmp/path.txt" }

context "when the environment variable is set" do
it "returns its values" do
expect(booster.split_configuration_path).to eq("/tmp/path.txt")
end
end

context "when the environment variable is not set" do
before { ENV.delete("MINITEST_SPLIT_CONFIGURATION_PATH") }

it "returns the path from the home directory" do
expect(booster.split_configuration_path).to eq("#{ENV["HOME"]}/minitest_split_configuration.json")
end
end
end
end
22 changes: 10 additions & 12 deletions spec/lib/test_boosters/insights_uploader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

describe TestBoosters::InsightsUploader do

it "uploads dummy json file" do
ENV["SEMAPHORE_PROJECT_UUID"] = "not a project UUID"
ENV["SEMAPHORE_EXECUTABLE_UUID"] = "not a build UUID"
ENV["SEMAPHORE_JOB_UUID"] = "not a job UUID"
before do
@report_path = "/tmp/report.json"

dymmy_json_file = "spec/dymmy_json_file.json"

expect(TestBoosters::InsightsUploader.upload("rspec", dymmy_json_file)).to eq(0)
File.write(@report_path, "")
end

it "fails to upload dummy json file - no file" do
expect(TestBoosters::InsightsUploader.upload("rspec", "no-file")).to eq(1)
end
it "uploads json file" do
ENV["SEMAPHORE_PROJECT_UUID"] = "aaaa"
ENV["SEMAPHORE_EXECUTABLE_UUID"] = "bbbb"
ENV["SEMAPHORE_JOB_UUID"] = "cccc"

expect(TestBoosters::Shell).to receive(:execute).with("http POST 'https://insights-receiver.semaphoreci.com/job_reports?project_hash_id=aaaa&build_hash_id=bbbb&job_hash_id=cccc' rspec:=@/tmp/report.json > ~/insights_uploader.log", :silent => true)

it "fails to upload dummy json file - malformed file" do
expect(TestBoosters::InsightsUploader.upload("rspec", "README.md")).to eq(1)
TestBoosters::InsightsUploader.upload("rspec", @report_path)
end

end

0 comments on commit 6808530

Please sign in to comment.