Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Add tests based on ctest #124

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5ae26cd
Add tests for glib-sys based on ctest
tmiasko Dec 16, 2018
2514eb6
Use pkg-config to obtain compilation flags
tmiasko Dec 16, 2018
d962e8c
Add tests for gobject-sys based on ctest
tmiasko Dec 16, 2018
92abb5f
Add tests for gio-sys based on ctest
tmiasko Dec 16, 2018
90e3cd6
Add tests for gdk-sys based on ctest
tmiasko Dec 16, 2018
4d73cbd
Add makefile check target that runs system tests
tmiasko Dec 16, 2018
4b38ed8
Skip gio-unix-2.0 and types therein when testing on Windows
tmiasko Dec 17, 2018
23adac7
Skip glib-unix.h and types therein when testing on Windows
tmiasko Dec 17, 2018
390c2c3
Update list of incomplete types used in ctest
tmiasko Dec 17, 2018
da0ccdf
Add tests for gtk-sys based on ctest
tmiasko Dec 17, 2018
2febdae
Add tests for pango-sys based on ctest
tmiasko Dec 17, 2018
4c8b33f
xlib::Window has unsigned long type
tmiasko Dec 17, 2018
1408316
Add tests for gtk-pixbuf-sys based on ctest
tmiasko Dec 17, 2018
e3a76ea
Skip X11 headers and types on Windows
tmiasko Dec 18, 2018
94293da
Add tests for atk-sys based on ctest
tmiasko Dec 18, 2018
6115f47
Add tests for pangocairo-sys based on ctest
tmiasko Dec 18, 2018
7e4bbfa
Add workspace
tmiasko Dec 18, 2018
fc4a8e1
Enable a few more tests in atk, gdk-pixbuf and gdk.
tmiasko Dec 19, 2018
d8d9b68
Automatically determine and ignore incomplete types
tmiasko Dec 19, 2018
2d1762e
Enable remaining constant tests
tmiasko Dec 21, 2018
8625037
Repalce unwrap with expect when using flags from pkg-config
tmiasko Dec 21, 2018
e1726d1
Run rustfmt on sys tests
tmiasko Dec 21, 2018
711f695
Remove empty newlines in Cargo.toml for sys tests
tmiasko Dec 21, 2018
c4d43c4
Use https://github.com/gtk-rs/gir-ctest
tmiasko Dec 21, 2018
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: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ script:
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ "$GTK" == "3.4" ]; then
make regen_check;
fi
- mkdir .cargo
- echo 'paths = ["."]' > .cargo/config
- git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples
- cd _examples
- mkdir .cargo
- echo 'paths = [".."]' > .cargo/config
- ./build_travis.sh
25 changes: 25 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[workspace]
members = [
"atk-sys",
"atk-sys-test",
"gdk-pixbuf-sys",
"gdk-pixbuf-sys-test",
"gdk-sys",
"gdk-sys-test",
"gio-sys",
"gio-sys-test",
"glib-sys",
"glib-sys-test",
"gobject-sys",
"gobject-sys-test",
"gtk-sys",
"gtk-sys-test",
"pango-sys",
"pango-sys-test",
"pangocairo-sys",
"pangocairo-sys-test"
]
exclude = [
"_examples",
"gir"
]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GIR_FILES = $(shell ls $(CONFIGS) | xargs -n1 perl -ne '$$name = $$1 if /^librar
LIBS = $(CONFIGS:conf/gir-%.toml=%-sys/src/lib.rs)
TEST_C_FILES = $(CONFIGS:conf/gir-%.toml=%-sys/tests/*.c)
TEST_RS_FILES = $(CONFIGS:conf/gir-%.toml=%-sys/tests/*.rs)
TEST_CRATES = $(wildcard *-sys-test)

libs : $(LIBS)

Expand All @@ -25,3 +26,8 @@ regen_check: $(GIR) $(GIR_FILES)
rm -f $(TEST_RS_FILES)
@$(MAKE) -f $(THIS_FILE) libs
git diff -R --exit-code

check:
for crate in $(TEST_CRATES); do \
cargo run -p $$crate; \
done
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ install:
- pacman --noconfirm -S mingw-w64-%ARCH%-gtk3

build_script:
- mkdir .cargo
- echo paths = ["."] > .cargo\config
- git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples
- cd _examples
- mkdir .cargo
- echo paths = [".."] > .cargo\config
- cargo build
- cargo build --features gtk_3_18

Expand Down
15 changes: 15 additions & 0 deletions atk-sys-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "atk-sys-test"
version = "0.1.0"
authors = ["Tomasz Miąsko <[email protected]>"]
edition = "2018"
build = "build.rs"

[dependencies]
atk-sys = { path = "../atk-sys" }
libc = "0.2"

[build-dependencies]
ctest = { git = "https://github.com/tmiasko/gir-ctest", branch = "master" }
shell-words = "0.1.0"

60 changes: 60 additions & 0 deletions atk-sys-test/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
extern crate ctest;
extern crate shell_words;

fn pkg_config_cflags() -> Result<Vec<String>, Box<std::error::Error>> {
let mut cmd = std::process::Command::new("pkg-config");
cmd.arg("--cflags");
cmd.arg("atk");
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}",
&cmd, out.status).into());
}
let stdout = std::str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
This conversation was marked as resolved.
Show resolved Hide resolved
}

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

for flag in pkg_config_cflags().unwrap() {
This conversation was marked as resolved.
Show resolved Hide resolved
cfg.flag(&flag);
}

cfg.header("atk/atk.h");

cfg.skip_fn(|_| true);
cfg.skip_signededness(|_| true);

cfg.type_name(|ty, _is_struct, _is_union| {
// Use Foo, instead of struct Foo, etc.
ty.to_string()
});

cfg.field_name(|_typ, field| match field {
// Restore original field names:
"type_" => "type",
_ => field,
}.to_string());

cfg.skip_field_type(|typ, field| match (typ, field) {
// FIXME in gir generator: int vs int**
("AtkTableIface", "get_column_at_index") => true,
("AtkTableIface", "get_row_at_index") => true,

// FIXME: void* / void**
("AtkObjectClass", "initialize") => true,

_ => false,
});

cfg.skip_struct(|typ| match typ {
// Interface was changed upstream
"AtkComponentIface" => true,

_ => false,
});

cfg.generate("../atk-sys/src/lib.rs", "all.rs");
}

This conversation was marked as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions atk-sys-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![allow(bad_style)]

extern crate atk_sys;
extern crate libc;

use atk_sys::*;

include!(concat!(env!("OUT_DIR"), "/all.rs"));

This conversation was marked as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions conf/gir-glib.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ignore = [
"GLib.HAVE_GNUC_VISIBILITY",
"GLib.HAVE_GROWING_STACK",
"GLib.HAVE_ISO_VARARGS",
"GLib.LOG_DOMAIN",
"GLib.MAJOR_VERSION",
"GLib.MAXINT8",
"GLib.MAXINT16",
Expand Down
15 changes: 15 additions & 0 deletions gdk-pixbuf-sys-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "gdk-pixbuf-sys-test"
version = "0.1.0"
authors = ["Tomasz Miąsko <[email protected]>"]
edition = "2018"
build = "build.rs"

[dependencies]
gdk-pixbuf-sys = { path = "../gdk-pixbuf-sys" }
libc = "0.2"

[build-dependencies]
ctest = { git = "https://github.com/tmiasko/gir-ctest", branch = "master" }
shell-words = "0.1.0"

This conversation was marked as resolved.
Show resolved Hide resolved
50 changes: 50 additions & 0 deletions gdk-pixbuf-sys-test/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
extern crate ctest;
extern crate shell_words;

fn pkg_config_cflags() -> Result<Vec<String>, Box<std::error::Error>> {
let mut cmd = std::process::Command::new("pkg-config");
cmd.arg("--cflags");
cmd.arg("gdk-pixbuf-2.0");
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}",
&cmd, out.status).into());
}
let stdout = std::str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
}

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

for flag in pkg_config_cflags().unwrap() {
cfg.flag(&flag);
}

cfg.header("gdk-pixbuf/gdk-pixbuf.h");
cfg.header("gdk-pixbuf/gdk-pixdata.h");

cfg.skip_fn(|_| true);
cfg.skip_signededness(|_| true);

cfg.type_name(|ty, _is_struct, _is_union| {
// Use Foo, instead of struct Foo, etc.
ty.to_string()
});

cfg.field_name(|_typ, field| match field {
// Restore original field names:
"priv_" => "priv",
_ => field,
}.to_string());

cfg.skip_struct(|typ| match typ {
// Not part of public headers ...
"GdkPixbufSimpleAnimIter" => true,

_ => false,
});

cfg.generate("../gdk-pixbuf-sys/src/lib.rs", "all.rs");
}

10 changes: 10 additions & 0 deletions gdk-pixbuf-sys-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![allow(bad_style)]

extern crate gdk_pixbuf_sys;
extern crate libc;

use gdk_pixbuf_sys::*;
use libc::*;

include!(concat!(env!("OUT_DIR"), "/all.rs"));

This conversation was marked as resolved.
Show resolved Hide resolved
16 changes: 16 additions & 0 deletions gdk-sys-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "gdk-sys-test"
version = "0.1.0"
authors = ["Tomasz Miąsko <[email protected]>"]
edition = "2018"
build = "build.rs"

[dependencies]
glib-sys = { path = "../glib-sys" }
gdk-sys = { path = "../gdk-sys" }
libc = "0.2"

[build-dependencies]
ctest = { git = "https://github.com/tmiasko/gir-ctest", branch = "master" }
shell-words = "0.1.0"

This conversation was marked as resolved.
Show resolved Hide resolved
51 changes: 51 additions & 0 deletions gdk-sys-test/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
extern crate ctest;
extern crate shell_words;

fn pkg_config_cflags() -> Result<Vec<String>, Box<std::error::Error>> {
let mut cmd = std::process::Command::new("pkg-config");
cmd.arg("--cflags");
cmd.arg("gdk-3.0");
let out = cmd.output()?;
if !out.status.success() {
return Err(format!("command {:?} returned {}",
&cmd, out.status).into());
}
let stdout = std::str::from_utf8(&out.stdout)?;
Ok(shell_words::split(stdout.trim())?)
}

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

for flag in pkg_config_cflags().unwrap() {
cfg.flag(&flag);
}

cfg.header("gdk/gdk.h");

cfg.skip_fn(|_| true);
cfg.skip_signededness(|_| true);

cfg.type_name(|ty, _is_struct, _is_union| {
// Use Foo, instead of struct Foo, etc.
ty.to_string()
});

cfg.field_name(|_typ, field| match field {
// Restore original field names:
"in_" => "in",
"type_" => "type",
_ => field,
}.to_string());

cfg.skip_field(|typ,field| match (typ, field) {
// Bit fields:
("GdkEventKey", "is_modifier") => true,
("GdkEventScroll", "is_stop") => true,

_ => false,
});

cfg.generate("../gdk-sys/src/lib.rs", "all.rs");
}

12 changes: 12 additions & 0 deletions gdk-sys-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![allow(bad_style)]

extern crate gdk_sys;
extern crate glib_sys;
extern crate libc;

use gdk_sys::*;
use glib_sys::gboolean;
use libc::*;

include!(concat!(env!("OUT_DIR"), "/all.rs"));

This conversation was marked as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions gio-sys-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "gio-sys-test"
version = "0.1.0"
authors = ["Tomasz Miąsko <[email protected]>"]
edition = "2018"
build = "build.rs"

[dependencies]
gio-sys = { path = "../gio-sys" }
libc = "0.2"

[build-dependencies]
ctest = { git = "https://github.com/tmiasko/gir-ctest", branch = "master" }
shell-words = "0.1.0"

This conversation was marked as resolved.
Show resolved Hide resolved
Loading