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

Spock does not work in tr_TR locale: Unrecognized block label: given @ line 31, column 13. #1414

Closed
vlsi opened this issue Jan 15, 2022 · 0 comments · Fixed by #1418
Closed
Labels

Comments

@vlsi
Copy link

vlsi commented Jan 15, 2022

Describe the bug

Spock fails with tr_TR locale:

D:\a\jmeter\jmeter\src\core\src\test\groovy\org\apache\jmeter\engine\util\FunctionParserSpec.groovy: 31: Unrecognized block label: given @ line 31, column 13.
               CompoundVariable.functions.put('__func', Func.class)
               ^

It blocks JMeter testing :-/
apache/jmeter#693

Reason:
Spock uses .toLowerCase() for BlockParseInfo:

public String toString() {
return super.toString().toLowerCase();
}

The lookup fails here:

if (!label.equals(blockInfo.toString())) continue;
checkIsValidSuccessor(method, blockInfo, stat.getLineNumber(), stat.getColumnNumber());
Block block = blockInfo.addNewBlock(method);
String description = getDescription(stat);
if (description == null)
block.getAst().add(stat);
else
block.getDescriptions().add(description);
return block;
}
throw new InvalidSpecCompileException(stat, "Unrecognized block label: " + label);

Sample code in question (I believe it does not matter):

import org.apache.jmeter.functions.Function
import org.apache.jmeter.samplers.SampleResult
import org.apache.jmeter.samplers.Sampler

import spock.lang.Specification
import spock.lang.Unroll

@Unroll
class FunctionParserSpec extends Specification {
    def "function '#value' gets compiled"() {
        given:
            CompoundVariable.functions.put('__func', Func.class)
            def parser = new FunctionParser()
        when:
            def result = parser.compileString(value)
        then:
            "$result" == "$expected"
        where:
            value           | expected
            '${__func()}'   | [new Func()]
            '${ __func()}'  | [new Func()]
            '${__func() }'  | [new Func()]
            '${ __func() }' | [new Func()]
    }

To Reproduce

run any Spock test with -Duser.country=TR -Duser.language=tr

Expected behavior

tr_TR should be supported

Actual behavior

Unrecognized block label: given @ line 31, column 13

Java version

8, 11, 17

Buildtool version

Gradle 7.3

What operating system are you using

Windows

Dependencies

I believe it is irrelevant

Additional context

No response

@vlsi vlsi added the bug label Jan 15, 2022
vlsi added a commit to vlsi/selenide that referenced this issue Jan 16, 2022
This enables significantly improve test coverage while still keeping test feedback fast and easy configuration.

For example, this matrix captures locale-dependent issues like spockframework/spock#1414

The idea is that you declare test axis like `os`, `java`, `java_distribution`, `timezone`, `locale`, etc, and `matrix.js` produces several jobs for you.

See https://github.com/vlsi/github-actions-random-matrix

Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
vlsi added a commit to vlsi/selenide that referenced this issue Jan 16, 2022
This enables significantly improve test coverage while still keeping test feedback fast and easy configuration.

For example, this matrix captures locale-dependent issues like spockframework/spock#1414

The idea is that you declare test axis like `os`, `java`, `java_distribution`, `timezone`, `locale`, etc, and `matrix.js` produces several jobs for you.

See https://github.com/vlsi/github-actions-random-matrix

Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
vlsi added a commit to vlsi/selenide that referenced this issue Jan 16, 2022
This enables significantly improve test coverage while still keeping test feedback fast and easy configuration.

For example, this matrix captures locale-dependent issues like spockframework/spock#1414

The idea is that you declare test axis like `os`, `java`, `java_distribution`, `timezone`, `locale`, etc, and `matrix.js` produces several jobs for you.

See https://github.com/vlsi/github-actions-random-matrix

Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
vlsi added a commit to vlsi/selenide that referenced this issue Jan 16, 2022
This enables significantly improve test coverage while still keeping test feedback fast and easy configuration.

For example, this matrix captures locale-dependent issues like spockframework/spock#1414

The idea is that you declare test axis like `os`, `java`, `java_distribution`, `timezone`, `locale`, etc, and `matrix.js` produces several jobs for you.

See https://github.com/vlsi/github-actions-random-matrix

Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
leonard84 added a commit to leonard84/spock that referenced this issue Jan 21, 2022
Prior to this commit, there were several instances of toLowerCase()/toUpperCase()
using the default locale, this causes issues in certain locales like tr_TR.
To fis this, we declare Locale.ROOT should be used in those cases.

fixes spockframework#1414
leonard84 added a commit that referenced this issue Feb 16, 2022
Prior to this commit, there were several instances of toLowerCase()/toUpperCase()
using the default locale, this causes issues in certain locales like tr_TR.
To fix this, we declare Locale.ROOT should be used in those cases.

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

Successfully merging a pull request may close this issue.

1 participant