Skip to content

Commit

Permalink
Make code-coverage an executable
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-otf committed Nov 22, 2024
1 parent aa3cf98 commit c02a586
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 240 deletions.
366 changes: 187 additions & 179 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pallets/admin-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ subtensor-linting = { workspace = true }

[features]
default = ["std"]
code-coverage = []
std = [
"codec/std",
"frame-benchmarking?/std",
Expand Down
11 changes: 0 additions & 11 deletions pallets/admin-utils/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
fn main() {
println!("cargo:rerun-if-changed=src");
subtensor_linting::walk_src();

#[cfg(feature = "code-coverage")]
{
use std::env;
use std::path::Path;
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let source_dir = Path::new(&source_dir);
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir);
// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir);
}
}
1 change: 0 additions & 1 deletion pallets/collective/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ subtensor-linting = { workspace = true }

[features]
default = ["std"]
code-coverage = []
std = [
"codec/std",
"frame-benchmarking?/std",
Expand Down
11 changes: 0 additions & 11 deletions pallets/collective/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
fn main() {
println!("cargo:rerun-if-changed=src");
subtensor_linting::walk_src();

#[cfg(feature = "code-coverage")]
{
use std::env;
use std::path::Path;
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let source_dir = Path::new(&source_dir);
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir);
// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir);
}
}
1 change: 0 additions & 1 deletion pallets/commitments/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ subtensor-linting = { workspace = true }

[features]
default = ["std"]
code-coverage = []
std = [
"codec/std",
"frame-benchmarking?/std",
Expand Down
11 changes: 0 additions & 11 deletions pallets/commitments/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
fn main() {
println!("cargo:rerun-if-changed=src");
subtensor_linting::walk_src();

#[cfg(feature = "code-coverage")]
{
use std::env;
use std::path::Path;
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let source_dir = Path::new(&source_dir);
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir);
// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir);
}
}
1 change: 0 additions & 1 deletion pallets/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ subtensor-linting = { workspace = true }

[features]
default = ["std"]
code-coverage = []
std = [
"codec/std",
"frame-benchmarking?/std",
Expand Down
11 changes: 0 additions & 11 deletions pallets/registry/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
fn main() {
println!("cargo:rerun-if-changed=src");
subtensor_linting::walk_src();

#[cfg(feature = "code-coverage")]
{
use std::env;
use std::path::Path;
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let source_dir = Path::new(&source_dir);
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir);
// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir);
}
}
1 change: 0 additions & 1 deletion pallets/subtensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ subtensor-linting = { workspace = true }

[features]
default = ["std"]
code-coverage = []
std = [
"codec/std",
"frame-benchmarking/std",
Expand Down
11 changes: 0 additions & 11 deletions pallets/subtensor/build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
fn main() {
println!("cargo:rerun-if-changed=src");
subtensor_linting::walk_src();

#[cfg(feature = "code-coverage")]
{
use std::env;
use std::path::Path;
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let source_dir = Path::new(&source_dir);
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir);
// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir);
}
}
4 changes: 4 additions & 0 deletions support/code-coverage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ procedural-fork.workspace = true
walkdir.workspace = true
rayon.workspace = true

[dev-dependencies]
frame-system.workspace = true
frame-support.workspace = true

[lints]
workspace = true
2 changes: 1 addition & 1 deletion support/code-coverage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rayon::{
use std::{
collections::{HashMap, HashSet},
ffi::OsStr,
fs::{self},
fs,
path::{Path, PathBuf},
str::FromStr,
};
Expand Down
14 changes: 14 additions & 0 deletions support/code-coverage/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::env;
use std::path::PathBuf;

fn main() {
// should we instead provide an argument to set the directory?
let source_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut source_dir = PathBuf::from(&source_dir);
source_dir.pop();
source_dir.pop();
let rust_files = subtensor_code_coverage::collect_rust_files(source_dir.as_path());

// Generate code coverage report
subtensor_code_coverage::analyze_files(&rust_files, source_dir.as_path());
}

0 comments on commit c02a586

Please sign in to comment.