Skip to content

Commit

Permalink
Skip test if test data is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
oeb25 committed Feb 17, 2024
1 parent cc4c94c commit 5fbfb3c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
8 changes: 4 additions & 4 deletions crates/core/src/ranking/models/cross_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ mod tests {

#[test]
fn sanity_check() {
if !Path::new("../../data/cross_encoder").exists() {
let data_path = Path::new("../../data/cross_encoder");
if !data_path.exists() {
// Skip the test if the test data is not available
return;
}

let model = CrossEncoderModel::open("../../data/cross_encoder")
.expect("Failed to find cross-encoder model");
let model = CrossEncoderModel::open(data_path).expect("Failed to find cross-encoder model");

let s = model.run(
"how many people live in paris",
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/summarizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ mod tests {

#[test]
fn test_dual_encoder() {
if !Path::new("../../data/summarizer/dual_encoder").exists() {
let data_path = Path::new("../../data/summarizer/dual_encoder");
if !data_path.exists() {
// Skip the test if the test data is not available
return;
}

let model =
DualEncoder::open("../../data/summarizer/dual_encoder").expect("Failed to load model");
let model = DualEncoder::open(data_path).expect("Failed to load model");
let query = "What is the capital of France?";
let pos = "The capital of France is Paris.";
let neg = "The best baguette in Paris can be found at Boulangerie Pichard.";
Expand Down
9 changes: 4 additions & 5 deletions crates/core/src/warc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,16 +725,15 @@ mod tests {

#[test]
fn internet_archive_parse() {
if !Path::new("../../data/internet_archive.warc.gz").exists() {
let data_path = Path::new("../../data/internet_archive.warc.gz");
if !data_path.exists() {
// Skip the test if the test data is not available
return;
}

let mut records = 0;

for record in WarcFile::open("../../data/internet_archive.warc.gz")
.unwrap()
.records()
{
for record in WarcFile::open(data_path).unwrap().records() {
records += 1;
if let Err(err) = record {
panic!("Error: {:?}", err);
Expand Down
7 changes: 6 additions & 1 deletion crates/core/src/widgets/thesaurus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,12 @@ mod tests {

#[test]
fn build_dict() {
let dict = Dictionary::build("../../data/english-wordnet-2022-subset.ttl").unwrap();
let data_path = Path::new("../../data/english-wordnet-2022-subset.ttl");
if !data_path.exists() {
// Skip the test if the test data is not available
return;
}
let dict = Dictionary::build(data_path).unwrap();

let infos = dict.get(Lemma("barely".to_string()));

Expand Down
6 changes: 4 additions & 2 deletions crates/zimba/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,13 @@ mod tests {

#[test]
fn it_works() {
if !Path::new("../../data/test.zim").exists() {
let data_path = Path::new("../../data/test.zim");
if !data_path.exists() {
// Skip test if data file is not present
return;
}

let zim = ZimFile::open("../../data/test.zim").unwrap();
let zim = ZimFile::open(data_path).unwrap();

assert_eq!(zim.header.magic, 72173914);
assert_eq!(zim.header.major_version, 5);
Expand Down
16 changes: 14 additions & 2 deletions crates/zimba/src/wiki.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,18 @@ impl<'a> Iterator for ImageIterator<'a> {

#[cfg(test)]
mod tests {
use std::path::Path;

use super::*;

#[test]
fn test_article_iterator() {
let zim = ZimFile::open("../../data/test.zim").unwrap();
let data_path = Path::new("../../data/test.zim");
if !data_path.exists() {
// Skip the test if the test data is not available
return;
}
let zim = ZimFile::open(data_path).unwrap();
let mut iter = ArticleIterator::new(&zim).unwrap();

let article = iter.next().unwrap();
Expand All @@ -271,7 +278,12 @@ mod tests {

#[test]
fn test_image_iterator() {
let zim = ZimFile::open("../../data/test.zim").unwrap();
let data_path = Path::new("../../data/test.zim");
if data_path.exists() {
// Skip the test if the test data is not available
return;
}
let zim = ZimFile::open(data_path).unwrap();
let mut iter = ImageIterator::new(&zim).unwrap();

let image = iter.next().unwrap();
Expand Down

0 comments on commit 5fbfb3c

Please sign in to comment.