Add submodules for the integration tests (#960)
DeepSpeech "v0.9.3" pdf.js "v2.12.313" rust "1.57.0"
This commit is contained in:
Родитель
ec02e83b94
Коммит
219ede1a56
|
@ -1,4 +1,3 @@
|
|||
target
|
||||
enums/target
|
||||
tests/repositories
|
||||
*~
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[submodule "tests/repositories/rca-output"]
|
||||
path = tests/repositories/rca-output
|
||||
url = https://github.com/SoftengPoliTo/rca-output
|
||||
[submodule "tests/repositories/DeepSpeech"]
|
||||
path = tests/repositories/DeepSpeech
|
||||
url = https://github.com/mozilla/DeepSpeech
|
||||
[submodule "tests/repositories/rust"]
|
||||
path = tests/repositories/rust
|
||||
url = https://github.com/rust-lang/rust.git
|
||||
[submodule "tests/repositories/pdf.js"]
|
||||
path = tests/repositories/pdf.js
|
||||
url = https://github.com/mozilla/pdf.js
|
|
@ -1273,6 +1273,7 @@ dependencies = [
|
|||
"num-derive",
|
||||
"num-format",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"petgraph",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
|
|
|
@ -16,6 +16,7 @@ crossbeam = { version = "^0.8", features = ["crossbeam-channel"] }
|
|||
fxhash = "0.2"
|
||||
globset = "^0.4"
|
||||
lazy_static = "^1.3"
|
||||
once_cell = "1.12.1"
|
||||
num = "^0.4"
|
||||
num-derive = "^0.3"
|
||||
num-format = "^0.4"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit f2e9c85880dff94115ab510cde9ca4af7ee51c19
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a2ae56f394acb485ce7067a75342ac60da17f171
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 16033b9fd6f4e0ce866df88d127e8c5180f0d0ed
|
|
@ -0,0 +1 @@
|
|||
Subproject commit f1edd0429582dd29cccacaf50fd134b05593bd9c
|
|
@ -1,5 +1,6 @@
|
|||
use globset::GlobSet;
|
||||
use globset::{Glob, GlobSetBuilder};
|
||||
use once_cell::sync::Lazy;
|
||||
use rust_code_analysis::LANG;
|
||||
use rust_code_analysis::*;
|
||||
use std::fs::*;
|
||||
|
@ -7,16 +8,11 @@ use std::io::BufReader;
|
|||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::process::Command;
|
||||
use std::sync::Once;
|
||||
|
||||
// Synchronization primitive
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Config {
|
||||
language: Option<LANG>,
|
||||
output_folder: String,
|
||||
output_folder: PathBuf,
|
||||
}
|
||||
|
||||
fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
|
||||
|
@ -37,15 +33,11 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
|
|||
};
|
||||
|
||||
// Build json file path
|
||||
let file_path = Path::new(&cfg.output_folder)
|
||||
.join(path.strip_prefix("./").unwrap())
|
||||
.into_os_string()
|
||||
.into_string()
|
||||
.unwrap()
|
||||
+ ".json";
|
||||
let mut file_path = cfg.output_folder.join(path.strip_prefix("./").unwrap());
|
||||
file_path.set_extension("json");
|
||||
|
||||
// Produce and compare metrics only if json file exists
|
||||
if Path::new(&file_path).exists() {
|
||||
if file_path.exists() {
|
||||
// Get FuncSpace struct
|
||||
let funcspace_struct = get_function_spaces(&language, source, &path, None).unwrap();
|
||||
|
||||
|
@ -182,32 +174,15 @@ fn compare_f64(f1: f64, f2: &serde_json::Value) {
|
|||
}
|
||||
}
|
||||
|
||||
const OUTPUT_FOLDER: &str = "./tests/repositories/rca-output";
|
||||
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_branch: &str,
|
||||
repo_url: &str,
|
||||
repo_folder: &str,
|
||||
include: &[&str],
|
||||
) {
|
||||
// The first test clones the repository
|
||||
// Next tests wait here until the repository is cloned
|
||||
INIT.call_once(|| {
|
||||
clone_repository(
|
||||
"main",
|
||||
"https://github.com/SoftengPoliTo/rca-output.git",
|
||||
OUTPUT_FOLDER,
|
||||
);
|
||||
});
|
||||
|
||||
clone_repository(repo_branch, repo_url, repo_folder);
|
||||
|
||||
fn compare_rca_output_with_files(repo_name: &str, include: &[&str]) {
|
||||
let num_jobs = 4;
|
||||
|
||||
let cfg = Config {
|
||||
language: None,
|
||||
output_folder: OUTPUT_FOLDER.to_owned(),
|
||||
output_folder: REPO.join("rca-output"),
|
||||
};
|
||||
|
||||
let mut gsbi = GlobSetBuilder::new();
|
||||
|
@ -218,7 +193,7 @@ fn compare_rca_output_with_files(
|
|||
let files_data = FilesData {
|
||||
include: gsbi.build().unwrap(),
|
||||
exclude: GlobSet::empty(),
|
||||
paths: vec![Path::new(repo_folder).to_path_buf()],
|
||||
paths: vec![REPO.join(repo_name)],
|
||||
};
|
||||
|
||||
if let Err(e) = ConcurrentRunner::new(num_jobs, act_on_file).run(cfg, files_data) {
|
||||
|
@ -227,50 +202,17 @@ fn compare_rca_output_with_files(
|
|||
}
|
||||
}
|
||||
|
||||
/// Runs a git clone command
|
||||
fn clone_repository(branch: &str, url: &str, destination: &str) {
|
||||
if !Path::new(destination).exists() {
|
||||
Command::new("git")
|
||||
.args([
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"--branch",
|
||||
branch,
|
||||
url,
|
||||
destination,
|
||||
])
|
||||
.output()
|
||||
.expect("Git clone failed");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_deepspeech() {
|
||||
compare_rca_output_with_files(
|
||||
"v0.9.3",
|
||||
"https://github.com/mozilla/DeepSpeech.git",
|
||||
"./tests/repositories/DeepSpeech",
|
||||
&["*.cc", "*.cpp", "*.h", "*.hh"],
|
||||
);
|
||||
compare_rca_output_with_files("DeepSpeech", &["*.cc", "*.cpp", "*.h", "*.hh"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pdfjs() {
|
||||
compare_rca_output_with_files(
|
||||
"v2.12.313",
|
||||
"https://github.com/mozilla/pdf.js.git",
|
||||
"./tests/repositories/pdf.js",
|
||||
&["*.js"],
|
||||
);
|
||||
compare_rca_output_with_files("pdf.js", &["*.js"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rust_library() {
|
||||
compare_rca_output_with_files(
|
||||
"1.57.0",
|
||||
"https://github.com/rust-lang/rust.git",
|
||||
"./tests/repositories/rust",
|
||||
&["*/library/*.rs"],
|
||||
);
|
||||
compare_rca_output_with_files("rust", &["*/library/*.rs"]);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче