зеркало из https://github.com/mozilla/grcov.git
Coveralls: rename service_job_number to service_job_id (#376)
* Coveralls: use correct JSON key for service job ID This makes Coverall reference Travis build in the report, and use author's GitHub handle instead of name. Fixes #373. * Do not require commit-sha for Coveralls Due to previous commit, "git" key in Coveralls' JSON isn't as important now, and grcov can generate valid reports even without knowing the commit SHA. It was decided[1] to keep the CLI switch, but since it isn't strictly necessary now, we make it optional. 1. https://github.com/mozilla/grcov/issues/373#issuecomment-573403732 * Add --service-job-id This deprecates --service-job-number.
This commit is contained in:
Родитель
86cdc5c383
Коммит
7396749f6d
|
@ -54,7 +54,8 @@ OPTIONS:
|
|||
-p, --prefix-dir <PATH>
|
||||
Specifies a prefix to remove from the paths (e.g. if grcov is run on a different machine than the one that
|
||||
generated the code coverage information)
|
||||
--service-job-number <SERVICE JOB NUMBER> Sets the service job number
|
||||
--service-job-id <SERVICE JOB ID> Sets the service job id
|
||||
--service-job-number <SERVICE JOB NUMBER> Sets the service job number (deprecated in favour of --service-job-id)
|
||||
--service-name <SERVICE NAME> Sets the service name
|
||||
--service-number <SERVICE NUMBER> Sets the service number
|
||||
--service-pull-request <SERVICE PULL REQUEST>
|
||||
|
|
27
src/main.rs
27
src/main.rs
|
@ -121,11 +121,7 @@ fn main() {
|
|||
.help("Sets the hash of the commit used to generate the code coverage data")
|
||||
.long("commit-sha")
|
||||
.value_name("COMMIT HASH")
|
||||
.takes_value(true)
|
||||
.required_ifs(&[
|
||||
("output_type", "coveralls"),
|
||||
("output_type", "coveralls+")
|
||||
]))
|
||||
.takes_value(true))
|
||||
|
||||
.arg(Arg::with_name("service_name")
|
||||
.help("Sets the service name")
|
||||
|
@ -140,10 +136,18 @@ fn main() {
|
|||
.takes_value(true))
|
||||
|
||||
.arg(Arg::with_name("service_job_number")
|
||||
.help("Sets the service job number")
|
||||
.help("Sets the service job number (deprecated in favour of --service-job-id)")
|
||||
.long("service-job-number")
|
||||
.value_name("SERVICE JOB NUMBER")
|
||||
.takes_value(true))
|
||||
.takes_value(true)
|
||||
.conflicts_with("service_job_id"))
|
||||
|
||||
.arg(Arg::with_name("service_job_id")
|
||||
.help("Sets the service job id")
|
||||
.long("service-job-id")
|
||||
.value_name("SERVICE JOB ID")
|
||||
.takes_value(true)
|
||||
.conflicts_with("service_job_number"))
|
||||
|
||||
.arg(Arg::with_name("service_pull_request")
|
||||
.help("Sets the service pull request number")
|
||||
|
@ -209,7 +213,10 @@ fn main() {
|
|||
let service_name = matches.value_of("service_name").unwrap_or("");
|
||||
let is_parallel = matches.is_present("parallel");
|
||||
let service_number = matches.value_of("service_number").unwrap_or("");
|
||||
let service_job_number = matches.value_of("service_job_number").unwrap_or("");
|
||||
let service_job_id = matches
|
||||
.value_of("service_job_id")
|
||||
.or_else(|| matches.value_of("service_job_number"))
|
||||
.unwrap_or("");
|
||||
let service_pull_request = matches.value_of("service_pull_request").unwrap_or("");
|
||||
let vcs_branch = matches.value_of("vcs_branch").unwrap_or("");
|
||||
let log = matches.value_of("log").unwrap_or("");
|
||||
|
@ -376,7 +383,7 @@ fn main() {
|
|||
repo_token,
|
||||
service_name,
|
||||
service_number,
|
||||
service_job_number,
|
||||
service_job_id,
|
||||
service_pull_request,
|
||||
commit_sha,
|
||||
false,
|
||||
|
@ -390,7 +397,7 @@ fn main() {
|
|||
repo_token,
|
||||
service_name,
|
||||
service_number,
|
||||
service_job_number,
|
||||
service_job_id,
|
||||
service_pull_request,
|
||||
commit_sha,
|
||||
true,
|
||||
|
|
|
@ -369,7 +369,7 @@ pub fn output_coveralls(
|
|||
repo_token: &str,
|
||||
service_name: &str,
|
||||
service_number: &str,
|
||||
service_job_number: &str,
|
||||
service_job_id: &str,
|
||||
service_pull_request: &str,
|
||||
commit_sha: &str,
|
||||
with_function_info: bool,
|
||||
|
@ -440,7 +440,7 @@ pub fn output_coveralls(
|
|||
"source_files": source_files,
|
||||
"service_name": service_name,
|
||||
"service_number": service_number,
|
||||
"service_job_number": service_job_number,
|
||||
"service_job_id": service_job_id,
|
||||
"service_pull_request": service_pull_request,
|
||||
"parallel": parallel,
|
||||
}),
|
||||
|
@ -587,4 +587,43 @@ mod tests {
|
|||
|
||||
assert_eq!(results, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_coveralls_service_job_id() {
|
||||
let tmp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
|
||||
let file_name = "test_coveralls_service_job_id.json";
|
||||
let file_path = tmp_dir.path().join(&file_name);
|
||||
|
||||
let results = vec![(
|
||||
PathBuf::from("foo/bar/a.cpp"),
|
||||
PathBuf::from("foo/bar/a.cpp"),
|
||||
CovResult {
|
||||
lines: [(1, 10), (2, 11)].iter().cloned().collect(),
|
||||
branches: BTreeMap::new(),
|
||||
functions: FxHashMap::default(),
|
||||
},
|
||||
)];
|
||||
|
||||
let results = Box::new(results.into_iter());
|
||||
let expected_service_job_id: &str = "100500";
|
||||
let with_function_info: bool = true;
|
||||
let parallel: bool = true;
|
||||
output_coveralls(
|
||||
results,
|
||||
"unused",
|
||||
"unused",
|
||||
"unused",
|
||||
expected_service_job_id,
|
||||
"unused",
|
||||
"unused",
|
||||
with_function_info,
|
||||
Some(file_path.to_str().unwrap()),
|
||||
"unused",
|
||||
parallel,
|
||||
);
|
||||
|
||||
let results: Value = serde_json::from_str(&read_file(&file_path)).unwrap();
|
||||
|
||||
assert_eq!(results["service_job_id"], expected_service_job_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
},
|
||||
"repo_token": "TOKEN",
|
||||
"service_job_number": "",
|
||||
"service_job_id": "",
|
||||
"service_name": "",
|
||||
"service_number": "",
|
||||
"source_files": [
|
||||
|
|
|
@ -274,7 +274,7 @@ fn check_equal_coveralls(expected_output: &str, output: &str, skip_branches: boo
|
|||
assert_eq!(expected["git"]["branch"], actual["git"]["branch"]);
|
||||
assert_eq!(expected["git"]["head"]["id"], actual["git"]["head"]["id"]);
|
||||
assert_eq!(expected["repo_token"], actual["repo_token"]);
|
||||
assert_eq!(expected["service_job_number"], actual["service_job_number"]);
|
||||
assert_eq!(expected["service_job_id"], actual["service_job_id"]);
|
||||
assert_eq!(expected["service_name"], actual["service_name"]);
|
||||
assert_eq!(expected["service_number"], actual["service_number"]);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче