diff --git a/README.md b/README.md index 1a73b7e0..3056232d 100644 --- a/README.md +++ b/README.md @@ -238,8 +238,13 @@ Optional. Shell command to run tests after the build. The wheel will be installed automatically and available for import from the tests. `{project}` can be used as a placeholder for the absolute path to the project's root and will be replaced by `cibuildwheel`. +On Linux and Mac, the command runs in a shell, so you can write things like `cmd1 && cmd2`. + Example: `nosetests {project}/tests` +Platform-specific variants also available: +`CIBW_TEST_COMMAND_MACOS` | `CIBW_TEST_COMMAND_WINDOWS` | `CIBW_TEST_COMMAND_LINUX` + | Environment variable: `CIBW_TEST_REQUIRES` | --- @@ -250,6 +255,9 @@ Space-separated list of dependencies required for running the tests. Example: `pytest` Example: `nose==1.3.7 moto==0.4.31` +Platform-specific variants also available: +`CIBW_TEST_REQUIRES_MACOS` | `CIBW_TEST_REQUIRES_WINDOWS` | `CIBW_TEST_REQUIRES_LINUX` + -- #### Example YML syntax diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 775a20e2..1a9e3c5e 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -6,7 +6,7 @@ import cibuildwheel.linux, cibuildwheel.windows, cibuildwheel.macos from cibuildwheel.environment import parse_environment, EnvironmentParseError from cibuildwheel.util import BuildSkipper -def get_option_from_environment(option_name, platform=None): +def get_option_from_environment(option_name, platform=None, default=None): ''' Returns an option from the environment, optionally scoped by the platform. @@ -21,7 +21,7 @@ def get_option_from_environment(option_name, platform=None): if option is not None: return option - return os.environ.get(option_name) + return os.environ.get(option_name, default) def main(): @@ -70,13 +70,13 @@ def main(): exit(2) output_dir = args.output_dir - test_command = os.environ.get('CIBW_TEST_COMMAND', None) - test_requires = os.environ.get('CIBW_TEST_REQUIRES', '').split() + test_command = get_option_from_environment('CIBW_TEST_COMMAND', platform=platform) + test_requires = get_option_from_environment('CIBW_TEST_REQUIRES', platform=platform, default='').split() project_dir = args.project_dir before_build = get_option_from_environment('CIBW_BEFORE_BUILD', platform=platform) - build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform) or '' + build_verbosity = get_option_from_environment('CIBW_BUILD_VERBOSITY', platform=platform, default='') skip_config = os.environ.get('CIBW_SKIP', '') - environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform) or '' + environment_config = get_option_from_environment('CIBW_ENVIRONMENT', platform=platform, default='') try: build_verbosity = min(3, max(-3, int(build_verbosity))) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 4d6f3565..09db2030 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -128,7 +128,7 @@ def build(project_dir, package_name, output_dir, test_command, test_requires, be # (this ensures that Python runs the tests against the installed wheel # and not the repo code) test_command_prepared = prepare_command(test_command, project=abs_project_dir) - call(shlex.split(test_command_prepared), cwd=os.environ['HOME'], env=env) + call(test_command_prepared, cwd=os.environ['HOME'], env=env, shell=True) # we're all done here; move it to output shutil.move(delocated_wheel, output_dir) diff --git a/test/02_test/environment.json b/test/02_test/environment.json index a9b6ac2b..3a541dd4 100644 --- a/test/02_test/environment.json +++ b/test/02_test/environment.json @@ -1,4 +1,6 @@ { "CIBW_TEST_REQUIRES": "nose", - "CIBW_TEST_COMMAND": "nosetests {project}/test" + "CIBW_TEST_COMMAND": "false || nosetests {project}/test", + "comment": "The 'false ||' bit is to ensure this command runs in a shell on Mac and Linux", + "CIBW_TEST_COMMAND_WINDOWS": "nosetests {project}/test" }