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

refactor(tests): fix conflict of variable scope by renaming local variables during upgrade of groovy 3.x #1341

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

j-sandy
Copy link
Contributor

@j-sandy j-sandy commented Sep 21, 2023

While upgrading groovy 3.0.10 and spockframework 2.0-groovy-3.0, encountered the following errors in groovy test compilation of echo-core and echo-notifications modules:

startup failed:
/echo/echo-core/src/test/groovy/com/netflix/spinnaker/echo/notification/AbstractEventNotificationAgentSpec.groovy: 42: The current scope already contains a variable of the name event
 @ line 42, column 43.
   Mock.sendNotifications(*_) >> { notifica
                                 ^
1 error
> Task :echo-core:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 50: The current scope already contains a variable of the name status
 @ line 50, column 31.
       github.updateCheck(*_) >> { token, repo, sha, status ->
                                 ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED

startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 99: The current scope already contains a variable of the name status
 @ line 99, column 31.
       github.updateCheck(*_) >> { token, repo, sha, status ->
                                 ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name webhookURL
 @ line 63, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name message
 @ line 63, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
2 errors
> Task :echo-notifications:compileTestGroovy FAILED

> Task :echo-notifications:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 92: The current scope already contains a variable of the name webhookURL
 @ line 92, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
1 error
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 36: The current scope already contains a variable of the name channel
 @ line 36, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED

> Task :echo-notifications:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name message
 @ line 62, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name channel
 @ line 62, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
2 errors

startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 91: The current scope already contains a variable of the name channel
 @ line 91, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED

To fix this issue renamed the local variables to avoid the scope conflict with global variables.

…iables during upgrade of groovy 3.x

While upgrading groovy 3.0.10 and spockframework 2.0-groovy-3.0, encountered the following errors in groovy test compilation of echo-core and echo-notifications modules:

```
startup failed:
/echo/echo-core/src/test/groovy/com/netflix/spinnaker/echo/notification/AbstractEventNotificationAgentSpec.groovy: 42: The current scope already contains a variable of the name event
 @ line 42, column 43.
   Mock.sendNotifications(*_) >> { notifica
                                 ^
1 error
> Task :echo-core:compileTestGroovy FAILED
```

```
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 50: The current scope already contains a variable of the name status
 @ line 50, column 31.
       github.updateCheck(*_) >> { token, repo, sha, status ->
                                 ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED

startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 99: The current scope already contains a variable of the name status
 @ line 99, column 31.
       github.updateCheck(*_) >> { token, repo, sha, status ->
                                 ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED
```

```
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name webhookURL
 @ line 63, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name message
 @ line 63, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
2 errors
> Task :echo-notifications:compileTestGroovy FAILED

> Task :echo-notifications:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 92: The current scope already contains a variable of the name webhookURL
 @ line 92, column 35.
       googleChat.sendMessage(*_) >> { webhookURL, message ->
                                     ^
1 error
```

```
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 36: The current scope already contains a variable of the name channel
 @ line 36, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED

> Task :echo-notifications:compileTestGroovy FAILED
startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name message
 @ line 62, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name channel
 @ line 62, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
2 errors

startup failed:
/echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 91: The current scope already contains a variable of the name channel
 @ line 91, column 30.
       slack.sendMessage(*_) >> { message, channel, asUser ->
                                ^
1 error
> Task :echo-notifications:compileTestGroovy FAILED
```

To fix this issue renamed the local variables to avoid the scope confilct with global variables.
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Sep 21, 2023
@mergify mergify bot added the auto merged label Sep 21, 2023
@mergify mergify bot merged commit a6e00b2 into spinnaker:master Sep 21, 2023
5 checks passed
@j-sandy j-sandy deleted the refactor-test branch September 21, 2023 18:41
j-sandy added a commit to j-sandy/echo that referenced this pull request Oct 6, 2023
…iables during upgrade of groovy 3.x

Rectification w.r.t variable named `event` in [PR](spinnaker#1341) of AbstractEventNotificationAgentSpec.groovy class.
mergify bot pushed a commit that referenced this pull request Oct 6, 2023
…iables during upgrade of groovy 3.x (#1351)

Rectification w.r.t variable named `event` in [PR](#1341) of AbstractEventNotificationAgentSpec.groovy class.
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 this pull request may close these issues.

3 participants