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

Unable to mock 'bat' step if 'label' contains Unicode character #130

Open
mdealer opened this issue Jul 26, 2022 · 0 comments
Open

Unable to mock 'bat' step if 'label' contains Unicode character #130

mdealer opened this issue Jul 26, 2022 · 0 comments

Comments

@mdealer
Copy link

mdealer commented Jul 26, 2022

Expected Behavior

Proper Unicode handling and mock of the step.

Actual Behavior

It does not mock the step.

Steps to Reproduce

  1. Create a Jenkins Shared Groovy Library
  2. Implement some function to be called later that contains a 'bat' step with a 'label' that contains a Unicode char.
  3. Add tests using jenkins-spock and mock the 'bat' step

Additional Information

The bat step in question is roughly:
output = script.bat script: '@echo off && aaa aaaaaaaaa aaaaaaaaaaaaaaaaa@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa', returnStdout: true, encoding: 'UTF-8', label: 'Batch Script (💻myhostname)'

The setup function / test class is roughly:
import com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification

class createBuilderSpec extends JenkinsPipelineSpecification {
    def setup() {
        // ...
        getPipelineMock('bat')([returnStdout: true, script: 'hostname']) >> 'myhostname' // Some other step which just works fine
	getPipelineMock("bat")([script:'@echo off && aaa aaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa', returnStdout:true, encoding:'UTF-8', label:'Batch Script (💻myhostname)']) >> 'someresult'
         // ...
    }
// ...

Spock does not handle the Unicode character, I can see it in the console:

10:11:07.598 [main] DEBUG com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification - TEST FIXTURE intercepted & redirected a call:
	Test         : class com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
	Note         : pipeline step 
	Via          : [email protected]
	    (types)  : createBuilder.methodMissing
	Invocation   : [email protected]([[script:@echo off && aaa aaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa, returnStdout:true, encoding:UTF-8, label:Batch Script (­ƒÆ╗myhostname)]])
	    (types)  : createBuilder.bat(Object[])
	Forwarded To : Mock for type 'Closure' named 'getPipelineMock("bat")'.call([script:aaa aaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaa, returnStdout:true, encoding:UTF-8, label:Batch Script (­ƒÆ╗myhostname)])
	    (types)  : Closure$$EnhancerByCGLIB$$923b74da.call(LinkedHashMap)

As long as the character is in there, the mock is not actually called and the 'bat' step returns null.

I'm on Windows with Java 11 64-bit and Groovy 2.4.12.

Having Unicode in Strings works fine in Jenkins.

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

No branches or pull requests

1 participant