Skip to content

Commit

Permalink
vendor ui_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexendoo committed Feb 28, 2024
1 parent 0a579ef commit 4a849b9
Show file tree
Hide file tree
Showing 197 changed files with 9,497 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ color-print = "0.3.4"
anstream = "0.6.0"

[dev-dependencies]
ui_test = "0.22.2"
ui_test = { path = "./ui_test" }
tester = "0.9"
regex = "1.5"
toml = "0.7.3"
Expand Down
1 change: 1 addition & 0 deletions ui_test/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
4 changes: 4 additions & 0 deletions ui_test/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# TODO (check if already done)
* [ ] Add tests
* [ ] Add CHANGELOG.md entry
44 changes: 44 additions & 0 deletions ui_test/.github/rust.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"problemMatcher": [
{
"owner": "cargo-common",
"pattern": [
{
"regexp": "^(warning|warn|error)(\\[(\\S*)\\])?: (.*)$",
"severity": 1,
"message": 4,
"code": 3
},
{
"regexp": "^\\s+-->\\s(\\S+):(\\d+):(\\d+)$",
"file": 1,
"line": 2,
"column": 3
}
]
},
{
"owner": "cargo-test",
"pattern": [
{
"regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+):(\\d+)$",
"message": 1,
"file": 2,
"line": 3,
"column": 4
}
]
},
{
"owner": "cargo-fmt",
"pattern": [
{
"regexp": "^(Diff in (\\S+)) at line (\\d+):",
"message": 1,
"file": 2,
"line": 3
}
]
}
]
}
76 changes: 76 additions & 0 deletions ui_test/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release new version

on:
workflow_dispatch:
secrets:
CARGO_REGISTRY_TOKEN:
required: true

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always

jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: true

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2

# Determine which version we're about to publish, so we can tag it appropriately.
# If the tag already exists, then we've already published this version.
- name: Determine current version
id: version-check
run: |
# Fail on first error, on undefined variables, and on errors in pipes.
set -euo pipefail
export VERSION="$(cargo metadata --format-version 1 | \
jq --arg crate_name ui_test --exit-status -r \
'.packages[] | select(.name == $crate_name) | .version')"
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [[ "$(git tag -l "$VERSION")" != '' ]]; then
echo "Aborting: Version $VERSION is already published, we found its tag in the repo."
exit 1
fi
# TODO: Replace this with the cargo-semver-checks v2 GitHub Action when it's stabilized:
# https://github.com/obi1kenobi/cargo-semver-checks-action/pull/21
- name: Semver-check
run: |
# Fail on first error, on undefined variables, and on errors in pipes.
set -euo pipefail
cargo install --locked cargo-semver-checks
cargo semver-checks check-release
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Tag the version
run: |
# Fail on first error, on undefined variables, and on errors in pipes.
set -euo pipefail
git tag "${{ steps.version-check.outputs.version }}"
git push origin "${{ steps.version-check.outputs.version }}"
- uses: taiki-e/create-gh-release-action@v1
name: Create GitHub release
with:
branch: main
ref: refs/tags/${{ steps.version-check.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions ui_test/.github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: check rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Format
run: cargo fmt --check

clippy:
name: check clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clippy
run: cargo clippy -- -D warnings

tests:
strategy:
matrix:
include:
- os: ubuntu-latest
host_target: x86_64-unknown-linux-gnu
- os: macos-latest
host_target: x86_64-apple-darwin
- os: windows-latest
host_target: i686-pc-windows-msvc
runs-on: ${{ matrix.os }}
# Run tests under a directory with a space in it to double check the windows path heuristic
defaults:
run:
working-directory: "dir with spaces/ui test"
steps:
- uses: actions/checkout@v3
with:
path: "dir with spaces/ui test"
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --verbose
- name: Run ui tests
run: cargo test --verbose --test integration -- --check
- name: Run unit tests
run: cargo test --verbose
1 change: 1 addition & 0 deletions ui_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
75 changes: 75 additions & 0 deletions ui_test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

### Fixed

### Changed

### Removed

## [0.22.2] - 2024-02-27

### Added

### Fixed

### Changed

* `spanned` dependency bump to lower `bstr` to `1.6.0` to resolve windows linker issues with `1.7`

### Removed

## [0.22.1] - 2024-02-16

### Added

* Add `//~v` comments to put an error matcher above the error site.

### Fixed

* Give aux builds the default comment config, too

### Changed

### Removed

## [0.22.0] - 2024-01-24

### Added

* Started maintaining a changelog
* `Config::comment_defaults` allows setting `//@` comments for all tests
* `//~` comments can now specify just an error code or lint name, without any message. ERROR level is implied
* `Revisioned::diagnostic_code_prefix` allows stripping a prefix of diagnostic codes to avoid having to repeat `clippy::` in all messages

### Fixed

* report an error instead of panicking when encountering a suggestion that does not belong to the main file.
* number of filtered tests is now > 0 when things actually got filtered.

### Changed

* crate-private span handling was passed off to the `spanned` crate, improving some diagnostics along the way.
* `Config::output_conflict_handling` does not contain the bless command message anymore, it is instead available separately as `Config::bless_command`
* Updating `cargo_metadata` to `0.18`
* Updated `spanned` to `0.1.5`, giving more precise spans for more iterator operations
* `Config::cfgs` is now `Config::program::cfg_flag`
* Bumped `annotate-snippets` to `0.10`

### Removed

* `$DIR` and `RUSTLIB` replacements
* `Config::edition` (replaced by `config.comment_defaults.base().edition`)
* `Config::filter_stdout` (replaced by `config.comment_defaults.base().normalize_stdout`)
* `Config::filter_stderr` (replaced by `config.comment_defaults.base().normalize_stderr`)
* `Config::mode` (replaced by `config.comment_defaults.base().mode`)

## [0.21.2] - 2023-09-27
7 changes: 7 additions & 0 deletions ui_test/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Running the test suite

Running `cargo test` will automatically update the `.stderr`
and `.stdout` files.

If you only want to check that the output files match and not
update them, use `cargo test -- -- --check`
46 changes: 46 additions & 0 deletions ui_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[package]
name = "ui_test"
version = "0.22.2"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "A test framework for testing rustc diagnostics output"
repository = "https://github.com/oli-obk/ui_test"
rust-version = "1.63"

[lib]
test = true # we have unit tests
doctest = false # but no doc tests

[dependencies]
rustc_version = "0.4"
colored = "2"
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
cargo_metadata = "0.18"
crossbeam-channel = "0.5.6"
tempfile = "3.3.0"
bstr = "1.0.1"
rustfix = "0.6.1"
cargo-platform = "0.1.2"
comma = "1.0.0"
anyhow = "1.0.6"
indicatif = "0.17.6"
prettydiff = { version = "0.6.4", default_features = false }
annotate-snippets = { version = "0.10.0" }
levenshtein = "1.0.5"
spanned = "0.1.6"

[dependencies.regex]
version = "1.5.5"
default-features = false
features = ["unicode-gencat"]

[dependencies.color-eyre]
version = "0.6.1"
default-features = false
features = ["capture-spantrace"]

[[test]]
name = "integration"
harness = false
Loading

0 comments on commit 4a849b9

Please sign in to comment.