def test_create_recipes(mocker, capsys): ''' Tests that `_create_recipes` correctly builds the recipe and extracts all of the dependencies from the conda_build render result. ''' mocker.patch( 'os.getcwd', return_value="/test/starting_dir" ) render_result=helpers.make_render_result("horovod", ['build_req1', 'build_req2 1.2'], ['run_req1 1.3'], ['host_req1 1.0', 'host_req2'], ['test_req1']) mocker.patch( 'conda_build.api.render', return_value=render_result ) mocker.patch( 'os.chdir', side_effect=(lambda x: helpers.validate_chdir(x, expected_dirs=["/test/my_repo", # First the working directory should be changed to the arg. "/test/starting_dir"])) # And then changed back to the starting directory. ) create_recipes_result = build_tree._create_recipes("/test/my_repo", None, "master", {'python' : ['3.6'], 'build_type' : ['cuda']}, []) assert create_recipes_result[0].packages == {'horovod'} for dep in {'build_req1', 'build_req2 1.2'}: assert dep in create_recipes_result[0].build_dependencies for dep in {'run_req1 1.3'}: assert dep in create_recipes_result[0].run_dependencies for dep in {'host_req1 1.0', 'host_req2'}: assert dep in create_recipes_result[0].host_dependencies for dep in {'test_req1'}: assert dep in create_recipes_result[0].test_dependencies
def test_create_commands(mocker): ''' Tests that `_create_commands` correctly builds the recipe and extracts all of the dependencies from the conda_build render result. ''' dir_tracker = helpers.DirTracker() mocker.patch('os.getcwd', return_value="/test/starting_dir") render_result = helpers.make_render_result( "horovod", ['build_req1', 'build_req2 1.2'], ['run_req1 1.3'], ['Host_req1 1.0', 'host_req2'], ['test_req1'], ['string1_1']) mocker.patch('conda_build.api.render', return_value=render_result) mocker.patch('conda_build.api.get_output_file_paths', return_value=['/output/path/linux/horovod.tar.gz']) mocker.patch( 'os.chdir', side_effect=( lambda x: dir_tracker.validate_chdir( x, expected_dirs=[ "/test/my_repo", # First the working directory should be changed to the arg. "/test/starting_dir" ])) # And then changed back to the starting directory. ) build_commands = [ x.build_command for x in build_tree._create_commands( "/test/my_repo", "True", "my_recipe_path", None, "main", { 'python': '3.6', 'build_type': 'cuda', 'mpi_type': 'openmpi', 'cudatoolkit': '10.2' }, []).nodes() ] assert build_commands[0].packages == ['horovod'] assert build_commands[0].recipe_path == "my_recipe_path" for dep in {'build_req1', 'build_req2 1.2'}: assert dep in build_commands[0].build_dependencies for dep in {'run_req1 1.3'}: assert dep in build_commands[0].run_dependencies for dep in {'host_req1 1.0', 'host_req2'}: assert dep in build_commands[0].host_dependencies for dep in {'test_req1'}: assert dep in build_commands[0].test_dependencies