trybuild | Test harness for ui tests of compiler diagnostics | Testing library

 by   dtolnay Rust Version: 1.0.80 License: Apache-2.0

kandi X-RAY | trybuild Summary

kandi X-RAY | trybuild Summary

trybuild is a Rust library typically used in Testing applications. trybuild has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

[] [] [] [] Trybuild is a test harness for invoking rustc on a set of test cases and asserting that any resulting error messages are the ones intended. . Such tests are commonly useful for testing error reporting involving procedural macros. We would write test cases triggering either errors detected by the macro or errors detected by the Rust compiler in the resulting expanded code, and compare against the expected errors to ensure that they remain user-friendly. This style of testing is sometimes called ui tests because they test aspects of the user’s interaction with a library outside of what would be covered by ordinary API tests. Nothing here is specific to macros; trybuild would work equally well for testing misuse of non-macro APIs.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              trybuild has a low active ecosystem.
              It has 610 star(s) with 57 fork(s). There are 9 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 10 open issues and 104 have been closed. On average issues are closed in 255 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of trybuild is 1.0.80

            kandi-Quality Quality

              trybuild has no bugs reported.

            kandi-Security Security

              trybuild has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              trybuild is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              trybuild releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of trybuild
            Get all kandi verified functions for this library.

            trybuild Key Features

            No Key Features are available at this moment for trybuild.

            trybuild Examples and Code Snippets

            No Code Snippets are available at this moment for trybuild.

            Community Discussions

            QUESTION

            How do I use an iterator twice inside of the quote! macro?
            Asked 2021-Jan-08 at 16:32

            I'm trying to implement the builder pattern from the proc macro workshop I'm creating a proc macro which parses a struct, extracts its name, field_names and field_types. It should reproduce the struct itself and also create a builder struct with the same field_names but with optional types.

            My problem is that field_name and field_type are iterators that I would have to use twice in order to create two structs out of one.

            This is my source tree

            ...

            ANSWER

            Answered 2021-Jan-06 at 21:28

            Iterators can only be used zero or one time, not multiple; that's standard Rust and doesn't involve the quote! macro:

            Source https://stackoverflow.com/questions/65603440

            QUESTION

            Unit testing Rust Syn crate
            Asked 2020-Dec-12 at 20:46

            From the Syn documentation:

            Syn operates on the token representation provided by the proc-macro2 crate from crates.io rather than using the compiler's built in proc-macro crate directly. This enables code using Syn to execute outside of the context of a procedural macro, such as in unit tests or build.rs

            I am trying to enable unit testing for some Syn functions, however I can't get it to work no matter what I have tried. It does not work with the proc_macro2::TokenStream type, but it won't work with the proc_macro::TokenStream because we are not in a proc-macro context.

            link to playground

            ...

            ANSWER

            Answered 2020-Dec-12 at 20:46

            It does not work with the proc_macro2::TokenStream type, but it won't work with the proc_macro::TokenStream because we are not in a proc-macro context.

            Yes, and that's the whole point! Crates that export procedural macros can't export anything else, but proc_macro can only be used in crates that export macros. This is the reason why proc_macro2 exists in the first place.

            You need to use multiple crates in order to write tests for code that uses syn and proc_macro2:

            • Your public crate that declares the macros with #[proc_macro] etc., and does very little except convert a proc_macro::TokenStream into a proc_macro2::TokenStream and vice versa.
            • An "internal" crate, containing most of the actual code, which depends on proc_macro2 but not proc_macro. Your tests can go in here.

            The error you are seeing is because syn::parse accepts a proc_macro::TokenStream. You can instead use syn::parse2, which is identical except that it accepts a proc_macro2::TokenStream.

            Source https://stackoverflow.com/questions/65269173

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install trybuild

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/dtolnay/trybuild.git

          • CLI

            gh repo clone dtolnay/trybuild

          • sshUrl

            git@github.com:dtolnay/trybuild.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link