Skip to content

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

Description

@vlsi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions