diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/escargot | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/escargot')
-rw-r--r-- | vendor/escargot/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | vendor/escargot/Cargo.lock | 413 | ||||
-rw-r--r-- | vendor/escargot/Cargo.toml | 102 | ||||
-rw-r--r-- | vendor/escargot/LICENSE-APACHE | 202 | ||||
-rw-r--r-- | vendor/escargot/LICENSE-MIT | 19 | ||||
-rw-r--r-- | vendor/escargot/README.md | 41 | ||||
-rw-r--r-- | vendor/escargot/build.rs | 16 | ||||
-rw-r--r-- | vendor/escargot/examples/example_fixture.rs | 33 | ||||
-rw-r--r-- | vendor/escargot/src/bin/bin_fixture.rs | 33 | ||||
-rw-r--r-- | vendor/escargot/src/build.rs | 340 | ||||
-rw-r--r-- | vendor/escargot/src/cargo.rs | 60 | ||||
-rw-r--r-- | vendor/escargot/src/error.rs | 91 | ||||
-rw-r--r-- | vendor/escargot/src/format/diagnostic.rs | 158 | ||||
-rw-r--r-- | vendor/escargot/src/format/mod.rs | 266 | ||||
-rw-r--r-- | vendor/escargot/src/format/test.rs | 242 | ||||
-rw-r--r-- | vendor/escargot/src/lib.rs | 59 | ||||
-rw-r--r-- | vendor/escargot/src/msg.rs | 117 | ||||
-rw-r--r-- | vendor/escargot/src/run.rs | 195 | ||||
-rw-r--r-- | vendor/escargot/src/test.rs | 201 | ||||
-rw-r--r-- | vendor/escargot/tests/build.rs | 69 |
20 files changed, 2658 insertions, 0 deletions
diff --git a/vendor/escargot/.cargo-checksum.json b/vendor/escargot/.cargo-checksum.json new file mode 100644 index 000000000..ab6428f75 --- /dev/null +++ b/vendor/escargot/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.lock":"95ce83a7e0ab70cca99dd0a0a7ea99339748021b174ad61a4075ea3a5f26d639","Cargo.toml":"7c612dd12e4589e977480e5fa84a7854fbc99c1ba1be6066630f7c15aa00583d","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"6efb0476a1cc085077ed49357026d8c173bf33017278ef440f222fb9cbcb66e6","README.md":"f7bd9d8293adb4ffb0eb74916ed3655c4d547065120c677ac5864f29f267d707","build.rs":"cba55a9fcf3ffdf532840055eef69d9d21c08b8a5c5cf67fb54bc02d2bc82528","examples/example_fixture.rs":"467bb70ad685f162e4973c5d2b303a00441606fbc025556499e2c8becef8ca42","src/bin/bin_fixture.rs":"467bb70ad685f162e4973c5d2b303a00441606fbc025556499e2c8becef8ca42","src/build.rs":"d5ea3fbfd76173ff2591f837d381a2c373e0dded54e954835d3948347b98a970","src/cargo.rs":"1eaa663727da84eba2eb897384c1b1a590fb3ed7b11378831c54852949db3174","src/error.rs":"7da88f81028e74aa0f96b28172117053c1c677678d7a2ea45aa9258949f37d7c","src/format/diagnostic.rs":"8b72e0d85102653fea20e71613d3edc0d64222a9d68a3366c9fc2c246aac3ac5","src/format/mod.rs":"69c5a0166e8c07caaeec05d9f940998bb26f3ddf7b9f1f3a6c32fc535541af91","src/format/test.rs":"e6da1112f035871298fc765c15be47568bebfd544314dcdcdb35b558863e7c97","src/lib.rs":"2157e8a234129b84cb0f0d8388d79c0c92934d161724e92c1fde5ab39e0b58ef","src/msg.rs":"6a8e23dd51d5e8278e7ec95c1b947ea196b76c8c255f6ad0b512670a16566653","src/run.rs":"1ab56fa566ddb6d0879caf85fa59878d53bd2111131b033865ceaadb82fcc568","src/test.rs":"bbf6bd546dde8951db3dd34efb670ceabd6e65a9c836415f5f8911b636ae8afb","tests/build.rs":"11275c344f6a3a17efdf1f3a16a624d41af67b8172984ccc437c05393c26985a"},"package":"768064bd3a0e2bedcba91dc87ace90beea91acc41b6a01a3ca8e9aa8827461bf"}
\ No newline at end of file diff --git a/vendor/escargot/Cargo.lock b/vendor/escargot/Cargo.lock new file mode 100644 index 000000000..17c773cda --- /dev/null +++ b/vendor/escargot/Cargo.lock @@ -0,0 +1,413 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "assert_fs" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d94b2a3f3786ff2996a98afbd6b4e5b7e890d685ccf67577f508ee2342c71cc9" +dependencies = [ + "doc-comment", + "globwalk", + "predicates", + "predicates-core", + "predicates-tree", + "tempfile", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "memchr", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "escargot" +version = "0.5.8" +dependencies = [ + "assert_fs", + "log", + "once_cell", + "serde", + "serde_json", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "globset" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "globwalk" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc" +dependencies = [ + "bitflags", + "ignore", + "walkdir", +] + +[[package]] +name = "ignore" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" +dependencies = [ + "crossbeam-utils", + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "predicates" +version = "2.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f54fc5dc63ed3bbf19494623db4f3af16842c0d975818e469022d09e53f0aa05" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" + +[[package]] +name = "predicates-tree" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termtree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/vendor/escargot/Cargo.toml b/vendor/escargot/Cargo.toml new file mode 100644 index 000000000..02ef84ff7 --- /dev/null +++ b/vendor/escargot/Cargo.toml @@ -0,0 +1,102 @@ +# 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 are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.66.0" +name = "escargot" +version = "0.5.8" +authors = ["Ed Page <eopage@gmail.com>"] +include = [ + "build.rs", + "src/**/*", + "Cargo.toml", + "Cargo.lock", + "LICENSE*", + "README.md", + "benches/**/*", + "examples/**/*", +] +description = "Cargo API written in Paris" +homepage = "https://github.com/crate-ci/escargot" +documentation = "http://docs.rs/escargot/" +readme = "README.md" +keywords = [ + "cargo", + "packaging", +] +categories = ["development-tools::build-utils"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/crate-ci/escargot.git" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "docsrs", +] + +[[package.metadata.release.pre-release-replacements]] +file = "CHANGELOG.md" +min = 1 +replace = "{{version}}" +search = "Unreleased" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = "...{{tag_name}}" +search = '\.\.\.HEAD' + +[[package.metadata.release.pre-release-replacements]] +file = "CHANGELOG.md" +min = 1 +replace = "{{date}}" +search = "ReleaseDate" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = """ +<!-- next-header --> +## [Unreleased] - ReleaseDate +""" +search = "<!-- next-header -->" + +[[package.metadata.release.pre-release-replacements]] +exactly = 1 +file = "CHANGELOG.md" +replace = """ +<!-- next-url --> +[Unreleased]: https://github.com/crate-ci/escargot/compare/{{tag_name}}...HEAD""" +search = "<!-- next-url -->" + +[dependencies.log] +version = "0.4.4" + +[dependencies.once_cell] +version = "1.2.0" + +[dependencies.serde] +version = "1.0.113" +features = ["derive"] + +[dependencies.serde_json] +version = "1.0" + +[dev-dependencies.assert_fs] +version = "1.0" + +[features] +cargo_unstable = [] +print = [] +strict_unstable = [] +test_unstable = [] diff --git a/vendor/escargot/LICENSE-APACHE b/vendor/escargot/LICENSE-APACHE new file mode 100644 index 000000000..8f71f43fe --- /dev/null +++ b/vendor/escargot/LICENSE-APACHE @@ -0,0 +1,202 @@ + 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/escargot/LICENSE-MIT b/vendor/escargot/LICENSE-MIT new file mode 100644 index 000000000..a2d01088b --- /dev/null +++ b/vendor/escargot/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) Individual contributors + +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/escargot/README.md b/vendor/escargot/README.md new file mode 100644 index 000000000..c4122c33f --- /dev/null +++ b/vendor/escargot/README.md @@ -0,0 +1,41 @@ +# escargot + +> **Cargo API written in Paris** + +[![codecov](https://codecov.io/gh/crate-ci/escargot/branch/master/graph/badge.svg)](https://codecov.io/gh/crate-ci/escargot) +[![Documentation](https://img.shields.io/badge/docs-master-blue.svg)][Documentation] +![License](https://img.shields.io/crates/l/escargot.svg) +[![Crates Status](https://img.shields.io/crates/v/escargot.svg)](https://crates.io/crates/escargot) + +## Why escargot + +Compared to depending on `cargo`: +- Faster compile times. +- Simpler API. +- Better interop with projects relying on other cargo versions. +- Probably slower execution, especially on platforms without an optimized `fork` (e.g. Windows). + +## Relevant crates + +Other related crates: +* [cargo](https://crates.io/crates/cargo) for the real thing +* [cargo-metadata](https://crates.io/crates/cargo_metadata) for a similar project specifically geared to the `metadata` subcommand. + +## 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. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. + +[Crates.io]: https://crates.io/crates/escargot +[Documentation]: https://docs.rs/escargot diff --git a/vendor/escargot/build.rs b/vendor/escargot/build.rs new file mode 100644 index 000000000..8b7b65a0c --- /dev/null +++ b/vendor/escargot/build.rs @@ -0,0 +1,16 @@ +use std::env; +use std::fs; +use std::io::Write; +use std::path; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + // env::ARCH doesn't include full triplet, and AFAIK there isn't a nicer way of getting the full triplet + // (see lib.rs for the rest of this hack) + let out = path::PathBuf::from(env::var_os("OUT_DIR").expect("run within cargo")) + .join("current_target.txt"); + let default_target = env::var("TARGET").expect("run as cargo build script"); + let mut file = fs::File::create(out).unwrap(); + file.write_all(default_target.as_bytes()).unwrap(); +} diff --git a/vendor/escargot/examples/example_fixture.rs b/vendor/escargot/examples/example_fixture.rs new file mode 100644 index 000000000..f47540f85 --- /dev/null +++ b/vendor/escargot/examples/example_fixture.rs @@ -0,0 +1,33 @@ +use std::env; +use std::error::Error; +use std::io; +use std::io::Write; +use std::process; + +fn run() -> Result<(), Box<dyn Error>> { + if let Ok(text) = env::var("stdout") { + println!("{}", text); + } + if let Ok(text) = env::var("stderr") { + eprintln!("{}", text); + } + + let code = env::var("exit") + .ok() + .map(|v| v.parse::<i32>()) + .map(|r| r.map(Some)) + .unwrap_or(Ok(None))? + .unwrap_or(0); + process::exit(code); +} + +fn main() { + let code = match run() { + Ok(_) => 0, + Err(ref e) => { + write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + 1 + } + }; + process::exit(code); +} diff --git a/vendor/escargot/src/bin/bin_fixture.rs b/vendor/escargot/src/bin/bin_fixture.rs new file mode 100644 index 000000000..f47540f85 --- /dev/null +++ b/vendor/escargot/src/bin/bin_fixture.rs @@ -0,0 +1,33 @@ +use std::env; +use std::error::Error; +use std::io; +use std::io::Write; +use std::process; + +fn run() -> Result<(), Box<dyn Error>> { + if let Ok(text) = env::var("stdout") { + println!("{}", text); + } + if let Ok(text) = env::var("stderr") { + eprintln!("{}", text); + } + + let code = env::var("exit") + .ok() + .map(|v| v.parse::<i32>()) + .map(|r| r.map(Some)) + .unwrap_or(Ok(None))? + .unwrap_or(0); + process::exit(code); +} + +fn main() { + let code = match run() { + Ok(_) => 0, + Err(ref e) => { + write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail"); + 1 + } + }; + process::exit(code); +} diff --git a/vendor/escargot/src/build.rs b/vendor/escargot/src/build.rs new file mode 100644 index 000000000..f37c1fb9e --- /dev/null +++ b/vendor/escargot/src/build.rs @@ -0,0 +1,340 @@ +use std::ffi::{self, OsStr}; +use std::process; + +use crate::cargo::Cargo; +use crate::cargo::CURRENT_TARGET; +use crate::error::*; +use crate::msg::*; +use crate::run::CargoRun; +#[cfg(feature = "test_unstable")] +use crate::test::CargoTest; + +/// The `build` subcommand. +/// +/// # Example +/// +/// ```rust +/// extern crate escargot; +/// extern crate assert_fs; +/// +/// let temp = assert_fs::TempDir::new().unwrap(); +/// escargot::CargoBuild::new() +/// .bin("bin") +/// .current_release() +/// .current_target() +/// .manifest_path("tests/fixtures/bin/Cargo.toml") +/// .target_dir(temp.path()) +/// .exec() +/// .unwrap(); +/// ``` +pub struct CargoBuild { + cmd: process::Command, + bin: bool, + example: bool, +} + +impl CargoBuild { + /// Shortcut to create a `build` subcommand. + /// + /// See also [`Cargo`]. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .bin("bin") + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + /// + pub fn new() -> Self { + Cargo::new().build() + } + + pub(crate) fn with_command(cmd: process::Command) -> Self { + Self { + cmd, + bin: false, + example: false, + } + } + + /// Build from `name` package in workspaces. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .package("bin") + /// .bin("bin") + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn package<S: AsRef<ffi::OsStr>>(self, name: S) -> Self { + self.arg("--package").arg(name) + } + /// Build only `name` binary. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .bin("bin") + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn bin<S: AsRef<ffi::OsStr>>(mut self, name: S) -> Self { + self.bin = true; + self.arg("--bin").arg(name) + } + + /// Build all examples + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .examples() + /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn examples(mut self) -> Self { + self.example = true; + self.arg("--examples") + } + + /// Build only `name` example. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .example("example_fixture") + /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn example<S: AsRef<ffi::OsStr>>(mut self, name: S) -> Self { + self.example = true; + self.arg("--example").arg(name) + } + + /// Build all tests + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .tests() + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn tests(self) -> Self { + self.arg("--tests") + } + + /// Build only `name` test. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// escargot::CargoBuild::new() + /// .test("test") + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .exec() + /// .unwrap(); + /// ``` + pub fn test<S: AsRef<ffi::OsStr>>(self, name: S) -> Self { + self.arg("--test").arg(name) + } + + /// Path to Cargo.toml + pub fn manifest_path<S: AsRef<ffi::OsStr>>(self, path: S) -> Self { + self.arg("--manifest-path").arg(path) + } + + /// Build artifacts in release mode, with optimizations. + pub fn release(self) -> Self { + self.arg("--release") + } + + /// Inserts or updates an environment variable mapping. + pub fn env<K, V>(mut self, key: K, val: V) -> Self + where + K: AsRef<OsStr>, + V: AsRef<OsStr>, + { + self.cmd.env(key, val); + + self + } + + /// Removes an environment variable + pub fn env_remove<K>(mut self, key: K) -> Self + where + K: AsRef<OsStr>, + { + self.cmd.env_remove(key); + self + } + + /// Build artifacts in release mode if the current process has, with optimizations. + #[cfg(debug_assertions)] + pub fn current_release(self) -> Self { + self + } + + /// Build artifacts in release mode if the current process has, with optimizations. + #[cfg(not(debug_assertions))] + pub fn current_release(self) -> Self { + self.release() + } + + /// Build for the target triplet. + pub fn target<S: AsRef<ffi::OsStr>>(self, triplet: S) -> Self { + self.arg("--target").arg(triplet) + } + + /// Build for the current process' triplet. + pub fn current_target(self) -> Self { + self.target(CURRENT_TARGET) + } + + /// Directory for all generated artifacts + pub fn target_dir<S: AsRef<ffi::OsStr>>(self, dir: S) -> Self { + self.arg("--target-dir").arg(dir) + } + + /// Activate all available features + pub fn all_features(self) -> Self { + self.arg("--all-features") + } + + /// Do not activate the `default` feature + pub fn no_default_features(self) -> Self { + self.arg("--no-default-features") + } + + /// Space-separated list of features to activate + pub fn features<S: AsRef<ffi::OsStr>>(self, features: S) -> Self { + self.arg("--features").arg(features) + } + + /// Manually pass an argument that is unsupported. + /// + /// Caution: Passing in `--` can throw off the API. + pub fn arg<S: AsRef<ffi::OsStr>>(mut self, arg: S) -> Self { + self.cmd.arg(arg); + self + } + + /// Manually pass arguments that are unsupported. + /// + /// Caution: Passing in `--` can throw off the API. + pub fn args<I: IntoIterator<Item = S>, S: AsRef<ffi::OsStr>>(mut self, args: I) -> Self { + self.cmd.args(args); + self + } + + /// Build the configured target, returning compiler messages. + pub fn exec(self) -> CargoResult<CommandMessages> { + CommandMessages::with_command(self.cmd) + } + + /// Provide a proxy for running the built target. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .bin("bin") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .run() + /// .unwrap(); + /// println!("artifact={}", run.path().display()); + /// ``` + pub fn run(self) -> CargoResult<CargoRun> { + let msgs = CommandMessages::with_command(self.cmd)?; + CargoRun::from_message(msgs, self.bin, self.example) + } + + /// Provide a proxy for running the built target. + /// + /// Required feature: `test_unstable` since the format parsed is unstable. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .test("test") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .run_tests().unwrap() + /// .next().unwrap().unwrap(); + /// println!("artifact={}", run.path().display()); + /// ``` + #[cfg(feature = "test_unstable")] + pub fn run_tests(self) -> CargoResult<impl Iterator<Item = Result<CargoTest, CargoError>>> { + let msgs = CommandMessages::with_command(self.cmd)?; + Ok(CargoTest::with_messages(msgs)) + } +} + +impl Default for CargoBuild { + fn default() -> Self { + Self::new() + } +} diff --git a/vendor/escargot/src/cargo.rs b/vendor/escargot/src/cargo.rs new file mode 100644 index 000000000..6e8efd220 --- /dev/null +++ b/vendor/escargot/src/cargo.rs @@ -0,0 +1,60 @@ +use std::env; +use std::ffi; +use std::process; +use std::str; + +use crate::build::CargoBuild; + +/// The current process' target triplet. +pub const CURRENT_TARGET: &str = include_str!(concat!(env!("OUT_DIR"), "/current_target.txt")); + +static CARBO_BIN: once_cell::sync::Lazy<ffi::OsString> = + once_cell::sync::Lazy::new(|| env::var_os("CARGO").unwrap_or_else(|| "cargo".into())); + +/// Top-level command. +#[derive(Debug)] +pub struct Cargo { + cmd: process::Command, +} + +impl Cargo { + /// Create a top-level command. + pub fn new() -> Self { + Self { + cmd: process::Command::new(CARBO_BIN.as_os_str()), + } + } + + /// Manually pass an argument that is unsupported. + /// + /// Caution: Passing in a sub-command or `--` can throw off the API. + pub fn arg<S: AsRef<ffi::OsStr>>(mut self, arg: S) -> Self { + self.cmd.arg(arg); + self + } + + /// Manually pass arguments that are unsupported. + /// + /// Caution: Passing in a sub-command or `--` can throw off the API. + pub fn args<I: IntoIterator<Item = S>, S: AsRef<ffi::OsStr>>(mut self, args: I) -> Self { + self.cmd.args(args); + self + } + + /// Run the `build` subcommand. + pub fn build(self) -> CargoBuild { + self.build_with("build") + } + + /// Run a custom `build` subcommand. + pub fn build_with<S: AsRef<ffi::OsStr>>(mut self, name: S) -> CargoBuild { + self.cmd.arg(name).arg("--message-format=json"); + CargoBuild::with_command(self.cmd) + } +} + +impl Default for Cargo { + fn default() -> Self { + Self::new() + } +} diff --git a/vendor/escargot/src/error.rs b/vendor/escargot/src/error.rs new file mode 100644 index 000000000..4f19c4013 --- /dev/null +++ b/vendor/escargot/src/error.rs @@ -0,0 +1,91 @@ +//! Error reporting API. + +use std::error::Error; +use std::fmt; + +/// Result of a cargo command. +pub type CargoResult<T> = Result<T, CargoError>; + +/// For programmatically processing failures. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum ErrorKind { + /// Spawning the cargo subommand failed. + InvalidCommand, + /// The cargo subcommand returned an error. + CommandFailed, + /// Parsing the cargo subcommand's output failed. + InvalidOutput, +} + +impl fmt::Display for ErrorKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self { + ErrorKind::InvalidOutput => write!(f, "Spawning the cargo subommand failed."), + ErrorKind::CommandFailed => write!(f, "The cargo subcommand returned an error."), + ErrorKind::InvalidCommand => write!(f, "Parsing the cargo subcommand's output failed."), + } + } +} + +/// Cargo command failure information. +#[derive(Debug)] +pub struct CargoError { + kind: ErrorKind, + context: Option<String>, + cause: Option<Box<dyn Error + Send + Sync + 'static>>, +} + +impl CargoError { + pub(crate) fn new(kind: ErrorKind) -> Self { + Self { + kind, + context: None, + cause: None, + } + } + + pub(crate) fn set_context<S>(mut self, context: S) -> Self + where + S: Into<String>, + { + let context = context.into(); + self.context = Some(context); + self + } + + pub(crate) fn set_cause<E>(mut self, cause: E) -> Self + where + E: Error + Send + Sync + 'static, + { + let cause = Box::new(cause); + self.cause = Some(cause); + self + } + + /// For programmatically processing failures. + pub fn kind(&self) -> ErrorKind { + self.kind + } +} + +impl Error for CargoError { + fn cause(&self) -> Option<&dyn Error> { + self.cause.as_ref().map(|c| { + let c: &dyn Error = c.as_ref(); + c + }) + } +} + +impl fmt::Display for CargoError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + writeln!(f, "Cargo command failed: {}", self.kind)?; + if let Some(ref context) = self.context { + writeln!(f, "{}", context)?; + } + if let Some(ref cause) = self.cause { + writeln!(f, "Cause: {}", cause)?; + } + Ok(()) + } +} diff --git a/vendor/escargot/src/format/diagnostic.rs b/vendor/escargot/src/format/diagnostic.rs new file mode 100644 index 000000000..0a2698d17 --- /dev/null +++ b/vendor/escargot/src/format/diagnostic.rs @@ -0,0 +1,158 @@ +//! This module contains `Diagnostic` and the types/functions it uses for deserialization. + +use std::borrow; +use std::path; + +type CowPath<'a> = borrow::Cow<'a, path::Path>; +type CowStr<'a> = borrow::Cow<'a, str>; + +/// The error code associated to this diagnostic. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +#[non_exhaustive] +pub struct DiagnosticCode<'a> { + /// The code itself. + #[serde(borrow)] + pub code: CowStr<'a>, + /// An explanation for the code + #[serde(borrow)] + pub explanation: Option<CowStr<'a>>, +} + +/// A line of code associated with the Diagnostic +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub text: CowStr<'a>, + /// Start of the section of the line to highlight. 1-based, character offset in self.text + pub highlight_start: usize, + /// End of the section of the line to highlight. 1-based, character offset in self.text + pub highlight_end: usize, +} + +/// Macro expansion information associated with a diagnostic. +#[derive(Debug, Clone, PartialEq, Eq, 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 + /// `span.expansion.is_some()`) + #[serde(borrow)] + pub span: DiagnosticSpan<'a>, + + /// name of macro that was applied (e.g., "foo!" or "#[derive(Eq)]") + #[serde(borrow)] + pub macro_decl_name: CowStr<'a>, + + /// span where macro was defined (if known) + #[serde(borrow)] + pub def_site_span: Option<DiagnosticSpan<'a>>, +} + +/// A section of the source code associated with a Diagnostic +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub file_name: CowPath<'a>, + /// The byte offset in the file where this diagnostic starts from. + pub byte_start: u32, + /// The byte offset in the file where this diagnostic ends. + pub byte_end: u32, + /// 1-based. The line in the file. + pub line_start: usize, + /// 1-based. The line in the file. + pub line_end: usize, + /// 1-based, character offset. + pub column_start: usize, + /// 1-based, character offset. + pub column_end: usize, + /// Is this a "primary" span -- meaning the point, or one of the points, + /// where the error occurred? + pub is_primary: bool, + /// Source text from the start of line_start to the end of line_end. + #[serde(borrow)] + pub text: Vec<DiagnosticSpanLine<'a>>, + /// Label that should be placed at this location (if any) + #[serde(borrow)] + pub label: Option<CowStr<'a>>, + /// If we are suggesting a replacement, this will contain text + /// that should be sliced in atop this span. + #[serde(borrow)] + pub suggested_replacement: Option<CowStr<'a>>, + /// If the suggestion is approximate + pub suggestion_applicability: Option<Applicability>, + /// Macro invocations that created the code at this span, if any. + #[serde(borrow)] + pub expansion: Option<Box<DiagnosticSpanMacroExpansion<'a>>>, +} + +/// Whether a suggestion can be safely applied. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub enum Applicability { + /// The suggested replacement can be applied automatically safely + MachineApplicable, + /// The suggested replacement has placeholders that will need to be manually + /// replaced. + HasPlaceholders, + /// The suggested replacement may be incorrect in some circumstances. Needs + /// human review. + MaybeIncorrect, + /// The suggested replacement will probably not work. + Unspecified, + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} + +/// A diagnostic message generated by rustc +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub message: CowStr<'a>, + /// The associated error code for this diagnostic + #[serde(borrow)] + pub code: Option<DiagnosticCode<'a>>, + /// The severity of the diagnostic. + pub level: DiagnosticLevel, + /// A list of source code spans this diagnostic is associated with. + #[serde(borrow)] + pub spans: Vec<DiagnosticSpan<'a>>, + /// Associated diagnostic messages. + #[serde(borrow)] + pub children: Vec<Diagnostic<'a>>, + /// The message as rustc would render it + #[serde(borrow)] + pub rendered: Option<CowStr<'a>>, +} + +/// The diagnostic level +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum DiagnosticLevel { + /// Internal compiler error + #[serde(rename = "error: internal compiler error")] + Ice, + /// Error + Error, + /// Warning + Warning, + /// Note + Note, + /// Help + Help, + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} diff --git a/vendor/escargot/src/format/mod.rs b/vendor/escargot/src/format/mod.rs new file mode 100644 index 000000000..9c9686139 --- /dev/null +++ b/vendor/escargot/src/format/mod.rs @@ -0,0 +1,266 @@ +//! Serialization formats for cargo messages. + +use std::borrow; +use std::path; + +pub mod diagnostic; + +#[cfg(feature = "test_unstable")] +pub mod test; + +type CowPath<'a> = borrow::Cow<'a, path::Path>; +type CowStr<'a> = borrow::Cow<'a, str>; + +/// A cargo message +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(tag = "reason", rename_all = "kebab-case")] +#[allow(clippy::large_enum_variant)] +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>), + /// The compiler wants to display a message + #[serde(borrow)] + CompilerMessage(FromCompiler<'a>), + /// A build script successfully executed. + #[serde(borrow)] + BuildScriptExecuted(BuildScript<'a>), + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} + +/// Build completed, all further output should not be parsed +#[derive(Debug, Clone, PartialEq, Eq, 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, PartialEq, Eq, 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)] + pub package_id: WorkspaceMember<'a>, + /// The full path to the artifact's manifest + #[serde(borrow)] + pub manifest_path: Option<CowPath<'a>>, + /// The target this artifact was compiled for + #[serde(borrow)] + pub target: Target<'a>, + /// The profile this artifact was compiled with + #[serde(borrow)] + pub profile: ArtifactProfile<'a>, + /// The enabled features for this artifact + #[serde(borrow)] + pub features: Vec<CowStr<'a>>, + /// The full paths to the generated artifacts + #[serde(borrow)] + pub filenames: Vec<CowPath<'a>>, + /// The full paths to the generated artifacts + #[serde(borrow)] + #[serde(default)] + pub executable: Option<CowPath<'a>>, + /// If true, then the files were already generated + pub fresh: bool, +} + +/// A single target (lib, bin, example, ...) provided by a crate +#[derive(Clone, PartialEq, Eq, 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)] + pub name: CowStr<'a>, + /// Kind of target ("bin", "example", "test", "bench", "lib") + #[serde(borrow)] + pub kind: Vec<CowStr<'a>>, + /// Almost the same as `kind`, except when an example is a library instead of an executable. + /// In that case `crate_types` contains things like `rlib` and `dylib` while `kind` is `example` + #[serde(default)] + #[serde(borrow)] + pub crate_types: Vec<CowStr<'a>>, + /// Whether this is a doctest or not + #[serde(default)] + pub doctest: Option<bool>, + /// Whether this is documentation or not + #[serde(default)] + pub doc: Option<bool>, + /// Whether this is a test file + #[serde(default)] + pub test: bool, + + #[serde(default)] + #[serde(rename = "required-features")] + /// This target is built only if these features are enabled. + /// It doesn't apply to `lib` targets. + #[serde(borrow)] + pub required_features: Vec<CowStr<'a>>, + /// Path to the main source file of the target + #[serde(borrow)] + pub src_path: CowPath<'a>, + /// Rust edition for this target + #[serde(default = "edition_default")] + #[serde(borrow)] + pub edition: CowStr<'a>, +} + +fn edition_default() -> CowStr<'static> { + "2015".into() +} + +/// A workspace member. This is basically identical to `cargo::core::package_id::PackageId`, except +/// that this does not use `Arc` internally. +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[serde(transparent)] +#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))] +pub struct WorkspaceMember<'a> { + /// The raw package id as given by cargo + #[serde(borrow)] + raw: CowStr<'a>, +} + +/// Profile settings used to determine which compiler flags to use for a +/// target. +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub opt_level: CowStr<'a>, + /// The amount of debug info. 0 for none, 1 for limited, 2 for full + pub debuginfo: Option<u32>, + /// State of the `cfg(debug_assertions)` directive, enabling macros like + /// `debug_assert!` + pub debug_assertions: bool, + /// State of the overflow checks. + pub overflow_checks: bool, + /// Whether this profile is a test + pub test: bool, +} + +/// Message left by the compiler +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub package_id: WorkspaceMember<'a>, + /// The full path to the artifact's manifest + #[serde(borrow)] + pub manifest_path: Option<CowPath<'a>>, + /// The target this message is aimed at + #[serde(borrow)] + pub target: Target<'a>, + /// The message the compiler sent. + #[serde(borrow)] + pub message: diagnostic::Diagnostic<'a>, +} + +/// Output of a Build Script execution. +#[derive(Debug, Clone, PartialEq, Eq, 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)] + pub package_id: WorkspaceMember<'a>, + /// The outdir used. + #[serde(borrow)] + #[serde(default)] + pub out_dir: Option<CowPath<'a>>, + /// The libs to link + #[serde(borrow)] + pub linked_libs: Vec<CowStr<'a>>, + /// The paths to search when resolving libs + #[serde(borrow)] + pub linked_paths: Vec<CowPath<'a>>, + /// The paths to search when resolving libs + #[serde(borrow)] + pub cfgs: Vec<CowPath<'a>>, + /// The environment variables to add to the compilation + #[serde(borrow)] + pub env: Vec<(CowStr<'a>, CowStr<'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,); + } + Message::CompilerMessage(ref comp) => { + let content = comp + .message + .rendered + .as_ref() + .map(|s| s.as_ref()) + .unwrap_or_else(|| comp.message.message.as_ref()); + match comp.message.level { + diagnostic::DiagnosticLevel::Ice => log::error!("{}", content), + diagnostic::DiagnosticLevel::Error => log::error!("{}", content), + diagnostic::DiagnosticLevel::Warning => log::warn!("{}", content), + diagnostic::DiagnosticLevel::Note => log::info!("{}", content), + diagnostic::DiagnosticLevel::Help => log::info!("{}", content), + #[cfg(not(feature = "strict_unstable"))] + _ => log::warn!("Unknown message: {:#?}", msg), + } + } + Message::BuildScriptExecuted(ref script) => { + log::trace!("Ran script from {:#?}", script.package_id); + } + #[cfg(not(feature = "strict_unstable"))] + _ => { + log::warn!("Unknown message: {:#?}", msg); + } + } +} + +#[cfg(feature = "print")] +pub(crate) fn log_message(msg: &Message<'_>) { + match msg { + Message::BuildFinished(ref finished) => { + eprintln!("Build Finished: {:?}", finished.success); + } + Message::CompilerArtifact(ref art) => { + eprintln!("Building {:#?}", art.package_id,); + } + Message::CompilerMessage(ref comp) => { + let content = comp + .message + .rendered + .as_ref() + .map(|s| s.as_ref()) + .unwrap_or_else(|| comp.message.message.as_ref()); + match comp.message.level { + diagnostic::DiagnosticLevel::Ice => eprintln!("{}", content), + diagnostic::DiagnosticLevel::Error => eprintln!("{}", content), + diagnostic::DiagnosticLevel::Warning => eprintln!("{}", content), + diagnostic::DiagnosticLevel::Note => eprintln!("{}", content), + diagnostic::DiagnosticLevel::Help => eprintln!("{}", content), + #[cfg(not(feature = "strict_unstable"))] + _ => eprintln!("Unknown message: {:#?}", msg), + } + } + Message::BuildScriptExecuted(ref script) => { + eprintln!("Ran script from {:#?}", script.package_id); + } + #[cfg(not(feature = "strict_unstable"))] + _ => { + eprintln!("Unknown message: {:#?}", msg); + } + } +} diff --git a/vendor/escargot/src/format/test.rs b/vendor/escargot/src/format/test.rs new file mode 100644 index 000000000..f046df9cf --- /dev/null +++ b/vendor/escargot/src/format/test.rs @@ -0,0 +1,242 @@ +//! Test runner emitted events. +//! +//! Required feature: `test_unstable` since the format parsed is unstable. + +use serde::Deserialize; + +// See https://github.com/rust-lang/rust/tree/master/src/libtest/formatters/json.rs + +/// Test-runner event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "type")] +pub enum Event { + /// Suite event. + Suite(Suite), + /// Test case event. + Test(Test), + /// Benchmark event. + Bench(Bench), + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} + +/// Suite event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "event")] +pub enum Suite { + /// Suite-started event. + Started(SuiteStarted), + /// Suite-finished successfully event. + Ok(SuiteOk), + /// Suite-finished with failure event. + Failed(SuiteFailed), + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} + +/// Suite-started event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct SuiteStarted { + /// Number of test cases in the suite. + pub test_count: usize, +} + +/// Suite-finished successfully event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct SuiteOk { + /// Cases that passed. + pub passed: usize, + /// Cases that failed. + pub failed: usize, + /// Cases that were allowed to fail. + pub allowed_fail: usize, + /// Ignored cases. + pub ignored: usize, + /// Benchmarks + pub measured: usize, + /// Cases filtered out by caller. + pub filtered_out: usize, +} + +/// Suite-finished with failure event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct SuiteFailed { + /// Cases that passed. + pub passed: usize, + /// Cases that failed. + pub failed: usize, + /// Cases that were allowed to fail. + pub allowed_fail: usize, + /// Ignored cases. + pub ignored: usize, + /// Benchmarks + pub measured: usize, + /// Cases filtered out by caller. + pub filtered_out: usize, +} + +/// Test case event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "event")] +pub enum Test { + /// Case-started event. + Started(TestStarted), + /// Case-finished successfully event. + Ok(TestOk), + /// Case-finished with failure event. + Failed(TestFailed), + /// Case-ignored event. + Ignored(TestIgnored), + /// Case-allowed-failure event. + AllowedFailure(TestAllowedFailured), + /// Case-timeout event. + Timeout(TestTimeout), + #[cfg(not(feature = "strict_unstable"))] + #[doc(hidden)] + #[serde(other)] + Unknown, +} + +/// Case-started event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestStarted { + /// Test case name. + pub name: String, +} + +/// Case-finished successfully event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestOk { + /// Test case name. + pub name: String, +} + +/// Case-finished with failure event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestFailed { + /// Test case name. + pub name: String, + /// Test's stdout + pub stdout: Option<String>, + /// Test failure mssage + pub message: Option<String>, +} + +/// Case-ignored event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestIgnored { + /// Test case name. + pub name: String, +} + +/// Case-allowed-failure event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestAllowedFailured { + /// Test case name. + pub name: String, +} + +/// Case-timeout event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct TestTimeout { + /// Test case name. + pub name: String, +} + +/// Benchmark event. +#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub struct Bench { + /// Benchmark name. + pub name: String, + /// Median performance. + pub median: usize, + /// Deviation from median. + pub deviation: usize, + /// Mb/s + pub mib_per_second: Option<usize>, +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn suite_started() { + let input = r#"{ "type": "suite", "event": "started", "test_count": 10 }"#; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn suite_ok() { + let input = "{ \"type\": \"suite\", \ + \"event\": \"ok\", \ + \"passed\": 6, \ + \"failed\": 5, \ + \"allowed_fail\": 4, \ + \"ignored\": 3, \ + \"measured\": 2, \ + \"filtered_out\": 1 }"; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn suite_failed() { + let input = "{ \"type\": \"suite\", \ + \"event\": \"failed\", \ + \"passed\": 6, \ + \"failed\": 5, \ + \"allowed_fail\": 4, \ + \"ignored\": 3, \ + \"measured\": 2, \ + \"filtered_out\": 1 }"; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn test_started() { + let input = r#"{ "type": "test", "event": "started", "name": "foo" }"#; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn test_timeout() { + let input = r#"{ "type": "test", "event": "timeout", "name": "foo" }"#; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn bench() { + let input = "{ \"type\": \"bench\", \ + \"name\": \"foo\", \ + \"median\": 10, \ + \"deviation\": 2 }"; + let _data: Event = serde_json::from_str(input).unwrap(); + } + + #[test] + fn bench_full() { + let input = "{ \"type\": \"bench\", \ + \"name\": \"foo\", \ + \"median\": 10, \ + \"deviation\": 2, \ + \"mib_per_second\": 1 }"; + let _data: Event = serde_json::from_str(input).unwrap(); + } +} diff --git a/vendor/escargot/src/lib.rs b/vendor/escargot/src/lib.rs new file mode 100644 index 000000000..dd6559131 --- /dev/null +++ b/vendor/escargot/src/lib.rs @@ -0,0 +1,59 @@ +//! # Escargot: A Cargo API +//! +//! ## Features +//! +//! Features: +//! - `print` for logged output to be printed instead, generally for test writing. +//! +//! ## Why escargot +//! +//! Compared to depending on `cargo`: +//! - Faster compile times. +//! - Simpler API. +//! - Better interop with projects relying on other cargo versions. +//! - Probably slower execution, especially on platforms without an optimized `fork` (e.g. Windows). +//! +//! ## Relevant crates +//! +//! Other related crates: +//! * [cargo](https://crates.io/crates/cargo) for the real thing +//! * [cargo-metadata](https://crates.io/crates/cargo_metadata) for a similar project specifically geared to the `metadata` subcommand. +//! +//! # Example +//! +//! ```rust +//! extern crate escargot; +//! extern crate assert_fs; +//! +//! let temp = assert_fs::TempDir::new().unwrap(); +//! escargot::CargoBuild::new() +//! .bin("bin") +//! .current_release() +//! .current_target() +//! .manifest_path("tests/fixtures/bin/Cargo.toml") +//! .target_dir(temp.path()) +//! .exec() +//! .unwrap(); +//! ``` + +#![warn(missing_docs)] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] + +#[macro_use] +extern crate serde; + +mod build; +pub use crate::build::*; +mod cargo; +pub use crate::cargo::*; +mod msg; +pub use crate::msg::*; +mod run; +pub use crate::run::*; +#[cfg(feature = "test_unstable")] +mod test; +#[cfg(feature = "test_unstable")] +pub use test::*; + +pub mod error; +pub mod format; diff --git a/vendor/escargot/src/msg.rs b/vendor/escargot/src/msg.rs new file mode 100644 index 000000000..b54a1d410 --- /dev/null +++ b/vendor/escargot/src/msg.rs @@ -0,0 +1,117 @@ +use std::io; +use std::io::BufRead; +use std::io::Read; +use std::process; + +use crate::error::*; +use crate::format; + +/// Messages returned from a cargo sub-command. +pub struct CommandMessages(InnerCommandMessages); + +struct InnerCommandMessages { + done: bool, + child: process::Child, + stdout: io::BufReader<process::ChildStdout>, + stderr: io::BufReader<process::ChildStderr>, +} + +impl CommandMessages { + /// Run the command, allowing iteration over ndjson messages. + pub fn with_command(mut cmd: process::Command) -> CargoResult<Self> { + let mut child = cmd + .stdout(process::Stdio::piped()) + .stderr(process::Stdio::piped()) + .spawn() + .map_err(|e| CargoError::new(ErrorKind::InvalidCommand).set_cause(e))?; + let stdout = child.stdout.take().expect("piped above"); + let stdout = io::BufReader::new(stdout); + let stderr = child.stderr.take().expect("piped above"); + let stderr = io::BufReader::new(stderr); + let msgs = InnerCommandMessages { + done: false, + child, + stdout, + stderr, + }; + Ok(CommandMessages(msgs)) + } + + #[inline] + fn next_msg(&mut self) -> CargoResult<Option<Message>> { + #![allow(clippy::branches_sharing_code)] + + let mut content = String::new(); + let len = self + .0 + .stdout + .read_line(&mut content) + .map_err(|e| CargoError::new(ErrorKind::InvalidOutput).set_cause(e))?; + if 0 < len { + Ok(Some(Message(content))) + } else { + let status = self + .0 + .child + .wait() + .map_err(|e| CargoError::new(ErrorKind::InvalidOutput).set_cause(e))?; + if !status.success() && !self.0.done { + self.0.done = true; + + let mut data = vec![]; + self.0 + .stderr + .read_to_end(&mut data) + .map_err(|e| CargoError::new(ErrorKind::InvalidOutput).set_cause(e))?; + let err = CargoError::new(ErrorKind::CommandFailed) + .set_context(String::from_utf8_lossy(&data)); + Err(err) + } else { + self.0.done = true; + Ok(None) + } + } + } +} + +impl Drop for CommandMessages { + fn drop(&mut self) { + if !self.0.done { + let _ = self.0.child.wait(); + } + } +} + +impl Iterator for CommandMessages { + type Item = CargoResult<Message>; + + #[inline] + fn next(&mut self) -> Option<CargoResult<Message>> { + match self.next_msg() { + Ok(Some(x)) => Some(Ok(x)), + Ok(None) => None, + Err(e) => Some(Err(e)), + } + } +} + +/// An individual message from a cargo sub-command. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Message(String); + +impl Message { + /// Deserialize the message. + pub fn decode(&self) -> CargoResult<format::Message<'_>> { + self.decode_custom() + } + + /// Deserialize the message. + pub fn decode_custom<'a, T>(&'a self) -> CargoResult<T> + where + T: serde::Deserialize<'a>, + { + let data = serde_json::from_str(self.0.as_str()) + .map_err(|e| CargoError::new(ErrorKind::InvalidOutput).set_cause(e))?; + Ok(data) + } +} diff --git a/vendor/escargot/src/run.rs b/vendor/escargot/src/run.rs new file mode 100644 index 000000000..e8aed96bb --- /dev/null +++ b/vendor/escargot/src/run.rs @@ -0,0 +1,195 @@ +use std::path; +use std::process; + +use crate::error::*; +use crate::format; +use crate::msg::*; + +/// The `run` subcommand (emulated). +/// +/// Created via [`CargoBuild::run`][crate::CargoBuild::run]. +/// +/// Benefits over spawning `cargo run`: +/// - Able to cache binary path, avoiding cargo overhead. +/// - Independent of CWD. +/// - stdout/stderr are clean of `cargo run` output. +/// +/// Relevant features +/// - `print` for logged output to be printed instead, generally for test writing. +/// +/// # Example +/// +/// To create a [`CargoRun`]: +/// ```rust +/// let temp = assert_fs::TempDir::new().unwrap(); +/// let run = escargot::CargoBuild::new() +/// .bin("bin") +/// .current_release() +/// .current_target() +/// .manifest_path("tests/fixtures/bin/Cargo.toml") +/// .target_dir(temp.path()) +/// .run() +/// .unwrap(); +/// println!("artifact={}", run.path().display()); +/// ``` +/// See [`CargoRun::path`] for how to then run the newly compiled +/// program. +pub struct CargoRun { + bin_path: path::PathBuf, +} + +impl CargoRun { + pub(crate) fn from_message( + msgs: CommandMessages, + is_bin: bool, + is_example: bool, + ) -> CargoResult<Self> { + let kind = match (is_bin, is_example) { + (true, true) => { + return Err(CargoError::new(ErrorKind::CommandFailed) + .set_context("Ambiguous which binary is intended, multiple selected")); + } + (false, true) => "example", + _ => "bin", + }; + let bin_path = extract_binary_path(msgs, kind)?; + Ok(Self { bin_path }) + } + + /// Path to the specified binary. + /// + /// This is to support alternative ways of launching the binary besides [`Command`]. + /// + /// # Example + /// + /// ```rust + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .bin("bin") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .run() + /// .unwrap(); + /// println!("artifact={}", run.path().display()); + /// ``` + /// or + /// ```rust,no_run + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .example("example_fixture") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .target_dir(temp.path()) + /// .run() + /// .unwrap(); + /// println!("artifact={}", run.path().display()); + /// ``` + /// + /// [`Command`]: std::process::Command + pub fn path(&self) -> &path::Path { + &self.bin_path + } + + /// Run the build artifact. + /// + /// # Example + /// + /// ```rust,no_run + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .bin("bin") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/bin/Cargo.toml") + /// .target_dir(temp.path()) + /// .run() + /// .unwrap() + /// .command() + /// .arg("--help") + /// .status() + /// .unwrap(); + /// ``` + /// or + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run = escargot::CargoBuild::new() + /// .example("example_fixture") + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/example/Cargo.toml") + /// .target_dir(temp.path()) + /// .run() + /// .unwrap() + /// .command() + /// .arg("--help") + /// .status() + /// .unwrap(); + /// ``` + pub fn command(&self) -> process::Command { + process::Command::new(self.path()) + } +} + +fn extract_bin<'a>(msg: &'a format::Message<'_>, desired_kind: &str) -> Option<&'a path::Path> { + match msg { + format::Message::CompilerArtifact(art) => { + if !art.profile.test + && art.target.crate_types == ["bin"] + && art.target.kind == [desired_kind] + { + Some(art.filenames.get(0).expect("files must exist")) + } else { + None + } + } + _ => None, + } +} + +fn transpose<T, E>(r: Result<Option<T>, E>) -> Option<Result<T, E>> { + match r { + Ok(Some(x)) => Some(Ok(x)), + Ok(None) => None, + Err(e) => Some(Err(e)), + } +} + +fn extract_binary_paths( + msgs: CommandMessages, + kind: &'static str, +) -> impl Iterator<Item = Result<path::PathBuf, CargoError>> { + msgs.filter_map(move |m| { + let m = m.and_then(|m| { + let m = m.decode()?; + format::log_message(&m); + let p = extract_bin(&m, kind).map(|p| p.to_path_buf()); + Ok(p) + }); + transpose(m) + }) +} + +fn extract_binary_path( + msgs: CommandMessages, + kind: &'static str, +) -> Result<path::PathBuf, CargoError> { + let bins: Result<Vec<_>, CargoError> = extract_binary_paths(msgs, kind).collect(); + let bins = bins?; + if bins.is_empty() { + return Err(CargoError::new(ErrorKind::CommandFailed).set_context("No binaries in crate")); + } else if bins.len() != 1 { + return Err( + CargoError::new(ErrorKind::CommandFailed).set_context(std::format!( + "Ambiguous which binary is intended: {:?}", + bins + )), + ); + } + Ok(bins.into_iter().next().expect("already validated")) +} diff --git a/vendor/escargot/src/test.rs b/vendor/escargot/src/test.rs new file mode 100644 index 000000000..5aebacfec --- /dev/null +++ b/vendor/escargot/src/test.rs @@ -0,0 +1,201 @@ +use std::path; +use std::process; + +use crate::error::*; +use crate::format; +use crate::msg::*; + +/// The `test` subcommand (emulated). +/// +/// Created via [`CargoBuild::run_tests`]. +/// +/// Benefits over spawning `cargo test`: +/// - Able to cache binary path, avoiding cargo overhead. +/// - Independent of CWD. +/// - stdout/stderr are clean of `cargo test` output. +/// +/// Required feature: `test_unstable` since the format parsed is unstable. +/// +/// Relevant features +/// - `print` for logged output to be printed instead, generally for test writing. +/// +/// # Example +/// +/// ```rust +/// extern crate escargot; +/// extern crate assert_fs; +/// +/// let temp = assert_fs::TempDir::new().unwrap(); +/// let run = escargot::CargoBuild::new() +/// .test("test") +/// .manifest_path("tests/fixtures/test/Cargo.toml") +/// .target_dir(temp.path()) +/// .run_tests().unwrap() +/// .next().unwrap().unwrap(); +/// println!("artifact={}", run.path().display()); +/// ``` +/// +/// [`CargoBuild::run_tests`]: crate::CargoBuild::run_tests() +pub struct CargoTest { + bin_path: path::PathBuf, + kind: String, + name: String, +} + +impl CargoTest { + pub(crate) fn with_messages( + msgs: CommandMessages, + ) -> impl Iterator<Item = Result<Self, CargoError>> { + extract_binary_paths(msgs) + } + + /// The `name` of test + /// + /// Used to offer filtering or displays. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run: Result<Vec<_>, _> = escargot::CargoBuild::new() + /// .tests() + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .run_tests() + /// .unwrap() + /// .collect(); + /// let run = run.unwrap(); + /// let mut names: Vec<_> = run.iter().map(|r| r.name()).collect(); + /// names.sort_unstable(); + /// assert_eq!(names, ["test", "test_fixture", "test_fixture"]); + /// ``` + pub fn name(&self) -> &str { + self.name.as_str() + } + + /// The `kind` of test + /// + /// Used to distinguish between integration tests (`test`) and unit tests (`bin`, `lib`). + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run: Result<Vec<_>, _> = escargot::CargoBuild::new() + /// .tests() + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .run_tests() + /// .unwrap() + /// .collect(); + /// let run = run.unwrap(); + /// let mut kinds: Vec<_> = run.iter().map(|r| r.kind()).collect(); + /// kinds.sort_unstable(); + /// assert_eq!(kinds, ["bin", "lib", "test"]); + /// ``` + pub fn kind(&self) -> &str { + self.kind.as_str() + } + + /// Path to the specified binary. + /// + /// This is to support alternative ways of launching the binary besides [`Command`]. + /// + /// # Example + /// + /// ```rust + /// extern crate escargot; + /// extern crate assert_fs; + /// + /// let temp = assert_fs::TempDir::new().unwrap(); + /// let run: Vec<_> = escargot::CargoBuild::new() + /// .tests() + /// .current_release() + /// .current_target() + /// .manifest_path("tests/fixtures/test/Cargo.toml") + /// .target_dir(temp.path()) + /// .run_tests() + /// .unwrap() + /// .collect(); + /// assert_eq!(run.len(), 3); + /// ``` + /// + /// [`Command`]: std::process::Command + pub fn path(&self) -> &path::Path { + &self.bin_path + } + + /// Run the build artifact. + pub fn command(&self) -> process::Command { + let mut cmd = process::Command::new(self.path()); + cmd.arg("-Z").arg("unstable-options").arg("--format=json"); + cmd + } + + /// Run the configured test, returning test events. + pub fn exec(&self) -> CargoResult<CommandMessages> { + CommandMessages::with_command(self.command()) + } +} + +fn extract_bin(msg: &format::Message<'_>) -> Option<CargoTest> { + match msg { + format::Message::CompilerArtifact(art) => { + if art.profile.test { + let bin_path = art + .filenames + .get(0) + .expect("files must exist") + .to_path_buf(); + let kind = art + .target + .kind + .get(0) + .expect("kind must exist") + .as_ref() + .to_owned(); + let name = art.target.name.as_ref().to_owned(); + Some(CargoTest { + bin_path, + kind, + name, + }) + } else { + None + } + } + _ => None, + } +} + +fn transpose<T, E>(r: Result<Option<T>, E>) -> Option<Result<T, E>> { + match r { + Ok(Some(x)) => Some(Ok(x)), + Ok(None) => None, + Err(e) => Some(Err(e)), + } +} + +fn extract_binary_paths( + msgs: CommandMessages, +) -> impl Iterator<Item = Result<CargoTest, CargoError>> { + msgs.filter_map(move |m| { + let m = m.and_then(|m| { + let m = m.decode()?; + format::log_message(&m); + let p = extract_bin(&m); + Ok(p) + }); + transpose(m) + }) +} diff --git a/vendor/escargot/tests/build.rs b/vendor/escargot/tests/build.rs new file mode 100644 index 000000000..d5e03a22a --- /dev/null +++ b/vendor/escargot/tests/build.rs @@ -0,0 +1,69 @@ +fn test_fixture(name: &str) { + let temp = assert_fs::TempDir::new().unwrap(); + + let msgs = escargot::CargoBuild::new() + .manifest_path(format!("tests/fixtures/{}/Cargo.toml", name)) + .current_release() + .current_target() + .target_dir(temp.path()) + .exec() + .unwrap(); + for msg in msgs { + let raw_msg = msg.unwrap(); + let msg = raw_msg.decode(); + match msg { + Ok(msg) => println!("{:#?}", msg), + Err(err) => panic!("{}\nmsg=`{:#?}`", err, raw_msg), + } + } +} + +#[test] +fn test_bin() { + test_fixture("bin"); +} + +#[test] +fn test_lib() { + test_fixture("lib"); +} + +#[test] +fn test_bin_lib() { + test_fixture("bin_lib"); +} + +#[test] +fn test_warn() { + test_fixture("warn"); +} + +#[test] +fn test_build_script() { + test_fixture("script"); +} + +#[test] +fn test_dependency() { + test_fixture("dep"); +} + +#[test] +fn test_error() { + let msgs: Vec<_> = escargot::CargoBuild::new() + .manifest_path("tests/fixtures/error/Cargo.toml") + .current_release() + .current_target() + .exec() + .unwrap() + .collect(); + assert!(1 < msgs.len()); + let error_idx = msgs.len() - 1; + for msg in &msgs[0..error_idx] { + let msg = msg.as_ref().unwrap(); + let msg = msg.decode().unwrap(); + println!("{:#?}", msg); + } + assert!(msgs[error_idx].is_err()); + println!("```{}```", msgs[error_idx].as_ref().err().unwrap()); +} |