simplify defining suites
This commit is contained in:
@@ -26,7 +26,5 @@ Keep the `RUN_TEST`s in the same order as the functions they call.
|
|||||||
|
|
||||||
To add a suite,
|
To add a suite,
|
||||||
|
|
||||||
1. Add a new C file in `integration-tests/src/bindings_tests/`.
|
1. Add a new C file in `integration-tests/src/bindings_tests/`, based off of one of hte others.
|
||||||
1. Add a new `.file(..)` to build that file in `integration-tests/build.rs`.
|
1. Add a the suite name to `suites` in `integration-tests/build.rs`.
|
||||||
1. Add a `suite!(..)` to `integration-tests/src/bindings_tests/mod.rs`.
|
|
||||||
1. Add a `suite!(..)` to `integration-tests/tests/bindings.rs`.
|
|
||||||
|
|||||||
@@ -1,36 +1,50 @@
|
|||||||
fn main() {
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
fn build_libtaskchampion(suites: &[&'static str]) {
|
||||||
// This crate has taskchampion-lib in its build-dependencies, so
|
// This crate has taskchampion-lib in its build-dependencies, so
|
||||||
// libtaskchampion.so should be built already. Hopefully it's in target/$PROFILE, and hopefully
|
// libtaskchampion.so should be built already. Hopefully it's in target/$PROFILE, and hopefully
|
||||||
// it's named libtaskchampion.so and not something else
|
// it's named libtaskchampion.so and not something else
|
||||||
let mut libtaskchampion = std::env::current_dir().unwrap();
|
let mut libtaskchampion = env::current_dir().unwrap();
|
||||||
libtaskchampion.pop();
|
libtaskchampion.pop();
|
||||||
libtaskchampion.push("target");
|
libtaskchampion.push("target");
|
||||||
libtaskchampion.push(std::env::var("PROFILE").unwrap());
|
libtaskchampion.push(env::var("PROFILE").unwrap());
|
||||||
libtaskchampion.push("deps");
|
libtaskchampion.push("deps");
|
||||||
libtaskchampion.push("libtaskchampion.so");
|
libtaskchampion.push("libtaskchampion.so");
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
|
||||||
|
|
||||||
let mut build = cc::Build::new();
|
let mut build = cc::Build::new();
|
||||||
build.object(libtaskchampion);
|
build.object(libtaskchampion);
|
||||||
build.include("../lib");
|
build.include("../lib");
|
||||||
build.include("src/bindings_tests/unity");
|
build.include("src/bindings_tests/unity");
|
||||||
build.file("src/bindings_tests/unity/unity.c");
|
build.file("src/bindings_tests/unity/unity.c");
|
||||||
|
|
||||||
let files = &[
|
let mut files = vec!["src/bindings_tests/test.c".to_string()];
|
||||||
"src/bindings_tests/test.c",
|
for suite in suites {
|
||||||
// keep this list in sync with integration-tests/src/bindings_tests/mod.rs and
|
files.push(format!("src/bindings_tests/{}.c", suite));
|
||||||
// integration-tests/tests/bindings.rs
|
}
|
||||||
"src/bindings_tests/uuid.c",
|
|
||||||
"src/bindings_tests/string.c",
|
|
||||||
"src/bindings_tests/task.c",
|
|
||||||
"src/bindings_tests/replica.c",
|
|
||||||
];
|
|
||||||
|
|
||||||
for file in files {
|
for file in files {
|
||||||
build.file(file);
|
build.file(&file);
|
||||||
println!("cargo:rerun-if-changed={}", file);
|
println!("cargo:rerun-if-changed={}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
build.compile("bindings-tests");
|
build.compile("bindings-tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn make_suite_file(suites: &[&'static str]) {
|
||||||
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
let dest_path = Path::new(&out_dir).join("bindings_test_suites.rs");
|
||||||
|
let mut content = String::new();
|
||||||
|
for suite in suites {
|
||||||
|
content.push_str(format!("suite!({}_tests);\n", suite).as_ref());
|
||||||
|
}
|
||||||
|
fs::write(&dest_path, content).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
|
let suites = &["uuid", "string", "task", "replica"];
|
||||||
|
build_libtaskchampion(suites);
|
||||||
|
make_suite_file(suites);
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,8 +13,4 @@ macro_rules! suite(
|
|||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
// keep this list in sync with integration-tests/build.rs and integration-tests/tests/bindings.rs.
|
include!(concat!(env!("OUT_DIR"), "/bindings_test_suites.rs"));
|
||||||
suite!(uuid_tests);
|
|
||||||
suite!(string_tests);
|
|
||||||
suite!(task_tests);
|
|
||||||
suite!(replica_tests);
|
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ macro_rules! suite(
|
|||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
// keep this list in sync with integration-tests/build.rs and
|
include!(concat!(env!("OUT_DIR"), "/bindings_test_suites.rs"));
|
||||||
// integration-tests/src/bindings_tests/mod.rs
|
|
||||||
suite!(uuid_tests);
|
|
||||||
suite!(string_tests);
|
|
||||||
suite!(task_tests);
|
|
||||||
suite!(replica_tests);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user