Skip to content

Commit 61c8dc6

Browse files
bors[bot]Bromeon
andauthored
Merge #109
109: Address sanitizers in integration tests r=Bromeon a=Bromeon Also makes clippy more strict and fixes doctests on `master`. Integration tests with address sanitizers currently support two setups (gcc + clang), and are allowed to fail until some of the underlying issues like #89 are fixed. Unless the two variants report different findings, we may reduce CI to use only one of the two memory checkers in the future. Co-authored-by: Jan Haller <[email protected]>
2 parents 6b44f16 + 93b8201 commit 61c8dc6

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

.github/workflows/full-ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- trying
1515

1616
env:
17-
GDEXT_FEATURES: 'godot-core/convenience'
17+
GDEXT_FEATURES: '--features godot-core/convenience'
1818
# GDEXT_CRATE_ARGS: '-p godot-codegen -p godot-ffi -p godot-core -p godot-macros -p godot'
1919

2020
defaults:
@@ -59,7 +59,9 @@ jobs:
5959
binary-filename: godot.linuxbsd.editor.dev.x86_64
6060

6161
- name: "Check clippy"
62-
run: cargo clippy -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
62+
run: |
63+
cargo clippy --all-targets $GDEXT_FEATURES -- -D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf \
64+
-D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings
6365
6466
6567
unit-test:
@@ -126,7 +128,7 @@ jobs:
126128
binary-filename: ${{ matrix.godot-binary }}
127129

128130
- name: "Compile tests"
129-
run: cargo test --no-run
131+
run: cargo test $GDEXT_FEATURES --no-run
130132

131133
- name: "Test"
132134
run: cargo test $GDEXT_FEATURES
@@ -135,7 +137,8 @@ jobs:
135137
godot-itest:
136138
name: godot-itest (${{ matrix.name }})
137139
runs-on: ${{ matrix.os }}
138-
continue-on-error: false
140+
# TODO: continue-on-error: false, as soon as memory errors are fixed
141+
continue-on-error: ${{ contains(matrix.name, 'memcheck') }}
139142
timeout-minutes: 24
140143
strategy:
141144
fail-fast: false # cancel all jobs as soon as one fails?
@@ -161,6 +164,16 @@ jobs:
161164
rust-toolchain: stable
162165
godot-binary: godot.linuxbsd.editor.dev.x86_64
163166

167+
- name: linux-memcheck-gcc
168+
os: ubuntu-20.04
169+
rust-toolchain: stable
170+
godot-binary: godot.linuxbsd.editor.dev.x86_64.san
171+
172+
- name: linux-memcheck-clang
173+
os: ubuntu-20.04
174+
rust-toolchain: stable
175+
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
176+
164177
steps:
165178
- uses: actions/checkout@v3
166179

.github/workflows/minimal-ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- master
1515

1616
env:
17-
GDEXT_FEATURES: 'godot-core/convenience'
17+
GDEXT_FEATURES: '--features godot-core/convenience'
1818
# GDEXT_CRATE_ARGS: '-p godot-codegen -p godot-ffi -p godot-core -p godot-macros -p godot'
1919

2020
defaults:
@@ -59,7 +59,9 @@ jobs:
5959
binary-filename: godot.linuxbsd.editor.dev.x86_64
6060

6161
- name: "Check clippy"
62-
run: cargo clippy -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
62+
run: |
63+
cargo clippy --all-targets $GDEXT_FEATURES -- -D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf \
64+
-D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings
6365
6466
6567
unit-test:

check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ for arg in "${args[@]}"; do
7676
cmds+=("cargo fmt --all -- --check")
7777
;;
7878
clippy)
79-
cmds+=("cargo clippy $features -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings")
79+
cmds+=("cargo clippy $features -- -D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings")
8080
;;
8181
test)
8282
cmds+=("cargo test $features")

godot-core/src/builtin/dictionary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ impl Share for Dictionary {
328328
///
329329
/// Example
330330
/// ```no_run
331-
/// use godot::builtin::dict;
331+
/// use godot::builtin::{dict, Variant};
332332
///
333333
/// let key = "my_key";
334334
/// let d = dict! {
335335
/// "key1": 10,
336336
/// "another": Variant::nil(),
337337
/// key: true,
338338
/// (1 + 2): "final",
339-
/// }
339+
/// };
340340
/// ```
341341
#[macro_export]
342342
macro_rules! dict {

godot-ffi/src/godot_ffi.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ use crate as sys;
88
use std::fmt::Debug;
99

1010
/// Adds methods to convert from and to Godot FFI pointers.
11-
#[doc(hidden)]
11+
/// See [crate::ffi_methods] for ergonomic implementation.
1212
pub trait GodotFfi {
1313
/// Construct from Godot opaque pointer.
14+
///
15+
/// # Safety
16+
/// `ptr` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
17+
/// which is different depending on the type.
1418
unsafe fn from_sys(ptr: sys::GDExtensionTypePtr) -> Self;
1519

16-
/// Construct uninitialized opaque data, then initialize it with `init` function.
20+
/// Construct uninitialized opaque data, then initialize it with `init_fn` function.
21+
///
22+
/// # Safety
23+
/// `init_fn` must be a function that correctly handles a (possibly-uninitialized) _type ptr_.
1724
unsafe fn from_sys_init(init_fn: impl FnOnce(sys::GDExtensionTypePtr)) -> Self;
1825

1926
/// Return Godot opaque pointer, for an immutable operation.
@@ -38,6 +45,11 @@ pub trait GodotFfi {
3845
self.sys()
3946
}
4047

48+
/// Write the contents of `self` into the pointer `dst`.
49+
///
50+
/// # Safety
51+
/// `dst` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
52+
/// which is different depending on the type.
4153
unsafe fn write_sys(&self, dst: sys::GDExtensionTypePtr);
4254
}
4355

@@ -66,6 +78,7 @@ pub trait GodotFuncMarshal: Sized {
6678
// See doc comment of `ffi_methods!` for information
6779

6880
#[macro_export]
81+
#[doc(hidden)]
6982
macro_rules! ffi_methods_one {
7083
// type $Ptr = *mut Opaque
7184
(OpaquePtr $Ptr:ty; $( #[$attr:meta] )? $vis:vis $from_sys:ident = from_sys) => {
@@ -159,6 +172,7 @@ macro_rules! ffi_methods_one {
159172
}
160173

161174
#[macro_export]
175+
#[doc(hidden)]
162176
macro_rules! ffi_methods_rest {
163177
( // impl T: each method has a custom name and is annotated with 'pub'
164178
$Impl:ident $Ptr:ty; $( fn $user_fn:ident = $sys_fn:ident; )*

godot/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub use godot_core::private;
9999
/// Often-imported symbols.
100100
pub mod prelude {
101101
pub use super::bind::{godot_api, GodotClass, GodotExt};
102+
pub use super::builtin::dict; // Re-export macros.
102103
pub use super::builtin::*;
103104
pub use super::engine::{
104105
load, try_load, utilities, AudioStreamPlayer, Camera2D, Camera3D, Input, Node, Node2D,

0 commit comments

Comments
 (0)