approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
318 stars 51 forks source link

Missing newline characters in the single-header release #118

Closed claremacrae closed 4 years ago

claremacrae commented 4 years ago

When comparing the old single-header release file that was created with the Java program, and the new one created by Python, the diffs showed that there were some corrupted \n characters in at least some previous releases...

I've created this ticket to log the differences, to be able to include details in the next release notes.

There was also a missing \ continuation character in the middle of a macro.

claremacrae commented 4 years ago

Here are the snippets of code from the 8.4.0 release (created with the Java program) that differ when created with the new Python mechanism:

        static std::string topAndTailHelpMessage(const std::string& message)
        {
            const std::string lineBreak =
                "**************************************************************"
                "***************";
            const std::string lineBuffer =
                "*                                                             "
                "              *n";
            return lineBreak + 'n' + lineBuffer + message + lineBuffer +
                   lineBreak;
        }

    virtual void testRunEnded(Catch::TestRunStats const& testRunStats) override
    {
        bool commit = testRunStats.totals.testCases.allOk();
        std::string message = "r ";
        if (commit)
        {
            std::cout << "git add -A n";
            std::cout << "git commit -m " << message;
        }
        else
        {
            std::cout << "git clean -fd n";
            std::cout << "git reset --hard HEAD n";
        }
    }

#if !(__GNUC__ >= 9 or __clang_major__ >= 9)
#error                                                                         
    "The [Boost].UT integration with Approval Tests requires source_location support by the compiler"
#endif

Here are the corresponding lines when created by the Python script:

        static std::string topAndTailHelpMessage(const std::string& message)
        {
            const std::string lineBreak =
                "**************************************************************"
                "***************";
            const std::string lineBuffer =
                "*                                                             "
                "              *\n";
            return lineBreak + '\n' + lineBuffer + message + lineBuffer + lineBreak;
        }

    virtual void testRunEnded(Catch::TestRunStats const& testRunStats) override
    {
        bool commit = testRunStats.totals.testCases.allOk();
        std::string message = "r ";
        if (commit)
        {
            std::cout << "git add -A \n";
            std::cout << "git commit -m " << message;
        }
        else
        {
            std::cout << "git clean -fd \n";
            std::cout << "git reset --hard HEAD \n";
        }
    }

#if !(__GNUC__ >= 9 or __clang_major__ >= 9)
#error                                                                                   \
    "The [Boost].UT integration with Approval Tests requires source_location support by the compiler"
#endif

And here are the differences between the two:

8,10c8,9
<                 "              *n";
<             return lineBreak + 'n' + lineBuffer + message + lineBuffer +
<                    lineBreak;
---
>                 "              *\n";
>             return lineBreak + '\n' + lineBuffer + message + lineBuffer + lineBreak;
13,14c12,13
<         virtual void testRunEnded(Catch::TestRunStats const& testRunStats) override
<         {
---
>     virtual void testRunEnded(Catch::TestRunStats const& testRunStats) override
>     {
19,20c18,19
<         std::cout << "git add -A n";
<         std::cout << "git commit -m " << message;
---
>             std::cout << "git add -A \n";
>             std::cout << "git commit -m " << message;
24,26c23,24
<         std::cout << "git clean -fd n";
<         std::cout << "git reset --hard HEAD n";
<         }
---
>             std::cout << "git clean -fd \n";
>             std::cout << "git reset --hard HEAD \n";
27a26
>     }
31c30
<         #error
---
> #error                                                                                   \
claremacrae commented 4 years ago

(my editing to strip back the differences probably introduced some white-space changes before creating the diff)

claremacrae commented 4 years ago

The new release process has been merged, so this is now fixed.