Repository: conda/conda-build

Issue:
OSError when copying test files in 3.1.1
Hi, when updating from 3.0.31 to 3.1.1, one of our recipes has started to fail. It fails to copy over test files associated with a recipe and raises an OSError on the copy operation. We are not sure the reason. The Travis job in question is: 

https://travis-ci.org/bccp/conda-channel-bccp/jobs/313297979

and the recipe in question is here: https://github.com/bccp/conda-channel-bccp/tree/master/platform/mpich

The traceback is: 
```

Traceback (most recent call last):
  File "/home/travis/miniconda/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 388, in main
    execute(sys.argv[1:])
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 379, in execute
    verify=args.verify)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/api.py", line 187, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/build.py", line 1839, in build_tree
    test(pkg, config=metadata.config)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/build.py", line 1525, in test
    create_all_test_files(metadata)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/create_test.py", line 256, in create_all_test_files
    files = create_files(m, test_dir)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/create_test.py", line 38, in create_files
    clobber=True)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/utils.py", line 220, in copy_into
    _copy_with_shell_fallback(src, dst_fn)
  File "/home/travis/miniconda/lib/python3.6/site-packages/conda_build/utils.py", line 153, in _copy_with_shell_fallback
    raise OSError("Failed to copy {} to {}.  Error was: {}".format(src, dst, e))
OSError: Failed to copy /tmp/tmpw2dggv7m/info/recipe/tests/helloworld.c to /home/travis/miniconda/conda-bld/mpich_1512703292871/test_tmp/tests/helloworld.c.  Error was: Command 'cp -a /tmp/tmpw2dggv7m/info/recipe/tests/helloworld.c /home/travis/miniconda/conda-bld/mpich_1512703292871/test_tmp/tests/helloworld.c' returned non-zero exit status 1.
```

cc @rainwoodman 


Discussion:
Thanks for reporting.  I'll try to reproduce and fix before the next release.
This is happening because it is copying your files directly into the recipe folder, not creating the tests subfolder:

```
OSError: Failed to copy /tmp/tmpqgege8uc/info/recipe/tests/helloworld.c to /opt/conda/conda-bld/mpich_1512798465689/test_tmp/tests/helloworld.c.  Error was: Command 'cp -a /tmp/tmpqgege8uc/info/recipe/tests/helloworld.c /opt/conda/conda-bld/mpich_1512798465689/test_tmp/tests/helloworld.c' returned non-zero exit status 1.
[root@51d2cdeaf431 code]# ls /tmp/tmpqgege8uc/info/
about.json       git              has_prefix       LICENSE.txt      recipe/
files            hash_input.json  index.json       paths.json       test/
[root@51d2cdeaf431 code]# ls /tmp/tmpqgege8uc/info/recipe/
build.sh                 helloworld.cxx           meta.yaml                run_test.sh
conda_build_config.yaml  helloworld.f             meta.yaml.template
helloworld.c             helloworld.f90           no-nonblock.py
```

Should be a reasonably quick fix.

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -220,7 +220,7 @@ def copy_recipe(m):
                 file_paths = []
 
         for f in file_paths:
-            utils.copy_into(os.path.join(src_dir, f), recipe_dir,
+            utils.copy_into(join(src_dir, f), join(recipe_dir, f),
                             timeout=output_metadata.config.timeout,
                             locking=output_metadata.config.locking, clobber=True)
 


Test patch: