Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pass a test name with special characters via an input file #1767

Closed
igor-akhmetov opened this issue Oct 7, 2019 · 11 comments
Closed
Labels

Comments

@igor-akhmetov
Copy link

I can't seem to pass the name of a test with special characters via an input file, specifically the one from CmdLine.tests.cpp:

TEST_CASE("Test with special, characters \"in name", "[cli][regression]") {
    // This test case succeeds if we can invoke it from the CLI
    SUCCEED();
}

--list-test-names-only outputs Test with special, characters "in name, which does not allow to run the test:

C:\src\Catch2\build\projects\Debug>SelfTest.exe -f tests.txt
Filters: "Test with special, characters "in name",
No test cases matched '"Test with special'
No test cases matched 'characters "in name"'
===============================================================================
No tests ran

I'd expect

Test with special\, characters \"in name

or

"Test with special\, characters \"in name"

to work, but they don't:

C:\src\Catch2\build\projects\Debug>SelfTest.exe -f tests.txt
Filters: "Test with special\, characters \"in name",
No test cases matched '"Test with special\, characters \"in name"'
===============================================================================
No tests ran


C:\src\Catch2\build\projects\Debug>SelfTest.exe -f tests.txt
Filters: "Test with special\, characters \"in name",
No test cases matched '"Test with special\, characters \"in name"'
===============================================================================
No tests ran
@amitherman95
Copy link
Contributor

Try updating the single header file by executing /scripts/generateSingleHeader.py

@igor-akhmetov
Copy link
Author

Same with names like vector<int,allocator> -> toString, escaping a comma in the input file does not seem to help.

@igor-akhmetov
Copy link
Author

@amitherman95 How is the single header relevant here? This is with the latest version of Catch2, I just grab the latest source, build, and run SelfTest.exe.

@amitherman95
Copy link
Contributor

Oh I see, I'll check it out

@echuber2
Copy link
Contributor

echuber2 commented Oct 8, 2019

I'm also experiencing this. Commas in test case names break stuff. This used to work in older versions of Catch (at least, it worked in v2.2.3). Now, with v2.9.2, it's causing issues. I do note that when I search through the v.2.9.2 catch.hpp file, there is one part that says:

// Applies the function macro f to each of the remaining parameters, inserts commas between the results,
// and passes userdata as the first parameter to each invocation,

I wonder if that's the problem, or if it's doing something else. For now I'm just going to avoid allowing commas in test case names. Colons and hyphens seem okay. I can't show the specific code I'm running unfortunately.

@echuber2
Copy link
Contributor

echuber2 commented Oct 8, 2019

Update: Semicolons also seem okay. For now I'll replace commas in test names with semicolons then.

@amitherman95
Copy link
Contributor

I found the cause of the problem, will upload PR later in the day

@amitherman95
Copy link
Contributor

That should fix the problem

@horenmar horenmar added the Bug label Oct 9, 2019
@horenmar
Copy link
Member

horenmar commented Oct 9, 2019

This is fixed in master now.

@horenmar horenmar closed this as completed Oct 9, 2019
@igor-akhmetov
Copy link
Author

Thanks a lot for the quick fix!
One note however: --list-test-names-only still does not quote special characters in test names, so "This makes it ideal for saving to a file and feeding back into the -f or --input-file option" from the documentation does not hold.
In general, am I correct that it's necessary to escape only '~', '"', ',', '[' and ']' characters in test names when feeding them back to Catch2 via an input file?

@horenmar
Copy link
Member

horenmar commented Oct 9, 2019

For the first, I'll have to think about it a bit -- I prefer to output human readable names to outputting round-trippable name (and the --list-test-names-only flag is going away anyway).

For the second, I cannot think of more right now, but it is important to note that * currently cannot be escaped (but you can have it as a part of a test name).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants