Skip to content

Commit

Permalink
Merge pull request #8 from JohnTitor/ctest2
Browse files Browse the repository at this point in the history
Rename to ctest2
  • Loading branch information
JohnTitor committed May 27, 2020
2 parents cc46e1a + cb03289 commit 1432332
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 60 deletions.
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
name = "ctest"
version = "0.2.22"
name = "ctest2"
version = "0.3.0"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>"
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
"Yuki Okushi <huyuumi.dev@gmail.com>"
]
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/gnzlbg/ctest"
homepage = "https://github.com/gnzlbg/ctest"
documentation = "https://docs.rs/ctest"
repository = "https://github.com/JohnTitor/ctest2"
homepage = "https://github.com/JohnTitor/ctest2"
documentation = "https://docs.rs/ctest2"
description = """
Automated tests of FFI bindings.
"""
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# ctest
# ctest2

[![Build Status](https://dev.azure.com/gonzalobg88/ctest/_apis/build/status/gnzlbg.ctest?branchName=master)](https://dev.azure.com/gonzalobg88/ctest/_build/latest?definitionId=5&branchName=master)
[Documentation][dox]

[dox]: https://docs.rs/ctest
[dox]: https://docs.rs/ctest2

**Note: This is a fork repository and we intend to use this in libc-test only.**

Automated testing of FFI bindings in Rust. This repository is intended to
validate the `*-sys` crates that can be found on crates.io to ensure that the
Expand All @@ -30,16 +31,16 @@ mylib-sys = { path = "../mylib-sys" }
libc = "0.2"

[build-dependencies]
ctest = "0.2"
ctest2 = "0.2"
```

Next, add a build script to `systest/build.rs`:

```rust
extern crate ctest;
extern crate ctest2;

fn main() {
let mut cfg = ctest::TestGenerator::new();
let mut cfg = ctest2::TestGenerator::new();

// Include the header files where the C APIs are defined
cfg.header("foo.h")
Expand Down Expand Up @@ -87,13 +88,9 @@ and returns information about the C side of things (which is validated in Rust).
A large amount of configuration can be applied to how the C file is generated,
you can browse [the documentation][dox].

### Projects using ctest
### Projects using ctest2

* [libc](https://github.com/rust-lang/libc)
* [git2-rs](https://github.com/rust-lang/git2-rs)
* [ssh2-rs](https://github.com/alexcrichton/ssh2-rs)
* [libz-sys](https://github.com/rust-lang/libz-sys)
* [openssl-sys](https://github.com/sfackler/rust-openssl)

### License

Expand All @@ -109,5 +106,5 @@ at your option.
### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in ctest by you, as defined in the Apache-2.0 license, shall be
for inclusion in ctest2 by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
4 changes: 2 additions & 2 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -ex

run() {
echo "Building docker container for TARGET=${1}"
docker build -t ctest -f ci/docker/$1/Dockerfile ci/
docker build -t ctest2 -f ci/docker/$1/Dockerfile ci/
mkdir -p target
target=$1
echo "Running docker"
Expand All @@ -21,7 +21,7 @@ run() {
--volume `pwd`/target:/checkout/target \
--workdir /checkout \
--privileged \
ctest \
ctest2 \
bash \
-c 'PATH=/rust/bin:$PATH exec ci/run.sh'
}
Expand Down
6 changes: 3 additions & 3 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ set -ex
mkdir -p target
rm -rf target/libc || true
git clone --depth=1 https://github.com/rust-lang/libc target/libc
mkdir -p target/libc/target/ctest
mkdir -p target/libc/target/ctest2

case $TARGET in
*linux*)
sed -i 's@ctest = "0.2"@ctest = { path = "../../.." }@g' target/libc/libc-test/Cargo.toml
sed -i 's@ctest2 = "0.2"@ctest2 = { path = "../../.." }@g' target/libc/libc-test/Cargo.toml
;;
*apple*)
sed -i '' 's@ctest = "0.2"@ctest = { path = "../../.." }@g' target/libc/libc-test/Cargo.toml
sed -i '' 's@ctest2 = "0.2"@ctest2 = { path = "../../.." }@g' target/libc/libc-test/Cargo.toml
;;
esac

Expand Down
54 changes: 27 additions & 27 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # ctest - an FFI binding validator
//! # ctest2 - an FFI binding validator
//!
//! This library is intended to be used as a build dependency in a separate
//! project from the main repo to generate tests which can be used to validate
Expand All @@ -7,7 +7,7 @@
//! For example usage, see the [main `README.md`][project] for how to set it
//! up.
//!
//! [project]: https://github.com/alexcrichton/ctest
//! [project]: https://github.com/alexcrichton/ctest2

#![deny(missing_docs)]
#![allow(bare_trait_objects)]
Expand Down Expand Up @@ -189,7 +189,7 @@ impl TestGenerator {
/// use std::env;
/// use std::path::PathBuf;
///
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.header("foo.h")
Expand All @@ -205,7 +205,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.rust_version(1, 0, 1);
Expand All @@ -226,7 +226,7 @@ impl TestGenerator {
/// use std::env;
/// use std::path::PathBuf;
///
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
Expand All @@ -245,7 +245,7 @@ impl TestGenerator {
/// use std::env;
/// use std::path::PathBuf;
///
/// use ctest::{TestGenerator, Lang};
/// use ctest2::{TestGenerator, Lang};
///
/// let mut cfg = TestGenerator::new();
/// cfg.language(Lang::CXX);
Expand All @@ -266,7 +266,7 @@ impl TestGenerator {
/// use std::env;
/// use std::path::PathBuf;
///
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
///
Expand All @@ -289,7 +289,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.out_dir("path/to/output");
Expand All @@ -307,7 +307,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.target("x86_64-unknown-linux-gnu");
Expand All @@ -325,7 +325,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.define("_GNU_SOURCE", None)
Expand Down Expand Up @@ -354,7 +354,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.cfg("foo", None) // cfg!(foo)
Expand Down Expand Up @@ -385,7 +385,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.type_name(|ty, is_struct, is_union| {
Expand Down Expand Up @@ -415,7 +415,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.field_name(|_s, field| {
Expand All @@ -437,7 +437,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::{TestGenerator, VolatileItemKind::StructField};
/// use ctest2::{TestGenerator, VolatileItemKind::StructField};
///
/// let mut cfg = TestGenerator::new();
/// cfg.volatile_item(|i| {
Expand All @@ -463,7 +463,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::{TestGenerator};
/// use ctest2::{TestGenerator};
///
/// let mut cfg = TestGenerator::new();
/// cfg.array_arg(|i, n| {
Expand All @@ -490,7 +490,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.const_cname(|c| {
Expand All @@ -515,7 +515,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_field(|s, field| {
Expand All @@ -540,7 +540,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_field_type(|s, field| {
Expand All @@ -565,7 +565,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_signededness(|s| {
Expand All @@ -591,7 +591,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_fn(|s| {
Expand All @@ -617,7 +617,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_static(|s| {
Expand Down Expand Up @@ -660,7 +660,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_const(|s| {
Expand All @@ -685,7 +685,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_type(|s| {
Expand All @@ -711,7 +711,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_struct(|s| {
Expand All @@ -738,7 +738,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.skip_roundtrip(|s| {
Expand All @@ -765,7 +765,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.fn_cname(|rust, link_name| link_name.unwrap_or(rust).to_string());
Expand Down Expand Up @@ -793,7 +793,7 @@ impl TestGenerator {
/// # Examples
///
/// ```no_run
/// use ctest::TestGenerator;
/// use ctest2::TestGenerator;
///
/// let mut cfg = TestGenerator::new();
/// cfg.generate("../path/to/libfoo-sys/lib.rs", "all.rs");
Expand Down
2 changes: 1 addition & 1 deletion testcrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Alex Crichton <alex@alexcrichton.com>"]
build = "build.rs"

[build-dependencies]
ctest = { path = ".." }
ctest2 = { path = ".." }
cc = "1.0"

[dependencies]
Expand Down

0 comments on commit 1432332

Please sign in to comment.