From 34e8ee0f25c5898005212819176057c2084fa062 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Wed, 6 Sep 2017 18:35:42 +0100 Subject: [PATCH] Fix empty env string case --- cibuildwheel/environment.py | 3 +++ unit_test/environment_test.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cibuildwheel/environment.py b/cibuildwheel/environment.py index 1e236d67..1b2adec4 100644 --- a/cibuildwheel/environment.py +++ b/cibuildwheel/environment.py @@ -28,6 +28,9 @@ def split_env_items(env_string): >>> split_env_items('PATH2="something with spaces"') ['PATH2="something with spaces"'] ''' + if not env_string: + return [] + command_node = bashlex.parsesingle(env_string) result = [] diff --git a/unit_test/environment_test.py b/unit_test/environment_test.py index 6b538a4d..0f0f385e 100644 --- a/unit_test/environment_test.py +++ b/unit_test/environment_test.py @@ -66,3 +66,19 @@ def test_empty_var(): assert environment_dict == {'CFLAGS': ''} assert environment_cmds == ['export CFLAGS='] + +def test_no_vars(): + environment_recipe = parse_environment('') + + environment_dict = environment_recipe.as_dictionary(prev_environment={}) + environment_cmds = environment_recipe.as_shell_commands() + + assert environment_dict == {} + assert environment_cmds == [] + +def test_no_vars_pass_through(): + environment_recipe = parse_environment('') + + environment_dict = environment_recipe.as_dictionary(prev_environment={'CIBUILDWHEEL': 'awesome'}) + + assert environment_dict == {'CIBUILDWHEEL': 'awesome'}