Skip to content

Commit

Permalink
Fix existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksey Kozhevnikov committed Jul 5, 2018
1 parent a2af3f2 commit 2d05457
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
9 changes: 9 additions & 0 deletions spec/slather/coverage_service/coveralls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@
before(:each) {
fixtures_project.ci_service = :travis_ci
project_root = Pathname("./").realpath
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
{
"data":[
{
"files":[]
}
]
}
))
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
| 1|//
| 2|// fixtures.m
Expand Down
10 changes: 9 additions & 1 deletion spec/slather/coverage_service/hardcover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@
allow(Slather::Project).to receive(:yml).and_return(fixture_yaml)
fixtures_project.ci_service = :jenkins_ci
project_root = Pathname("./").realpath
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
{
"data":[
{
"files":[]
}
]
}
))
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return("#{project_root}/spec/fixtures/fixtures/fixtures.m:
| 1|//
| 2|// fixtures.m
Expand Down Expand Up @@ -104,7 +113,6 @@

it "should always remove the hardcover_json_file after it's done" do
allow(fixtures_project).to receive(:`)

allow(fixtures_project).to receive(:jenkins_job_id).and_return("slather-master/9182")
allow(fixtures_project).to receive(:coverage_service_url).and_return("http://api.hardcover.io")
fixtures_project.post
Expand Down
41 changes: 41 additions & 0 deletions spec/slather/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
allow(Dir).to receive(:[]).and_call_original
allow(Dir).to receive(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
allow(fixtures_project).to receive(:binary_file).and_return(["Fixtures"])
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
{
"data":[
{
"files":[
{
"filename":"spec/fixtures/fixtures/Fixtures.swift"
}
]
}
]
}
))
allow(fixtures_project).to receive(:profdata_llvm_cov_output).and_return("#{FIXTURES_SWIFT_FILE_PATH}:
| 0|
| 1|import UIKit
Expand Down Expand Up @@ -111,6 +124,18 @@ class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
allow(fixtures_project).to receive(:ignore_list).and_return([])
allow(Dir).to receive(:[]).with("#{fixtures_project.build_directory}/**/Coverage.profdata").and_return(["/some/path/Coverage.profdata"])
allow(fixtures_project).to receive(:binary_file).and_return(["Fixtures"])
allow(fixtures_project).to receive(:unsafe_llvm_cov_export_output).and_return("
{
\"data\":[
{
\"files\":[
{
\"filename\":\"sp\145c/fixtures/fixtures/fixtures.m\"
}
]
}
]
}")
allow(fixtures_project).to receive(:unsafe_profdata_llvm_cov_output).and_return("#{FIXTURES_SWIFT_FILE_PATH}:
1| 8| func application(application: \255, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
1| 9| return true
Expand Down Expand Up @@ -563,6 +588,22 @@ class SpecXcode7CoverageFile < Slather::ProfdataCoverageFile
end

it "should print out the coverage for each file, and then total coverage" do
allow(fixtures_project).to receive(:llvm_cov_export_output).and_return(%q(
{
"data":[
{
"files":[
{
"filename":"spec/fixtures/fixtures/fixtures.m"
},
{
"filename":"spec/fixtures/fixturesTwo/fixturesTwo.m"
}
]
}
]
}
))
["spec/fixtures/fixtures/fixtures.m: 3 of 6 lines (50.00%)",
"spec/fixtures/fixturesTwo/fixturesTwo.m: 6 of 6 lines (100.00%)",
"Tested 9/12 statements",
Expand Down

0 comments on commit 2d05457

Please sign in to comment.