diff --git a/CHANGELOG.md b/CHANGELOG.md index fc6cba0..2c3c59d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ - -## 0.5.0 (2019-04-08) +# Change Log +All notable changes to this project will be documented in this file. +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + + +## [Unreleased] - ReleaseDate + +## [0.5.0] - 2019-04-08 #### Features @@ -15,11 +22,7 @@ * Gracefully handle upcoming cargo features ([a00f2408](https://github.com/crate-ci/escargot/commit/a00f240831ddc71b1846005df4917111e3690a82)) - - - -## 0.4.0 (2018-12-31) - +## [0.4.0] - 2018-12-31 #### Features @@ -41,21 +44,13 @@ * Stream messages ([343027d4](https://github.com/crate-ci/escargot/commit/343027d40cdeb94b820ecb0a8fbb145fcf3f19c7), breaks [#](https://github.com/crate-ci/escargot/issues/)) * MessageItr -> MessageIter ([07c4b257](https://github.com/crate-ci/escargot/commit/07c4b25740898b75af7b5d291be04ac737c5cd6c), closes [#9](https://github.com/crate-ci/escargot/issues/9), breaks [#](https://github.com/crate-ci/escargot/issues/)) - - - -## 0.3.1 (2018-08-07) - +## [0.3.1] - 2018-08-07 #### Bug Fixes * **run:** Example support ([99029550](https://github.com/crate-ci/escargot/commit/990295504ebd195f330e7b3e19b01e86a7b401f7), closes [#7](https://github.com/crate-ci/escargot/issues/7)) - - - -## 0.3.0 (2018-08-05) - +## [0.3.0] - 2018-08-05 #### Features @@ -66,10 +61,15 @@ * `current_target` spelling is corrected ([df4607a8](https://github.com/crate-ci/escargot/commit/df4607a8170a27d746e7c259e05c478a02d570e5)) * Removed parts of `CargoError` ([df4607a8](https://github.com/crate-ci/escargot/commit/df4607a8170a27d746e7c259e05c478a02d570e5)) - -## 0.2.0 (2018-06-27) - +## [0.2.0] - 2018-06-27 #### Breaking Changes * Define concrete CargoError ([445cb391](https://github.com/crate-ci/escargot/commit/445cb39156b63ce1894d40b31805273d995e185c), breaks [#](https://github.com/crate-ci/escargot/issues/)) + + +[Unreleased]: https://github.com/assert-rs/predicates-rs/compare/v0.5.0...HEAD +[0.5.0]: https://github.com/assert-rs/predicates-rs/compare/v0.4.0...v0.5.0 +[0.4.0]: https://github.com/assert-rs/predicates-rs/compare/v0.3.1...v0.4.0 +[0.3.1]: https://github.com/assert-rs/predicates-rs/compare/v0.3.0...v0.3.1 +[0.3.0]: https://github.com/assert-rs/predicates-rs/compare/v0.2.0...v0.3.0 diff --git a/Cargo.toml b/Cargo.toml index 5be88ab..53478d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ edition = "2018" [badges] azure-devops = { project = "crate-ci", pipeline = "escargot" } codecov = { repository = "crate-ci/escargot" } +maintenance = { status = "passively-maintained" } [dependencies] serde = { version = "1.0", features = ["derive"] } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 55f8dc8..42a79c6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,31 +1,178 @@ +trigger: + branches: + include: ['master'] + tags: + include: ['v*'] +pr: + branches: + include: + - master + paths: + exclude: + - "*.md" + - "docs/*" + - "LICENSE-*" schedules: - cron: "5 5 5 * *" displayName: Monthly Build branches: include: - master +variables: + minrust: 1.44.0 + codecov_token: $(CODECOV_TOKEN_SECRET) + windows_vm: vs2017-win2016 + mac_vm: macos-10.14 + linux_vm: ubuntu-16.04 -jobs: -- template: default.yml@templates - parameters: - minrust: 1.36.0 - codecov_token: $(CODECOV_TOKEN_SECRET) -- job: "Committed" - displayName: Lint History - pool: - vmImage: 'ubuntu-16.04' - steps: - - checkout: self - - template: v1/azdo-step.yml@gh-install - parameters: - git: crate-ci/committed - target: 'x86_64-unknown-linux-gnu' - to: $(Build.StagingDirectory)/tools - - script: | - echo "This project uses Conventional style, see https://www.conventionalcommits.org" - $(Build.StagingDirectory)/tools/committed HEAD~..HEAD^2 --no-merge-commit -vv - displayName: Committed - condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) +stages: +- stage: check + displayName: Compilation Check + jobs: + - job: cargo_check + displayName: cargo check + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: stable + - script: cargo check --workspace --all-targets + displayName: Default features + - script: cargo check --workspace --all-targets --no-default-features + displayName: No-default features + - script: cargo check --workspace --all-targets --all-features + displayName: All features +- stage: test + displayName: Test + jobs: + - job: test + displayName: Test + strategy: + matrix: + windows: + imageName: ${{ variables.windows_vm }} + target: 'x86_64-pc-windows-msvc' + channel: stable + mac: + imageName: ${{ variables.mac_vm }} + target: 'x86_64-apple-darwin' + channel: stable + linux: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: stable + # Check for upcoming platform-specific compiler breakages + windows_beta: + imageName: ${{ variables.windows_vm }} + target: 'x86_64-pc-windows-msvc' + channel: beta + mac_beta: + imageName: ${{ variables.mac_vm }} + target: 'x86_64-apple-darwin' + channel: beta + linux_beta: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: beta + # Check for compiler breakages + linux_nightly: + imageName: ${{ variables.linux_vm }} + target: 'x86_64-unknown-linux-gnu' + channel: nightly + continueOnError: $[ne(variables.rust, 'stable')] + pool: + vmImage: $(imageName) + steps: + - template: install-rust.yml@templates + parameters: + rust: $(channel) + targets: ["$(TARGET)"] + - script: cargo test --target $(TARGET) --workspace + displayName: cargo test + - script: cargo doc --target $(TARGET) --workspace --no-deps + displayName: cargo doc + - job: msrv + displayName: "${{ format('Minimum supported Rust version: {0}', variables.minrust) }}" + dependsOn: [] + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: ${{ variables.minrust }} + - script: cargo check --all --bins --examples --tests + displayName: cargo check +- stage: style + displayName: Style checks + dependsOn: [] + jobs: + - job: "Committed" + displayName: Linting commit history + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - checkout: self + - template: v1/azdo-step.yml@gh-install + parameters: + git: crate-ci/committed + target: 'x86_64-unknown-linux-gnu' + to: $(Build.StagingDirectory)/tools + - script: | + echo "Linting commits:" + git log --graph --oneline HEAD~..HEAD^2 + echo "Against 'committed.toml':" + $(Build.StagingDirectory)/tools/committed --dump-config - + echo "" + echo "If this fails, don't sweat it. We're trying to encourage clear communication and not hinder contributions." + echo "If it is a reasonable issue and you lack time or feel uncomfortable fixing it yourself," + echo "let us know and we can mentor or fix it." + $(Build.StagingDirectory)/tools/committed HEAD~..HEAD^2 --no-merge-commit -vv + displayName: Lint commit history + condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest')) + - job: style + displayName: Style checking + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: stable + components: + - rustfmt + - script: cargo fmt --all -- --check + displayName: rustfmt + - job: lint + displayName: Linting + strategy: + matrix: + current: + channel: ${{ variables.minrust }} + next: + channel: stable + continueOnError: $[eq(variables.channel, 'stable')] + pool: + vmImage: ${{ variables.linux_vm }} + steps: + - template: install-rust.yml@templates + parameters: + rust: $(channel) + components: + - clippy + - script: cargo check --workspace --all-targets --all-features + displayName: Warnings + env: + RUSTFLAGS: "-D warnings" + - script: cargo clippy --workspace --all-features --all-targets -- -D warnings + displayName: clippy +- ${{ if ne('', variables.codecov_token) }}: + - stage: coverage + displayName: Code coverage + dependsOn: test + jobs: + - template: coverage.yml@templates + parameters: + token: ${{ variables.codecov_token }} resources: repositories: diff --git a/committed.toml b/committed.toml index 96d8787..08815cf 100644 --- a/committed.toml +++ b/committed.toml @@ -1 +1,3 @@ -style="Conventional" +style="conventional" +ignore_author_re="dependabot" +merge_commit = false diff --git a/src/build.rs b/src/build.rs index a140fe7..7875995 100644 --- a/src/build.rs +++ b/src/build.rs @@ -53,7 +53,6 @@ impl CargoBuild { /// .unwrap(); /// ``` /// - /// [`Cargo`]: struct.Cargo.html pub fn new() -> Self { Cargo::new().build() } diff --git a/src/format/diagnostic.rs b/src/format/diagnostic.rs index 553b4d4..717b9d8 100644 --- a/src/format/diagnostic.rs +++ b/src/format/diagnostic.rs @@ -9,6 +9,7 @@ type CowStr<'a> = borrow::Cow<'a, str>; /// The error code associated to this diagnostic. #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct DiagnosticCode<'a> { /// The code itself. #[serde(borrow)] @@ -16,14 +17,12 @@ pub struct DiagnosticCode<'a> { /// An explanation for the code #[serde(borrow)] pub explanation: Option>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// A line of code associated with the Diagnostic #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct DiagnosticSpanLine<'a> { /// The line of code associated with the error #[serde(borrow)] @@ -32,14 +31,12 @@ pub struct DiagnosticSpanLine<'a> { pub highlight_start: usize, /// End of the section of the line to highlight. 1-based, character offset in self.text pub highlight_end: usize, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Macro expansion information associated with a diagnostic. #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct DiagnosticSpanMacroExpansion<'a> { /// span where macro was applied to generate this code; note that /// this may itself derive from a macro (if @@ -54,15 +51,12 @@ pub struct DiagnosticSpanMacroExpansion<'a> { /// span where macro was defined (if known) #[serde(borrow)] pub def_site_span: Option>, - - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// A section of the source code associated with a Diagnostic #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct DiagnosticSpan<'a> { /// The file name this diagnostic comes from. #[serde(borrow)] @@ -97,9 +91,6 @@ pub struct DiagnosticSpan<'a> { /// Macro invocations that created the code at this span, if any. #[serde(borrow)] pub expansion: Option>>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Whether a suggestion can be safely applied. @@ -124,6 +115,7 @@ pub enum Applicability { /// A diagnostic message generated by rustc #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct Diagnostic<'a> { /// The error message of this diagnostic. #[serde(borrow)] @@ -142,9 +134,6 @@ pub struct Diagnostic<'a> { /// The message as rustc would render it #[serde(borrow)] pub rendered: Option>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// The diagnostic level diff --git a/src/format/mod.rs b/src/format/mod.rs index efc16a5..11b143f 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -33,6 +33,7 @@ pub enum Message<'a> { /// A compiler-generated file. #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct Artifact<'a> { /// The workspace member this artifact belongs to #[serde(borrow)] @@ -55,14 +56,12 @@ pub struct Artifact<'a> { pub executable: Option>, /// If true, then the files were already generated pub fresh: bool, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// A single target (lib, bin, example, ...) provided by a crate #[derive(Clone, Serialize, Deserialize, Debug)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct Target<'a> { /// Name as given in the `Cargo.toml` or generated from the file name #[serde(borrow)] @@ -92,9 +91,6 @@ pub struct Target<'a> { #[serde(default = "edition_default")] #[serde(borrow)] pub edition: CowStr<'a>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } fn edition_default() -> CowStr<'static> { @@ -116,6 +112,7 @@ pub struct WorkspaceMember<'a> { /// target. #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct ArtifactProfile<'a> { /// Optimization level. Possible values are 0-3, s or z. #[serde(borrow)] @@ -129,14 +126,12 @@ pub struct ArtifactProfile<'a> { pub overflow_checks: bool, /// Whether this profile is a test pub test: bool, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Message left by the compiler #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct FromCompiler<'a> { /// The workspace member this message belongs to #[serde(borrow)] @@ -147,14 +142,12 @@ pub struct FromCompiler<'a> { /// The message the compiler sent. #[serde(borrow)] pub message: diagnostic::Diagnostic<'a>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Output of a Build Script execution. #[derive(Debug, Clone, Serialize, Deserialize)] #[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] pub struct BuildScript<'a> { /// The workspace member this build script execution belongs to #[serde(borrow)] @@ -175,9 +168,6 @@ pub struct BuildScript<'a> { /// The environment variables to add to the compilation #[serde(borrow)] pub env: Vec<(CowStr<'a>, CowStr<'a>)>, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } #[cfg(not(feature = "print"))] @@ -225,7 +215,7 @@ pub(crate) fn log_message(msg: &Message<'_>) { .rendered .as_ref() .map(|s| s.as_ref()) - .unwrap_or(comp.message.message.as_ref()); + .unwrap_or_else(|| comp.message.message.as_ref()); match comp.message.level { diagnostic::DiagnosticLevel::Ice => println!("{}", content), diagnostic::DiagnosticLevel::Error => println!("{}", content), diff --git a/src/format/test.rs b/src/format/test.rs index 1e8e2cf..b8cd5b3 100644 --- a/src/format/test.rs +++ b/src/format/test.rs @@ -42,16 +42,15 @@ pub enum Suite { /// Suite-started event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct SuiteStarted { /// Number of test cases in the suite. pub test_count: usize, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Suite-finished successfully event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct SuiteOk { /// Cases that passed. pub passed: usize, @@ -65,13 +64,11 @@ pub struct SuiteOk { pub measured: usize, /// Cases filtered out by caller. pub filtered_out: usize, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Suite-finished with failure event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct SuiteFailed { /// Cases that passed. pub passed: usize, @@ -85,9 +82,6 @@ pub struct SuiteFailed { pub measured: usize, /// Cases filtered out by caller. pub filtered_out: usize, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Test case event. @@ -115,26 +109,23 @@ pub enum Test { /// Case-started event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestStarted { /// Test case name. pub name: String, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Case-finished successfully event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestOk { /// Test case name. pub name: String, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Case-finished with failure event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestFailed { /// Test case name. pub name: String, @@ -142,43 +133,35 @@ pub struct TestFailed { pub stdout: Option, /// Test failure mssage pub message: Option, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Case-ignored event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestIgnored { /// Test case name. pub name: String, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Case-allowed-failure event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestAllowedFailured { /// Test case name. pub name: String, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Case-timeout event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct TestTimeout { /// Test case name. pub name: String, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } /// Benchmark event. #[derive(Serialize, Deserialize, Debug, Eq, PartialEq)] +#[non_exhaustive] pub struct Bench { /// Benchmark name. pub name: String, @@ -188,17 +171,12 @@ pub struct Bench { pub deviation: usize, /// Mb/s pub mib_per_second: Option, - #[doc(hidden)] - #[serde(skip)] - __do_not_match_exhaustively: (), } #[cfg(test)] mod tests { use super::*; - use serde_json; - #[test] fn suite_started() { let input = r#"{ "type": "suite", "event": "started", "test_count": 10 }"#; diff --git a/src/msg.rs b/src/msg.rs index ec2dbe5..5387f03 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -3,9 +3,6 @@ use std::io::BufRead; use std::io::Read; use std::process; -use serde; -use serde_json; - use crate::error::*; use crate::format; diff --git a/src/run.rs b/src/run.rs index 25eacab..da73e84 100644 --- a/src/run.rs +++ b/src/run.rs @@ -35,7 +35,7 @@ use crate::msg::*; /// println!("artifact={}", run.path().display()); /// ``` /// -/// [`CargoBuild::run`]: struct.CargoBuild.html#method.run +/// [`CargoBuild::run`]: CargoBuild::run() pub struct CargoRun { bin_path: path::PathBuf, } @@ -96,7 +96,7 @@ impl CargoRun { /// println!("artifact={}", run.path().display()); /// ``` /// - /// [`Command`]: https://doc.rust-lang.org/std/process/struct.Command.html + /// [`Command`]: std::process::Command pub fn path(&self) -> &path::Path { &self.bin_path } @@ -114,7 +114,7 @@ fn extract_bin<'a>(msg: &'a format::Message<'_>, desired_kind: &str) -> Option<& && art.target.crate_types == ["bin"] && art.target.kind == [desired_kind] { - Some(art.filenames.iter().next().expect("files must exist")) + Some(art.filenames.get(0).expect("files must exist")) } else { None } diff --git a/src/test.rs b/src/test.rs index fcf06f1..dd6f4dc 100644 --- a/src/test.rs +++ b/src/test.rs @@ -35,7 +35,7 @@ use crate::msg::*; /// println!("artifact={}", run.path().display()); /// ``` /// -/// [`CargoBuild::run_tests`]: struct.CargoBuild.html#method.run_tests +/// [`CargoBuild::run_tests`]: CargoBuild::run_tests() pub struct CargoTest { bin_path: path::PathBuf, kind: String, @@ -130,7 +130,7 @@ impl CargoTest { /// assert_eq!(run.len(), 3); /// ``` /// - /// [`Command`]: https://doc.rust-lang.org/std/process/struct.Command.html + /// [`Command`]: std::process::Command pub fn path(&self) -> &path::Path { &self.bin_path } @@ -148,21 +148,19 @@ impl CargoTest { } } -fn extract_bin<'a>(msg: &'a format::Message<'_>) -> Option { +fn extract_bin(msg: &format::Message<'_>) -> Option { match msg { format::Message::CompilerArtifact(art) => { if art.profile.test { let bin_path = art .filenames - .iter() - .next() + .get(0) .expect("files must exist") .to_path_buf(); let kind = art .target .kind - .iter() - .next() + .get(0) .expect("kind must exist") .as_ref() .to_owned(); diff --git a/tests/build.rs b/tests/build.rs index 2a5b2df..0572532 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1,6 +1,3 @@ -use assert_fs; -use escargot; - fn test_fixture(name: &str) { let temp = assert_fs::TempDir::new().unwrap(); diff --git a/tests/run.rs b/tests/run.rs index 83243be..c1dbdc5 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -1,6 +1,3 @@ -use assert_fs; -use escargot; - fn test_fixture(name: &str) { let temp = assert_fs::TempDir::new().unwrap();