Skip to content

Commit

Permalink
Merge pull request #42 from epage/finished
Browse files Browse the repository at this point in the history
feat(build): Support build-finished message
  • Loading branch information
epage committed Feb 1, 2021
2 parents debb804 + 730f03d commit e8dc072
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header -->
## [Unreleased] - ReleaseDate

#### Features

* Support `build-finished` message

## [0.5.0] - 2019-04-08

#### Features
Expand Down
9 changes: 0 additions & 9 deletions README.md
Expand Up @@ -8,15 +8,6 @@
![License](https://img.shields.io/crates/l/escargot.svg)
[![Crates Status](https://img.shields.io/crates/v/escargot.svg)](https://crates.io/crates/escargot)

## Install

Add to your `Cargo.toml`:

```toml
[dependencies]
escargot = "0.5"
```

## Why escargot

Compared to depending on `cargo`:
Expand Down
11 changes: 11 additions & 0 deletions release.toml
@@ -0,0 +1,11 @@
pre-release-commit-message = "chore({{crate_name}}): Release {{version}}"
no-dev-version = true
tag-message = "{{tag_name}}"
tag-name = "{{prefix}}v{{version}}"
pre-release-replacements = [
{file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1},
{file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1},
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/assert-rs/predicates-rs/compare/{{tag_name}}...HEAD", exactly=1},
]
19 changes: 19 additions & 0 deletions src/format/mod.rs
Expand Up @@ -15,6 +15,8 @@ type CowStr<'a> = borrow::Cow<'a, str>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "reason", rename_all = "kebab-case")]
pub enum Message<'a> {
/// Build completed, all further output should not be parsed
BuildFinished(BuildFinished),
/// The compiler generated an artifact
#[serde(borrow)]
CompilerArtifact(Artifact<'a>),
Expand All @@ -30,6 +32,14 @@ pub enum Message<'a> {
Unknown,
}

/// Build completed, all further output should not be parsed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct BuildFinished {
success: bool,
}

/// A compiler-generated file.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
Expand Down Expand Up @@ -77,6 +87,9 @@ pub struct Target<'a> {
/// Whether this is a doctest or not
#[serde(default)]
pub doctest: Option<bool>,
/// Whether this is a test file
#[serde(default)]
pub test: bool,

#[serde(default)]
#[serde(rename = "required-features")]
Expand Down Expand Up @@ -173,6 +186,9 @@ pub struct BuildScript<'a> {
#[cfg(not(feature = "print"))]
pub(crate) fn log_message(msg: &Message<'_>) {
match msg {
Message::BuildFinished(ref finished) => {
log::trace!("Build Finished: {:?}", finished.success);
}
Message::CompilerArtifact(ref art) => {
log::trace!("Building {:#?}", art.package_id,);
}
Expand Down Expand Up @@ -206,6 +222,9 @@ pub(crate) fn log_message(msg: &Message<'_>) {
#[cfg(feature = "print")]
pub(crate) fn log_message(msg: &Message<'_>) {
match msg {
Message::BuildFinished(ref finished) => {
println!("Build Finished: {:?}", finished.success);
}
Message::CompilerArtifact(ref art) => {
println!("Building {:#?}", art.package_id,);
}
Expand Down
9 changes: 1 addition & 8 deletions src/lib.rs
@@ -1,13 +1,6 @@
//! # Escargot: A Cargo API
//!
//! ## Install
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! escargot = "0.5"
//! ```
//! ## Features
//!
//! Features:
//! - `print` for logged output to be printed instead, generally for test writing.
Expand Down

0 comments on commit e8dc072

Please sign in to comment.