Skip to content

Commit

Permalink
ci work
Browse files Browse the repository at this point in the history
  • Loading branch information
hkratz committed Sep 26, 2024
1 parent c77ccbd commit 3f3f68d
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 5 deletions.
53 changes: 52 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
INLINE_IGNORE_PATTERN: "drop_in_place|::fmt::"

jobs:
test:
expect:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -28,6 +28,53 @@ jobs:
"beta",
"nightly",
]
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: cargo check --all-targets
shell: bash
run: |
output=$(cargo check --all-targets 2>&1)
echo "$output" > check_output.txt
if ! diff -u tests/check-expect-supported.out check_output.txt; then
echo "Cargo check output does not match expected output"
exit 1
fi
- name: cargo clean
run: cargo clean
- name: cargo test
run: cargo test --all-targets
- name: cargo clean
run: cargo clean
- name: cargo clippy
shell: bash
run: |
output=$(cargo clippy --all-targets 2>&1)
echo "$output" > clippy_output.txt
if ! diff -u tests/clippy-expect-supported.out clippy_output.txt; then
echo "Cargo clippy output does not match expected output"
exit 1
fi
- name: Run cargo check comparison
run: ./tests/compare-output.sh "check" "tests/check-expect-supported.out"
- name: cargo clean
run: cargo clean
- name: cargo test
run: cargo test --all-targets
- name: cargo clean
run: cargo clean
- name: Run cargo clippy comparison
run: ./tests/compare-output.sh "clippy" "tests/clippy-expect-supported.out"
allow:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain: ["1.43.0", "1.80.0"]
env:
RUSTFLAGS: "-D warnings"
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand All @@ -37,6 +84,10 @@ jobs:
with:
toolchain: ${{ matrix.toolchain }}
components: clippy
- name: cargo check
run: cargo check --all-targets
- name: cargo clean
run: cargo clean
- name: cargo test
run: cargo test --all-targets
- name: cargo clean
Expand Down
4 changes: 0 additions & 4 deletions examples/simple.rs

This file was deleted.

16 changes: 16 additions & 0 deletions output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
warning: this lint expectation is unfulfilled
--> tests/simple.rs:15:20
|
15 | #[flexpect::expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> tests/simple.rs:18:20
|
18 | #[flexpect::expect(clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^

warning: `flexpect` (test "simple") generated 2 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
17 changes: 17 additions & 0 deletions tests/check-expect-supported.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Checking flexpect v0.0.1 (/Users/hans/dev/flexpect)
warning: this lint expectation is unfulfilled
--> tests/simple.rs:14:20
|
14 | #[flexpect::expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> tests/simple.rs:34:20
|
34 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^

warning: `flexpect` (test "simple") generated 2 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
28 changes: 28 additions & 0 deletions tests/clippy-expect-supported.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
warning: this lint expectation is unfulfilled
--> tests/simple.rs:14:20
|
14 | #[flexpect::expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: this lint expectation is unfulfilled
--> tests/simple.rs:17:20
|
17 | #[flexpect::expect(clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^

warning: this lint expectation is unfulfilled
--> tests/simple.rs:34:20
|
34 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^

warning: this lint expectation is unfulfilled
--> tests/simple.rs:34:38
|
34 | #[flexpect::expect(unused_variables, clippy::clone_on_copy)]
| ^^^^^^^^^^^^^^^^^^^^^

warning: `flexpect` (test "simple") generated 4 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
10 changes: 10 additions & 0 deletions tests/compare-output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail
command=$1
expected_file=$2
output=$(cargo ${command} 2>&1)
echo "$output" > output.txt
if ! diff -u ${expected_file} output.txt; then
echo "Cargo ${command} output does not match expected output"
exit 1
fi
41 changes: 41 additions & 0 deletions tests/simple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#[test]
#[flexpect::expect(unused_variables)]
fn compiler_warning_correctly_flexpected() {
let x = 1;
}

#[flexpect::expect(clippy::clone_on_copy)]
#[test]
fn clippy_warning_correctly_flexpected() {
let _ = 32.clone();
}

#[test]
#[flexpect::expect(unused_variables)]
fn compiler_warning_incorrectly_flexpected() {}

#[flexpect::expect(clippy::clone_on_copy)]
#[test]
fn clippy_warning_incorrectly_flexpected() {}

#[flexpect::expect(unused_variables, clippy::clone_on_copy)]
mod submod_correct {
#[test]
fn compiler_warning_correctly_flexpected() {
let x = 1;
}

#[test]
fn clippy_warning_correctly_flexpected() {
let _ = 32.clone();
}
}

#[flexpect::expect(unused_variables, clippy::clone_on_copy)]
mod submod_incorrect {
#[test]
fn compiler_warning_incorrectly_flexpected() {}

#[test]
fn clippy_warning_incorrectly_flexpected() {}
}

0 comments on commit 3f3f68d

Please sign in to comment.