Skip to content

Commit

Permalink
Fix some ci/cd and clippy problems
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
  • Loading branch information
Arjentix committed Apr 21, 2022
1 parent 62d9d17 commit c9a126d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/iroha2-dev-pr-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- name: Format check
run: cargo +nightly-2022-04-20 fmt --all -- --check
- name: Static analysis without features
run: cargo lints clippy --workspace --benches --tests --examples --quiet --no-default-features
run: cargo +nightly-2022-04-20 lints clippy --workspace --benches --tests --examples --quiet --no-default-features
if: always()
- name: Static analysis with all features enabled
run: cargo lints clippy --workspace --benches --tests --examples --quiet --all-features
run: cargo +nightly-2022-04-20 lints clippy --workspace --benches --tests --examples --quiet --all-features
if: always()
- name: Verify iroha_data_model still supports no_std
run: cargo nono check --package iroha_data_model --no-default-features
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RUN git clone https://github.com/rui314/mold.git; \
RUN rustup component add llvm-tools-preview clippy; \
rustup target add wasm32-unknown-unknown; \
rustup install --profile default nightly-2022-04-20; \
rustup component add rust-src --toolchain nightly-2022-04-20-x86_64-unknown-linux-gnu; \
cargo install cargo-lints cargo-nono webassembly-test-runner grcov

RUN curl -fsSL https://get.docker.com -o get-docker.sh; \
Expand Down
10 changes: 9 additions & 1 deletion wasm/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ use super::*;

/// Print `obj` in debug representation to the stdout
pub fn dbg<T: Debug + ?Sized>(obj: &T) {
#[cfg(not(test))]
use host::dbg as host_dbg;
#[cfg(test)]
use tests::_dbg as host_dbg;

let s = format!("{:?}", obj);
unsafe { encode_and_execute(&s, host::dbg) }
// Safety: `host_dbg` doesn't take ownership of it's pointer parameter
unsafe { encode_and_execute(&s, host_dbg) }
}

/// Extension implemented for `Result` and `Option` to provide unwrapping with error message,
Expand All @@ -20,6 +26,7 @@ pub trait DebugUnwrapExt {
impl<T, E: Debug> DebugUnwrapExt for Result<T, E> {
type Output = T;

#[allow(clippy::panic)]
fn dbg_unwrap(self) -> Self::Output {
match self {
Ok(out) => out,
Expand All @@ -36,6 +43,7 @@ impl<T, E: Debug> DebugUnwrapExt for Result<T, E> {
impl<T> DebugUnwrapExt for Option<T> {
type Output = T;

#[allow(clippy::panic)]
fn dbg_unwrap(self) -> Self::Output {
match self {
Some(out) => out,
Expand Down
9 changes: 9 additions & 0 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ mod host {

/// Prints string to the standard output by providing offset and length
/// into WebAssembly's linear memory where string is stored
///
/// # Warning
///
/// This function doesn't take ownership of the provided allocation
/// but it does transfer ownership of the result to the caller
#[cfg(feature = "debug")]
pub(super) fn dbg(ptr: WasmUsize, len: WasmUsize);
}
Expand Down Expand Up @@ -276,6 +281,10 @@ mod tests {
assert_eq!(get_test_instruction(), instruction.unwrap());
}

#[cfg(feature = "debug")]
#[no_mangle]
pub(super) unsafe extern "C" fn _dbg(_ptr: WasmUsize, _len: WasmUsize) {}

#[no_mangle]
pub(super) unsafe extern "C" fn _iroha_wasm_execute_query_mock(
ptr: WasmUsize,
Expand Down

0 comments on commit c9a126d

Please sign in to comment.