Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
adt fixes for maven and noninteractive deb install #305
Conversation
elopio
reviewed
Feb 6, 2016
| + ' <nonProxyHosts>.internal</nonProxyHosts>\n' + \ | ||
| + ' </proxy>\n' + \ | ||
| + ' </proxies>\n' + \ | ||
| + '</settings>\n' |
elopio
Feb 6, 2016
Member
If you put this string inside parentheses, you don't need the \ nor the +, which I find really useful.
There's also the option of using three quotes and textwrap.dedent, which I don't like that much but it's common.
elopio
reviewed
Feb 6, 2016
| + proxy = urlparse(os.environ['http_proxy']) | ||
| + if not os.path.exists(os.path.dirname(settings_path)): | ||
| + cls.addCleanup(os.rmdir, os.path.dirname(settings_path)) | ||
| + os.makedirs(os.path.dirname(settings_path), exist_ok=True) |
elopio
reviewed
Feb 6, 2016
| + os.makedirs(os.path.dirname(settings_path), exist_ok=True) | ||
| + with open(settings_path, 'w') as f: | ||
| + f.write(_MVN_SETTINGS.format(proxy.hostname, proxy.port)) | ||
| + self.addCleanup(os.remove, settings_path) |
elopio
Feb 6, 2016
Member
We can start moving common helpers to snapcraft/tests/utils, or you can turn this into a fixture and put it in snapcraft/tests/fixture_setup.
I think we shouldn't duplicate things, even if they are in different suites. That makes the suite rely on the snapcraft library, not just the snapcraft binary, but that's ok for me. What do you think?
|
Thanks a lot for working on this, because I made no useful progress... |
|
Looks good to me! |
elopio
reviewed
Feb 10, 2016
| @@ -16,6 +16,7 @@ | ||
| import logging | ||
| import os | ||
| +import os.path |
elopio
reviewed
Feb 10, 2016
| @@ -42,6 +43,26 @@ | ||
| logger = logging.getLogger(__name__) | ||
| +_MVN_SETTINGS = ( |
elopio
Feb 10, 2016
Member
A nit, I find it useful to suffix the format constants so it's easier to know that they need an argument.
Like _MVN_SETTINGS_FORMAT.
elopio
reviewed
Feb 10, 2016
| + plugin = maven.MavenPlugin('test-part', self.options) | ||
| + os.makedirs(plugin.sourcedir) | ||
| + glob_mock.return_value = [ | ||
| + os.path.join(plugin.builddir, 'target', 'fake')] |
elopio
Feb 10, 2016
Member
You are not using this value in the test, it seems it's just needed to be able to test the the call to run. To make that clear I usually call the value 'dummy' instead of 'fake'.
elopio
reviewed
Feb 10, 2016
| + settings_path = os.path.join(plugin.partdir, 'm2', 'settings.xml') | ||
| + os.makedirs(plugin.sourcedir) | ||
| + glob_mock.return_value = [ | ||
| + os.path.join(plugin.builddir, 'target', 'fake')] |
elopio
reviewed
Feb 10, 2016
| + | ||
| +def _get_no_proxy_string(): | ||
| + no_proxy = [k.strip() for k in | ||
| + os.environ.get('no_proxy', 'localhost').split(',')] |
elopio
Feb 10, 2016
Member
You are missing tests for when no_proxy has one value, and when it has multiple values.
|
Thanks for adding this. I'm |
elopio
reviewed
Feb 10, 2016
| + self.addCleanup(os.environ.update, env_copy) | ||
| + | ||
| + os.environ['SNAPCRAFT_SETUP_PROXIES'] = '1' | ||
| + os.environ['http_proxy'] = 'http://localhost:3132' |
elopio
Feb 10, 2016
Member
Oh, one more. This will pollute the environ for the following tests.
Use self.useFixture(fixtures.EnvironmentVariable(var, value))
|
Tests passed and we have +0.6%. Merging... |
sergiusens commentedFeb 5, 2016
This makes sure we setup noninteractive for deb installation and
also sets up the proxy configuration for maven.
LP: #1542511
Signed-off-by: Sergio Schvezov sergio.schvezov@ubuntu.com