#marker #lint

marker_uitest

A thin wrapper around the ui_test crate for Marker

12 releases (5 breaking)

0.5.0 Dec 28, 2023
0.4.3 Dec 2, 2023
0.4.2 Nov 25, 2023
0.3.0 Oct 5, 2023
0.0.0-placeholder Nov 4, 2022

#36 in Configuration

Download history 2620/week @ 2023-11-06 1776/week @ 2023-11-13 2893/week @ 2023-11-20 2261/week @ 2023-11-27 1972/week @ 2023-12-04 1123/week @ 2023-12-11 3119/week @ 2023-12-18 740/week @ 2023-12-25 2058/week @ 2024-01-01 1789/week @ 2024-01-08 3019/week @ 2024-01-15 2710/week @ 2024-01-22 1608/week @ 2024-01-29 1179/week @ 2024-02-05 2210/week @ 2024-02-12 2028/week @ 2024-02-19

7,085 downloads per month

MIT/Apache

14KB
217 lines

Marker UI-test

Crates.io License: MIT OR Apache-2.0

The easiest way to test lints, is simply to run them on examples and look at the generated output. We are programmers, which means that we have tools to automate this process. marker_uitest is a thin wrapper around the ui_test crate for Marker. It performs all the common setup magic required to run ui-tests.

Prerequisites

marker_uitest requires Cargo, rustup and cargo_marker to be installed.

Usage

The ui_test crate runs Marker on every .rs-file in the tests/ui folder and compares the output with the .stderr and .stdout files next to them. To automatically update the .stderr and .stdout files, you can either run cargo test -- -- --bless or set the RUST_BLESS environment variable.

For a full list of supported features and magic comments, please refer to the documentation of the ui_test crate.

Setup

Manifest

First add marker_utils to the dev-dependencies of the lint crate, and specify that the ui-test doesn't require a test harness, like this:

[dev-dependencies]
marker_uitest = "0.5.0"

[[test]]
name = "uitest"
harness = false

Setup test file

Create a uitest.rs file in the tests directory. Then you can use the following template to get started:

use marker_uitest::ui_test::*;
use std::{env, path::Path};

fn main() -> color_eyre::Result<()> {
    let mut config = marker_uitest::simple_ui_test_config!()?;

    // Allows you to automatically update `.stderr` and `.stdout` files
    let bless = env::var_os("RUST_BLESS").is_some() || env::args().any(|arg| arg == "--bless");
    if bless {
        config.output_conflict_handling = OutputConflictHandling::Bless
    }

    // Maybe define replacement filters
    config.stderr_filter(r"\\", "/");
    config.stdout_filter(r"\\", "/");

    // Run the test
    run_tests_generic(
        config,
        default_file_filter,
        default_per_file_config,
        status_emitter::Text,
    )
}

Contributing

Contributions are highly appreciated! If you encounter any issues or have suggestions for improvements, please check out Marker's GitHub repository.

License

Copyright (c) 2022-2023 Rust-Marker

Rust-marker is distributed under the terms of the MIT license or the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT.

Dependencies

~12–26MB
~357K SLoC