-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce commentCharacter
property in @Csv{File}Source
#5031
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
base: main
Are you sure you want to change the base?
Introduce commentCharacter
property in @Csv{File}Source
#5031
Conversation
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvReaderFactory.java
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
@sbrannen, I’d like to update the User Guide and Release Notes, but other than that, it’s ready. UPD The User Guide and Release Notes updated ✔️ |
@marcphilipp, @sbrannen, I'm a bit confused 😅 . According to the compatibility scan, this new method is a source-incompatible change, even though it has a default value: char commentCharacter() default '#'; Could you take a look? ![]() |
Looks like that's a false-positive reported by japicmp: I hope that we can switch to roseau soon (see #5010) because it seems to be more precise. For now, I just pushed a commit adding the two new attributes to the list of "accepted breaking changes" even though we know they're not actually breaking. |
* ❓ | ||
* A regression introduced in version 6.0.0 caused an exception when using the | ||
`@CsvSource` or `@CsvFileSource` annotations when the `delimiter` or | ||
`delimiterString` attribute was set to #. This occurred because `#` was used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`delimiterString` attribute was set to #. This occurred because `#` was used | |
`delimiterString` attribute was set to `#`. This occurred because `#` was used |
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvFileSource.java
Outdated
Show resolved
Hide resolved
junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java
Outdated
Show resolved
Hide resolved
Ahhh, good that that's already been reported. 👍
🤞
Oh man... I literally did that at the same time as you (perhaps even before you), but I was away from the computer and came back to find you'd already pushed the same fix. 😆 Though, I sorted the entries alphabetically. 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking very good! 👍
I've requested a few minor changes.
* A regression introduced in version 6.0.0 caused an exception when using the | ||
`@CsvSource` or `@CsvFileSource` annotations when the `delimiter` or | ||
`delimiterString` attribute was set to #. This occurred because `#` was used | ||
as the default comment character without an option to change it. | ||
To resolve this, a new `commentCharacter` attribute has been added to both | ||
annotations. Its default value remains `#`, but it can now be customized | ||
to avoid conflicts with other control characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* A regression introduced in version 6.0.0 caused an exception when using the | |
`@CsvSource` or `@CsvFileSource` annotations when the `delimiter` or | |
`delimiterString` attribute was set to #. This occurred because `#` was used | |
as the default comment character without an option to change it. | |
To resolve this, a new `commentCharacter` attribute has been added to both | |
annotations. Its default value remains `#`, but it can now be customized | |
to avoid conflicts with other control characters. | |
* A regression introduced in version 6.0.0 caused an exception when using `@CsvSource` or | |
`@CsvFileSource` if the `delimiter` or `delimiterString` attribute was set to `+++#+++`. | |
This occurred because `+++#+++` was used as the default comment character without an | |
option to change it. To resolve this, a new `commentCharacter` attribute has been added | |
to both annotations. Its default value remains `+++#+++`, but it can now be customized | |
to avoid conflicts with other control characters. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
org.junit.jupiter.params.provider.CsvSource#commentCharacter | ||
org.junit.jupiter.params.provider.CsvFileSource#commentCharacter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.junit.jupiter.params.provider.CsvSource#commentCharacter | |
org.junit.jupiter.params.provider.CsvFileSource#commentCharacter | |
org.junit.jupiter.params.provider.CsvFileSource#commentCharacter | |
org.junit.jupiter.params.provider.CsvSource#commentCharacter |
Sort alphabetically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* | ||
* <p>Any line beginning with a {@code #} symbol will be interpreted as a comment | ||
* and will be ignored. | ||
* <p>Any line beginning with a {@link #commentCharacter()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* <p>Any line beginning with a {@link #commentCharacter()} | |
* <p>Any line beginning with a {@linkplain #commentCharacter() comment character} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbrannen, what do you think about keeping {@link ...}
here for consistency with how the other attributes are described?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Consistency is king. 👍🏻
* <p>The comment character must be the first character on the line without | ||
* any leading whitespace. | ||
* | ||
* <p>Defaults to a hashtag {@code #}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* <p>Defaults to a hashtag {@code #}. | |
* <p>Defaults to {@code '#'}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
validateControlCharactersDiffer( | ||
delimiter, csvFileSource.quoteCharacter(), csvFileSource.commentCharacter(), commentStrategy | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateControlCharactersDiffer( | |
delimiter, csvFileSource.quoteCharacter(), csvFileSource.commentCharacter(), commentStrategy | |
); | |
validateControlCharactersDiffer( | |
delimiter, csvFileSource.quoteCharacter(), csvFileSource.commentCharacter(), commentStrategy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* <p>The comment character must be the first character on the line without | ||
* any leading whitespace. | ||
* | ||
* <p>Defaults to a hashtag {@code #}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* <p>Defaults to a hashtag {@code #}. | |
* <p>Defaults to {@code '#'}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
jupiter-tests/src/test/java/org/junit/jupiter/params/provider/CsvArgumentsProviderTests.java
Outdated
Show resolved
Hide resolved
? builder.delimiter(c).build() // | ||
: builder.delimiterString(delimiter.toString()).build(); | ||
|
||
var message = "delimiter or delimiterString: '%s', and quoteCharacter: '%s' must differ"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var message = "delimiter or delimiterString: '%s', and quoteCharacter: '%s' must differ"; | |
var message = "delimiter or delimiterString: '%s' and quoteCharacter: '%s' must differ"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
|
||
@Test | ||
void doesNotThrowExceptionWhenDelimiterAndCommentCharacterTheSameWhenUsingValueAttribute() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void doesNotThrowExceptionWhenDelimiterAndCommentCharacterTheSameWhenUsingValueAttribute() { | |
void doesNotThrowExceptionWhenDelimiterAndCommentCharacterAreTheSameWhenUsingValueAttribute() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
@ParameterizedTest | ||
@MethodSource("invalidDelimiterQuoteCharacterAndCommentCharacterCombinations") | ||
void throwsExceptionWhenControlCharactersTheSameWhenUsingTextBlockAttribute(Object delimiter, char quoteCharacter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void throwsExceptionWhenControlCharactersTheSameWhenUsingTextBlockAttribute(Object delimiter, char quoteCharacter, | |
void throwsExceptionWhenControlCharactersAreTheSameWhenUsingTextBlockAttribute(Object delimiter, char quoteCharacter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"looses" -> "loses"
below which demonstrates formatting similar to a table). | ||
comments. Any line beginning with the value of the `commentCharacter` attribute (`+++#+++` | ||
by default) will be treated as a comment and ignored. Note that there is one exception | ||
to this rule: if the comment character appears within a quoted field, it looses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to this rule: if the comment character appears within a quoted field, it looses | |
to this rule: if the comment character appears within a quoted field, it loses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* | ||
* <p>Any line that begins with this character will be treated as a comment | ||
* and ignored during parsing. Note that there is one exception to this rule: | ||
* if the comment character appears within a quoted field, it looses its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* if the comment character appears within a quoted field, it looses its | |
* if the comment character appears within a quoted field, it loses its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
* | ||
* <p>Any line that begins with this character will be treated as a comment | ||
* and ignored during parsing. Note that there is one exception to this rule: | ||
* if the comment character appears within a quoted field, it looses its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* if the comment character appears within a quoted field, it looses its | |
* if the comment character appears within a quoted field, it loses its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I hereby agree to the terms of the JUnit Contributor License Agreement.
#5028
Definition of Done
@API
annotations