~matthiasbeyer/imag

ref: 48ba74e3e11b72d032494ad62fc03b1066fa8d9a imag/lib/core/libimagrt/src/runtime.rs -rw-r--r-- 24.3 KiB
Merge branch 'fix-clippy'

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Replace redundant closure with function pointer

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'blackhole-stdout-when-piping' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Add blackhole as default cli option

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'replace-failure-with-anyhow'

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Replace failure with anyhow in complete codebase

This patch was scripted with

    sed -i 's/use failure::Error/use anyhow::Error/' $(rg "use failure::Error" -l)
    sed -i 's/use failure::Fallible as /use anyhow::/' $(rg "use failure::Fallible" -l)
    sed -i 's/failure/anyhow/' $(rg "failure *=" -l)
    sed -i 's/format_err!/anyhow!/' $(rg "format_err!" -l)
    sed -i 's/use failure::ResultExt/use anyhow::Context/' $(rg "use failure::ResultExt" -l)
    sed -i 's/err_msg/anyhow!/' $(rg "use failure::err_msg" -l)
    sed -i 's/^anyhow\ *=.*$/anyhow = "1"/' $(rg "anyhow * =" -l)
    sed -i 's/^anyhow_derive.*//' $(rg "anyhow_derive" -l)
    sed -i 's/extern crate failure/extern crate anyhow/' $(rg "extern crate failure" -l)
    sed -i 's/.*extern crate anyhow_derive.*//' $(rg "anyhow_derive" -l)

Some manual changes were added as well, so this patch was not completely
scripted, but mostly.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'rt-reporting-iterator' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Add iterator extension for reporting from iterator

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'runtime-more-io-control' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Allow more fine-granular control over IO behaviour in runtime

This patch removes the --ignore-ids option and adds --pipe-input / -I and
--pipe-output / -O instead.

The behaviour of -IO is the same as --ignore-ids was before, but this
change gives the user the option to enable only one of both (input or
output, or both).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Update copyright years to 2015-2020

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'replace-map-dbg-err' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Remove DebugResult and DebugOption helpers

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Replace map_dbg() and map_dbg_str() with context() and inspect() calls

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Merge branch 'report-ids-ignore-broken-pipe' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Fix: Ignore broken pipe when reporting ids

This fixes a bug where a broken pipe in Runtime::report_touched()
resulted in an Err(_) raised up to main() which then reported this.

But as report_touched() should ignore a broken pipe (because the program
will exit anyways shortly after the call), we can safely ignore this
error.

This also results in `ExitCode` removed from the function signature,
which pushes us forward to the removal of custom error-handling
implementations!

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Add Runtime::input_is_pipe()

We need this because we might want to check whether we can get the STDIN
handle from the runtime or not.
In some (rare) cases, the runtime "thinks" that STDIN is a stream of
IDs, but it is not. So the client can check whether stdin is a pipe
(thus, whether Runtime thinks that there's a stream of IDs) and easily
work around that by taking ::std::io::stdin() itself.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Fix: --override-config argument can be passed multiple times

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Pull changes from https://github.com/flip1995/imag clippy_fix

This pulls in the clippy fixes from Phil. From the request-pull:

-----8<-----
    I finally got to fixing all of the Clippy warnings in the imag codebase.
    `cargo test` passes, `cargo clippy` doesn't produce any warnings
    or errors.

    Some important notes:
      - I didn't pay attention to the line length of the changes, so it may
        have happened that some lines are now longer than 100 chars
      - Except two commits the commit messages are formatted as follows:
        * The first tag shows if the changes in the commit were
          automatically applied by `cargo fix --clippy -Zunstable-options`.
          Commits that were automatically applied may require closer review,
          since I didn't check those by hand and the Clippy fix feature is
          still unstable.
        * The other tags specify the subcrate that is affected by the
          commit. I created one commit for each subcrate, even when only one
          file (most of the time the `main.rs` file) was changed.
      - I created one commit, where I replace usages of `r#try!` with the
        `?` operator, since `try!` is now officially deprecated.
      - I created one commit, where I just allow Clippy lints. Either because
        the fix would require much more work or knowledge of the codebase or
        because it was a FP.

    This was pretty much work, but it helped detecting a few bugs in Clippy,
    where I was already able to open 3 or 4 PRs. So win-win I guess.

    [...] we got a net LoC decrease.
----->8-----
[No-auto] lib/core/rt: Fix Clippy warnings

Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
[Auto] lib/core/rt: Fix Clippy warnings

Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Next