Skip to content

Fix test fail triggered by multiline environment variables #2875

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

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented Sep 8, 2020

Fix TestProcess.test_passthrough_environment fails when an environment variable has multiple lines.

Fix `test_passthrough_environment` fails when an environment variable
has multiple lines
@stevapple
Copy link
Contributor Author

This is going to fix TestFoundation failures on Azure CI for Windows builds.

CC @compnerd

@MaxDesiatov
Copy link
Contributor

@swift-ci please test

@stevapple
Copy link
Contributor Author

The Linux test failed, but the failure seems not caused by this change... Could you find the root of it? @MaxDesiatov 😂

@MaxDesiatov
Copy link
Contributor

@swift-ci please test

@stevapple
Copy link
Contributor Author

Can anyone merge this? I’d like to see the effect on Azure CI.

@MaxDesiatov

@compnerd
Copy link
Member

compnerd commented Sep 9, 2020

Thanks for looking into this @stevapple. Can you expand the commit message to explain why multi line values don't work? https://docs.microsoft.com/en-us/windows/win32/procthread/environment-variables doesn't seem to indicate the restriction.

@stevapple
Copy link
Contributor Author

stevapple commented Sep 9, 2020

@compnerd It’s not a problem of Windows actually.

First of all, Azure CI environment sometimes contains multiline environment variables, which is really a rare case. The former handler of --env simply print("\(key)=\(value)"), and the parser parses every single line of the output as "key=value", so any extra lines in an environment variable will lead to an error, thus failing the test. What I’m going to do is removing all the newlines characters from value, then the problem will go.

@compnerd
Copy link
Member

compnerd commented Sep 9, 2020

I guess the question is why does this not impact other platforms? I assume that it is an issue only because it is splitting on the newline?

@stevapple
Copy link
Contributor Author

It’s because multiline environment variable is really a rare case. A regular machine won’t have that. Azure CI is triggering it because it stores the latest commit message in an environment variable.

I believe the problem will also occur if we manually set an environment variable with multiple lines on Linux and macOS.

@compnerd
Copy link
Member

Then, why should this not apply to all targets instead of being windows only? The problem exists in all of the cases it sounds like,

@stevapple
Copy link
Contributor Author

The patch is applied to all platforms. The #if os(Windows) mark here is to make sure the test is meaningful on Windows because whatever subprocess on Windows will have at least one environment variable.

@millenomi millenomi merged commit a69879f into swiftlang:master Sep 10, 2020
@stevapple stevapple deleted the multiline-env branch September 11, 2020 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants