Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ sudo: required
language: rust
dist: xenial

env:
- CC=gcc

cache: cargo

addons:
apt:
packages:
- cmake
- g++
- gcc
- pkg-config
- jq
- libssl-dev
Expand Down
163 changes: 146 additions & 17 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name = "standard-benchmark"
version = "0.1.0"
authors = ["Michal Siedlaczek <michal.siedlaczek@nyu.edu>"]
edition = "2018"
build = "build.rs"

[lib]
name = "stdbench"
path = "src/lib.rs"

[dependencies]
clap = "2.24"
Expand All @@ -25,3 +27,9 @@ serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
url = "2.1"
url_serde = "0.2"
git2 = "0.10"

[build-dependencies]
cc = "1.0"
git2 = "0.10"
tempdir = "0.3"
51 changes: 51 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use git2::{ObjectType, Repository, ResetType};
use std::{env, path::PathBuf};

fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let url = "https://github.com/usnistgov/trec_eval";
let tmp = tempdir::TempDir::new("stdbench-build").expect("Unable to create a temp dir");
let repo_path = tmp.path().join("trec_eval");
let repo = match Repository::clone(url, &repo_path) {
Ok(repo) => repo,
Err(e) => panic!("failed to clone: {}", e),
};
let commit = repo
.resolve_reference_from_short_name("v8.1")
.expect("Cound not find tag v8.1")
.peel(ObjectType::Commit)
.expect("v8.1 is not a commit");
repo.reset(&commit, ResetType::Hard, None)
.expect("Failed checking out v8.1");
let mut cmd = cc::Build::new()
.include(&repo_path)
.no_default_flags(true)
.define("VERSIONID", r#""8.1""#)
.flag("-lm")
.warnings(false)
.opt_level(3)
.get_compiler()
.to_command();
cmd.args(
&[
"trec_eval.c",
"get_qrels.c",
"get_top.c",
"form_trvec.c",
"measures.c",
"print_meas.c",
"trvec_teval.c",
"buf_util.c",
"error_msgs.c",
"trec_eval_help.c",
]
.iter()
.map(|&f| repo_path.join(f))
.collect::<Vec<_>>(),
)
.arg("-o")
.arg(PathBuf::from(&out_dir).join("trec_eval"));
assert!(cmd.status().unwrap().success());
println!("cargo:libdir={}", &out_dir);
//panic!("{}", out_dir);
}
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use clap::{App, Arg};
use failure::ResultExt;
use log::{error, info, warn};
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs;
use std::process;
use std::{env, fs, process};
use stdbench::build;
use stdbench::config::{Collection, Config, Stage};
use stdbench::run::process_run;
Expand Down Expand Up @@ -198,7 +196,7 @@ mod test {

#[test]
fn test_parse_config_missing_file() {
std::env::set_var("RUST_LOG", "off");
env::set_var("RUST_LOG", "off");
assert!(parse_config(
["exe", "--config-file", "file"]
.into_iter()
Expand Down
46 changes: 9 additions & 37 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
};
use failure::ResultExt;
use itertools::iproduct;
use std::{fs, process::Command};
use std::{env, fs, iter, path::PathBuf, process::Command};

#[cfg_attr(tarpaulin, skip)]
fn queries_path(topics: &Topics, executor: &Executor) -> Result<String, Error> {
Expand Down Expand Up @@ -80,7 +80,15 @@ pub fn process_run(
let results_output = format!("{}.{}.results", base_path, algorithm);
let trec_eval_output = format!("{}.{}.trec_eval", base_path, algorithm);
std::fs::write(&results_output, &output)?;
let out_dir = PathBuf::from(env!("OUT_DIR"));
let paths: Vec<_> = iter::once(out_dir)
.chain(env::split_paths(&env::var("PATH").unwrap()))
.collect();
let output = Command::new("trec_eval")
.env(
"PATH",
env::join_paths(&paths).expect("Failed to join PATHs"),
)
.arg("-q")
.arg("-a")
.arg(qrels.to_str().unwrap())
Expand All @@ -106,7 +114,6 @@ mod tests {
use super::*;
use crate::tests::{mock_program, mock_set_up, EchoMode, EchoOutput, MockSetup};
use crate::Error;
use std::path;
use tempdir::TempDir;

#[test]
Expand Down Expand Up @@ -178,41 +185,6 @@ mod tests {
tmp.path().join("topics").display(),
)
);
let trec_eval = programs.get("trec_eval").unwrap().to_str().unwrap();
let qrels = tmp
.path()
.join("qrels")
.into_os_string()
.into_string()
.unwrap();
let run = config.runs[1].output.to_str().unwrap().to_string();
// TODO: Revisit when #5 addressed
// assert_eq!(
// EchoOutput::from(
// path::PathBuf::from(format!(
// "{}.wand.trec_eval",
// config.runs[1].output.display()
// ))
// .as_path()
// ),
// EchoOutput::from(format!(
// "{} -q -a {} {}.wand.results",
// &trec_eval, &qrels, &run
// )),
// );
// assert_eq!(
// EchoOutput::from(
// path::PathBuf::from(format!(
// "{}.maxscore.trec_eval",
// config.runs[1].output.display()
// ))
// .as_path()
// ),
// EchoOutput::from(format!(
// "{} -q -a {} {}.maxscore.results",
// &trec_eval, &qrels, &run
// )),
// );
}

#[test]
Expand Down