summaryrefslogtreecommitdiffstats
path: root/vendor/strip-ansi-escapes
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:36 +0000
commite02c5b5930c2c9ba3e5423fe12e2ef0155017297 (patch)
treefd60ebbbb5299e16e5fca8c773ddb74f764760db /vendor/strip-ansi-escapes
parentAdding debian version 1.73.0+dfsg1-1. (diff)
downloadrustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.tar.xz
rustc-e02c5b5930c2c9ba3e5423fe12e2ef0155017297.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/strip-ansi-escapes')
-rw-r--r--vendor/strip-ansi-escapes/.cargo-checksum.json1
-rw-r--r--vendor/strip-ansi-escapes/Cargo.lock65
-rw-r--r--vendor/strip-ansi-escapes/Cargo.toml25
-rw-r--r--vendor/strip-ansi-escapes/LICENSE-APACHE201
-rw-r--r--vendor/strip-ansi-escapes/LICENSE-MIT25
-rw-r--r--vendor/strip-ansi-escapes/README.md58
-rw-r--r--vendor/strip-ansi-escapes/examples/strip-escapes.rs18
-rw-r--r--vendor/strip-ansi-escapes/src/lib.rs219
8 files changed, 0 insertions, 612 deletions
diff --git a/vendor/strip-ansi-escapes/.cargo-checksum.json b/vendor/strip-ansi-escapes/.cargo-checksum.json
deleted file mode 100644
index e99a022fc..000000000
--- a/vendor/strip-ansi-escapes/.cargo-checksum.json
+++ /dev/null
@@ -1 +0,0 @@
-{"files":{"Cargo.lock":"0f23e34eabdc6e3ba08368712d0740a4389f7ae214a22a74ceb77f48781c8394","Cargo.toml":"a4f1ce10b189babf7799c9c751ad569431c500e603e2842cbbe9b0d0b5b99a3d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"1418fdabd96762bb5892098a229061f07dd624245687fd0a95ef33f3feb845a0","README.md":"5edacbe2884462365006d8b7aa26ecb416e4208d38c4cf42a3eca82526c411f1","examples/strip-escapes.rs":"c510f589aae3dd4258a11ef1b5bc87aa2d5a29cad5d5b65c099b02c29e7cf649","src/lib.rs":"f08f5d5646fcf0721ec25e746ca7b45ba9ad4376ddffdf9d9618d83f1dab6fa0"},"package":"011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8"} \ No newline at end of file
diff --git a/vendor/strip-ansi-escapes/Cargo.lock b/vendor/strip-ansi-escapes/Cargo.lock
deleted file mode 100644
index f8be9b2ea..000000000
--- a/vendor/strip-ansi-escapes/Cargo.lock
+++ /dev/null
@@ -1,65 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-[[package]]
-name = "arrayvec"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.28"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
-dependencies = [
- "unicode-xid",
-]
-
-[[package]]
-name = "quote"
-version = "1.0.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
-dependencies = [
- "proc-macro2",
-]
-
-[[package]]
-name = "strip-ansi-escapes"
-version = "0.1.1"
-dependencies = [
- "vte",
-]
-
-[[package]]
-name = "unicode-xid"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
-
-[[package]]
-name = "utf8parse"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372"
-
-[[package]]
-name = "vte"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983"
-dependencies = [
- "arrayvec",
- "utf8parse",
- "vte_generate_state_changes",
-]
-
-[[package]]
-name = "vte_generate_state_changes"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
-dependencies = [
- "proc-macro2",
- "quote",
-]
diff --git a/vendor/strip-ansi-escapes/Cargo.toml b/vendor/strip-ansi-escapes/Cargo.toml
deleted file mode 100644
index 659855745..000000000
--- a/vendor/strip-ansi-escapes/Cargo.toml
+++ /dev/null
@@ -1,25 +0,0 @@
-# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
-#
-# When uploading crates to the registry Cargo will automatically
-# "normalize" Cargo.toml files for maximal compatibility
-# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
-#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
-
-[package]
-name = "strip-ansi-escapes"
-version = "0.1.1"
-authors = ["Ted Mielczarek <ted@mielczarek.org>"]
-description = "Strip ANSI escape sequences from byte streams."
-homepage = "https://github.com/luser/strip-ansi-escapes"
-documentation = "https://docs.rs/strip-ansi-escapes"
-readme = "README.md"
-keywords = ["ansi", "escape", "terminal"]
-license = "Apache-2.0/MIT"
-repository = "https://github.com/luser/strip-ansi-escapes"
-[dependencies.vte]
-version = "0.10"
diff --git a/vendor/strip-ansi-escapes/LICENSE-APACHE b/vendor/strip-ansi-escapes/LICENSE-APACHE
deleted file mode 100644
index 16fe87b06..000000000
--- a/vendor/strip-ansi-escapes/LICENSE-APACHE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/vendor/strip-ansi-escapes/LICENSE-MIT b/vendor/strip-ansi-escapes/LICENSE-MIT
deleted file mode 100644
index 8d8d2ce1f..000000000
--- a/vendor/strip-ansi-escapes/LICENSE-MIT
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) 2018 Mozilla
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without
-limitation the rights to use, copy, modify, merge,
-publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
-IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
diff --git a/vendor/strip-ansi-escapes/README.md b/vendor/strip-ansi-escapes/README.md
deleted file mode 100644
index adb95a31f..000000000
--- a/vendor/strip-ansi-escapes/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-![Continuous integration](https://github.com/luser/strip-ansi-escapes/workflows/Continuous%20integration/badge.svg) [![crates.io](https://img.shields.io/crates/v/strip-ansi-escapes.svg)](https://crates.io/crates/strip-ansi-escapes) [![](https://docs.rs/strip-ansi-escapes/badge.svg)](https://docs.rs/strip-ansi-escapes)
-
-A crate for stripping ANSI escape sequences from byte sequences.
-
-This can be used to take output from a program that includes escape sequences and write
-it somewhere that does not easily support them, such as a log file.
-
-# Examples
-
-The `strip` function accepts bytes and returns a `Vec` of bytes with ANSI escape sequences removed.
-
-```rust
-extern crate strip_ansi_escapes;
-
-use std::io::{self, Write};
-
-fn work() -> io::Result<()> {
- let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar";
- let plain_bytes = strip_ansi_escapes::strip(&bytes_with_colors)?;
- io::stdout().write_all(&plain_bytes)?;
- Ok(())
-}
-
-fn main() {
- work().unwrap();
-}
-```
-
-For writing directly to a writer, the `Writer` struct may be preferable.
-
-```rust
-extern crate strip_ansi_escapes;
-
-use std::io::{self, Write};
-use strip_ansi_escapes::Writer;
-
-fn work() -> io::Result<()> {
- let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar";
- let mut writer = Writer::new(io::stdout());
- // Only `foo bar` will be written to stdout
- writer.write_all(bytes_with_colors)?;
- Ok(())
-}
-
-fn main() {
- work().unwrap();
-}
-```
-
-# License
-
-Licensed under either of
-
- * Apache License, Version 2.0 ([`LICENSE-APACHE`](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- * MIT license ([`LICENSE-MIT`](./LICENSE-MIT) or http://opensource.org/licenses/MIT)
-
-at your option.
-
diff --git a/vendor/strip-ansi-escapes/examples/strip-escapes.rs b/vendor/strip-ansi-escapes/examples/strip-escapes.rs
deleted file mode 100644
index ee82e5bd9..000000000
--- a/vendor/strip-ansi-escapes/examples/strip-escapes.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-extern crate strip_ansi_escapes;
-
-use std::io;
-use strip_ansi_escapes::Writer;
-
-pub fn work() -> io::Result<()> {
- let stdin = io::stdin();
- let mut in_lock = stdin.lock();
- let stdout = io::stdout();
- let out_lock = stdout.lock();
- let mut writer = Writer::new(out_lock);
- io::copy(&mut in_lock, &mut writer)?;
- Ok(())
-}
-
-pub fn main() {
- work().unwrap();
-}
diff --git a/vendor/strip-ansi-escapes/src/lib.rs b/vendor/strip-ansi-escapes/src/lib.rs
deleted file mode 100644
index 915494ebf..000000000
--- a/vendor/strip-ansi-escapes/src/lib.rs
+++ /dev/null
@@ -1,219 +0,0 @@
-//! A crate for stripping ANSI escape sequences from byte sequences.
-//!
-//! This can be used to take output from a program that includes escape sequences and write
-//! it somewhere that does not easily support them, such as a log file.
-//!
-//! The simplest interface provided is the [`strip`] function, which takes a byte slice and returns
-//! a `Vec` of bytes with escape sequences removed. For writing bytes directly to a writer, you
-//! may prefer using the [`Writer`] struct, which implements `Write` and strips escape sequences
-//! as they are written.
-//!
-//! [`strip`]: fn.strip.html
-//! [`Writer`]: struct.Writer.html
-//!
-//! # Example
-//!
-//! ```
-//! use std::io::{self, Write};
-//!
-//! # fn foo() -> io::Result<()> {
-//! let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar";
-//! let plain_bytes = strip_ansi_escapes::strip(&bytes_with_colors)?;
-//! io::stdout().write_all(&plain_bytes)?;
-//! # Ok(())
-//! # }
-//! ```
-
-extern crate vte;
-
-use std::io::{self, Cursor, IntoInnerError, LineWriter, Write};
-use vte::{Parser, Perform};
-
-/// `Writer` wraps an underlying type that implements `Write`, stripping ANSI escape sequences
-/// from bytes written to it before passing them to the underlying writer.
-///
-/// # Example
-/// ```
-/// use std::io::{self, Write};
-/// use strip_ansi_escapes::Writer;
-///
-/// # fn foo() -> io::Result<()> {
-/// let bytes_with_colors = b"\x1b[32mfoo\x1b[m bar";
-/// let mut writer = Writer::new(io::stdout());
-/// // Only `foo bar` will be written to stdout
-/// writer.write_all(bytes_with_colors)?;
-/// # Ok(())
-/// # }
-/// ```
-
-pub struct Writer<W>
-where
- W: Write,
-{
- performer: Performer<W>,
- parser: Parser,
-}
-
-/// Strip ANSI escapes from `data` and return the remaining bytes as a `Vec<u8>`.
-///
-/// See [the module documentation][mod] for an example.
-///
-/// [mod]: index.html
-pub fn strip<T>(data: T) -> io::Result<Vec<u8>>
-where
- T: AsRef<[u8]>,
-{
- let c = Cursor::new(Vec::new());
- let mut writer = Writer::new(c);
- writer.write_all(data.as_ref())?;
- Ok(writer.into_inner()?.into_inner())
-}
-
-struct Performer<W>
-where
- W: Write,
-{
- writer: LineWriter<W>,
- err: Option<io::Error>,
-}
-
-impl<W> Writer<W>
-where
- W: Write,
-{
- /// Create a new `Writer` that writes to `inner`.
- pub fn new(inner: W) -> Writer<W> {
- Writer {
- performer: Performer {
- writer: LineWriter::new(inner),
- err: None,
- },
- parser: Parser::new(),
- }
- }
-
- /// Unwraps this `Writer`, returning the underlying writer.
- ///
- /// The internal buffer is written out before returning the writer, which
- /// may produce an [`IntoInnerError`].
- ///
- /// [IntoInnerError]: https://doc.rust-lang.org/std/io/struct.IntoInnerError.html
- pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
- self.performer.into_inner()
- }
-}
-
-impl<W> Write for Writer<W>
-where
- W: Write,
-{
- fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- for b in buf.iter() {
- self.parser.advance(&mut self.performer, *b)
- }
- match self.performer.err.take() {
- Some(e) => Err(e),
- None => Ok(buf.len()),
- }
- }
-
- fn flush(&mut self) -> io::Result<()> {
- self.performer.flush()
- }
-}
-
-impl<W> Performer<W>
-where
- W: Write,
-{
- pub fn flush(&mut self) -> io::Result<()> {
- self.writer.flush()
- }
-
- pub fn into_inner(self) -> Result<W, IntoInnerError<LineWriter<W>>> {
- self.writer.into_inner()
- }
-}
-
-impl<W> Perform for Performer<W>
-where
- W: Write,
-{
- fn print(&mut self, c: char) {
- // Just print bytes to the inner writer.
- self.err = write!(self.writer, "{}", c).err();
- }
- fn execute(&mut self, byte: u8) {
- // We only care about executing linefeeds.
- if byte == b'\n' {
- self.err = writeln!(self.writer).err();
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- use std::env;
- use std::env::consts::EXE_EXTENSION;
- use std::path::Path;
- use std::process::Command;
-
- #[test]
- fn readme_test() {
- let rustdoc = Path::new("rustdoc").with_extension(EXE_EXTENSION);
- let readme = Path::new(file!())
- .parent()
- .unwrap()
- .parent()
- .unwrap()
- .join("README.md");
- let exe = env::current_exe().unwrap();
- let outdir = exe.parent().unwrap();
- let mut cmd = Command::new(rustdoc);
- cmd.args(&["--verbose", "--test", "-L"])
- .arg(&outdir)
- .arg(&readme);
- println!("{:?}", cmd);
- let result = cmd
- .spawn()
- .expect("Failed to spawn process")
- .wait()
- .expect("Failed to run process");
- assert!(
- result.success(),
- "Failed to run rustdoc tests on README.md!"
- );
- }
-
- fn assert_parsed(input: &[u8], expected: &[u8]) {
- let bytes = strip(input).expect("Failed to strip escapes");
- assert_eq!(bytes, expected);
- }
-
- #[test]
- fn test_simple() {
- assert_parsed(b"\x1b[m\x1b[m\x1b[32m\x1b[1m Finished\x1b[m dev [unoptimized + debuginfo] target(s) in 0.0 secs",
- b" Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs");
- }
-
- #[test]
- fn test_newlines() {
- assert_parsed(b"foo\nbar\n", b"foo\nbar\n");
- }
-
- #[test]
- fn test_escapes_newlines() {
- assert_parsed(b"\x1b[m\x1b[m\x1b[32m\x1b[1m Compiling\x1b[m utf8parse v0.1.0
-\x1b[m\x1b[m\x1b[32m\x1b[1m Compiling\x1b[m vte v0.3.2
-\x1b[m\x1b[m\x1b[32m\x1b[1m Compiling\x1b[m strip-ansi-escapes v0.1.0-pre (file:///build/strip-ansi-escapes)
-\x1b[m\x1b[m\x1b[32m\x1b[1m Finished\x1b[m dev [unoptimized + debuginfo] target(s) in 0.66 secs
-",
- b" Compiling utf8parse v0.1.0
- Compiling vte v0.3.2
- Compiling strip-ansi-escapes v0.1.0-pre (file:///build/strip-ansi-escapes)
- Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs
-");
- }
-}