Родитель
0847b50e24
Коммит
d360076090
|
@ -53,7 +53,7 @@ tasks:
|
|||
pip3 install --quiet pre-commit &&
|
||||
pre-commit run -a --show-diff-on-failure &&
|
||||
pre-commit run --show-diff-on-failure -c .pre-commit-audit-config.yaml &&
|
||||
cargo test --workspace --verbose --all-features -- --nocapture &&
|
||||
cargo test --workspace --verbose --all-features --no-fail-fast -- --nocapture &&
|
||||
cd enums &&
|
||||
cargo build --verbose --all-features"
|
||||
metadata:
|
||||
|
@ -149,7 +149,7 @@ tasks:
|
|||
- cd rust-code-analysis
|
||||
- git -c advice.detachedHead=false checkout ${head_rev}
|
||||
- git submodule update --init
|
||||
- cargo test --workspace --verbose --all-features -- --nocapture
|
||||
- cargo test --workspace --verbose --all-features --no-fail-fast -- --nocapture
|
||||
mounts:
|
||||
- content:
|
||||
url: https://win.rustup.rs/
|
||||
|
|
|
@ -16,7 +16,6 @@ crossbeam = { version = "^0.8", features = ["crossbeam-channel"] }
|
|||
fxhash = "0.2"
|
||||
globset = "^0.4"
|
||||
lazy_static = "^1.3"
|
||||
once_cell = "1.16.0"
|
||||
num = "^0.4"
|
||||
num-derive = "^0.3"
|
||||
num-format = "^0.4"
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
use globset::GlobSet;
|
||||
use globset::{Glob, GlobSetBuilder};
|
||||
use once_cell::sync::Lazy;
|
||||
use rust_code_analysis::LANG;
|
||||
use rust_code_analysis::*;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
|
||||
use globset::GlobSet;
|
||||
use globset::{Glob, GlobSetBuilder};
|
||||
|
||||
use rust_code_analysis::LANG;
|
||||
use rust_code_analysis::*;
|
||||
|
||||
const REPO: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/", "repositories");
|
||||
const SNAPSHOT_PATH: &str = concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/tests/",
|
||||
"repositories/rca-output/snapshots"
|
||||
);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Config {
|
||||
language: Option<LANG>,
|
||||
|
@ -32,15 +40,12 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
|
|||
// Get FuncSpace struct
|
||||
let funcspace_struct = get_function_spaces(&language, source, &path, None).unwrap();
|
||||
|
||||
let mut settings = insta::Settings::new();
|
||||
|
||||
settings.set_snapshot_path(
|
||||
Path::new("./repositories/rca-output/snapshots")
|
||||
.join(path.strip_prefix(*REPO).unwrap())
|
||||
.parent()
|
||||
.unwrap(),
|
||||
);
|
||||
settings.bind(|| {
|
||||
insta::with_settings!({snapshot_path => Path::new(SNAPSHOT_PATH)
|
||||
.join(path.strip_prefix(Path::new(REPO)).unwrap())
|
||||
.parent()
|
||||
.unwrap(),
|
||||
prepend_module_to_snapshot => false
|
||||
}, {
|
||||
// Redact away the name since paths are different on windows.
|
||||
let value = format!(
|
||||
"{:#.3?}",
|
||||
|
@ -49,20 +54,20 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
|
|||
..funcspace_struct
|
||||
}
|
||||
);
|
||||
|
||||
insta::assert_snapshot!(
|
||||
path.file_name().unwrap().to_string_lossy().as_ref(),
|
||||
value,
|
||||
"funcspace_struct"
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
static REPO: Lazy<&Path> = Lazy::new(|| Path::new("./tests/repositories"));
|
||||
|
||||
/// Produces metrics runtime and compares them with previously generated json files
|
||||
fn compare_rca_output_with_files(repo_name: &str, include: &[&str]) {
|
||||
pub fn compare_rca_output_with_files(repo_name: &str, include: &[&str]) {
|
||||
let num_jobs = 4;
|
||||
|
||||
let cfg = Config { language: None };
|
||||
|
@ -75,7 +80,7 @@ fn compare_rca_output_with_files(repo_name: &str, include: &[&str]) {
|
|||
let files_data = FilesData {
|
||||
include: gsbi.build().unwrap(),
|
||||
exclude: GlobSet::empty(),
|
||||
paths: vec![REPO.join(repo_name)],
|
||||
paths: vec![Path::new(REPO).join(repo_name)],
|
||||
};
|
||||
|
||||
if let Err(e) = ConcurrentRunner::new(num_jobs, act_on_file).run(cfg, files_data) {
|
||||
|
@ -83,18 +88,3 @@ fn compare_rca_output_with_files(repo_name: &str, include: &[&str]) {
|
|||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deepspeech() {
|
||||
compare_rca_output_with_files("DeepSpeech", &["*.cc", "*.cpp", "*.h", "*.hh"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pdfjs() {
|
||||
compare_rca_output_with_files("pdf.js", &["*.js"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serde() {
|
||||
compare_rca_output_with_files("serde", &["*.rs"]);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
mod common;
|
||||
|
||||
use common::compare_rca_output_with_files;
|
||||
|
||||
#[test]
|
||||
fn test_deepspeech() {
|
||||
compare_rca_output_with_files("DeepSpeech", &["*.cc", "*.cpp", "*.h", "*.hh"]);
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
mod common;
|
||||
|
||||
use common::compare_rca_output_with_files;
|
||||
|
||||
#[test]
|
||||
fn test_pdfjs() {
|
||||
compare_rca_output_with_files("pdf.js", &["*.js"]);
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 21e97f6857d18528c1ecb3d73933f10d44c7e0af
|
||||
Subproject commit c8908c63e992c9af90e0d925570294b788e8d897
|
|
@ -0,0 +1,8 @@
|
|||
mod common;
|
||||
|
||||
use common::compare_rca_output_with_files;
|
||||
|
||||
#[test]
|
||||
fn test_serde() {
|
||||
compare_rca_output_with_files("serde", &["*.rs"]);
|
||||
}
|
Загрузка…
Ссылка в новой задаче