Repository: conda/conda-build

Issue:
3.12.1 upgrade breaks conda build --test with explicit pre-built file
When testing a package with
`conda build --test path_to_built_package`, conda buiild returns and "Unsatisfiable dependency warning. For a minimal working example:

```yaml
# recipe/meta.yaml
package:
    name: test
    version: 1

test:
    commands:
        - echo hi
```

```bash
mkdir out
conda build --no-test --output-folder=out recipe
conda built --test out/linux-64/test*
```

### Actual Behavior

Fails with 
```
Solving environment: ...working... failed
failed to get install actions, retrying.  exception was: Unsatisfiable dependencies for platform linux-64: {'test==1=0'}
WARNING:conda_build.build:failed to get install actions, retrying.  exception was: Unsatisfiable dependencies for platform linux-64: {'test==1=0'}
```

### Expected Behavior

Tests pass (works with conda-build 3.12.0)

### Steps to Reproduce

See above


##### `Output of conda info`
<!-- Between the ticks below, paste the output of 'conda info' -->
```
     active environment : base
    active env location : /home/steven/miniconda3
            shell level : 1
       user config file : /home/steven/.condarc
 populated config files : 
          conda version : 4.5.9
    conda-build version : 3.12.1
         python version : 3.6.5.final.0
       base environment : /home/steven/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /home/steven/miniconda3/pkgs
                          /home/steven/.conda/pkgs
       envs directories : /home/steven/miniconda3/envs
                          /home/steven/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.9 requests/2.11.1 CPython/3.6.5 Linux/4.17.11-arch1 arch/ glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
```




Discussion:
Can't reproduce:

```
 msarahan@0109-msarahan-2  ~/code  conda build --no-test --output-folder out test_test
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Attempting to finalize metadata for test
INFO:conda_build.metadata:Attempting to finalize metadata for test
BUILD START: ['test-1-0.tar.bz2']
source tree in: /Users/msarahan/miniconda3/conda-bld/test_1534784101575/work
Packaging test
INFO:conda_build.build:Packaging test
Packaging test-1-0
INFO:conda_build.build:Packaging test-1-0
No files or script found for output test
WARNING:conda_build.build:No files or script found for output test
number of files: 0
Fixing permissions
Importing conda-verify failed.  Please be sure to test your packages.  conda install conda-verify to make this message go away.
WARNING:conda_build.build:Importing conda-verify failed.  Please be sure to test your packages.  conda install conda-verify to make this message go away.
updating: test-1-0.tar.bz2
Renaming work directory,  /Users/msarahan/miniconda3/conda-bld/test_1534784101575/work  to  /Users/msarahan/miniconda3/conda-bld/test_1534784101575/work_moved_test-1-0_osx-64_main_build_loop
# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload out/osx-64/test-1-0.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []
####################################################################################
Resource usage summary:

Total time: 0:00:00.8
CPU usage: sys=0:00:00.0, user=0:00:00.0
Maximum memory usage observed: 0B
Total disk usage observed (not including envs): 0B


####################################################################################
Source and build intermediates have been left in /Users/msarahan/miniconda3/conda-bld.
There are currently 233 accumulated.
To remove them, you can run the ```conda build purge``` command
 msarahan@0109-msarahan-2  ~/code  ls -la out/osx-64
total 72
drwxr-xr-x  9 msarahan  staff   288 Aug 20 11:55 .
drwxr-xr-x  4 msarahan  staff   128 Aug 20 11:55 ..
-rw-r--r--  1 msarahan  staff  9384 Aug 20 11:55 .about.json
-rw-r--r--  1 msarahan  staff   410 Aug 20 11:55 .index.json
-rw-r--r--  1 msarahan  staff    71 Aug 20 11:55 .paths.json
-rw-r--r--  1 msarahan  staff   286 Aug 20 11:55 .recipe.json
-rw-r--r--  1 msarahan  staff   418 Aug 20 11:55 repodata.json
-rw-r--r--  1 msarahan  staff   280 Aug 20 11:55 repodata.json.bz2
-rw-r--r--  1 msarahan  staff  3973 Aug 20 11:55 test-1-0.tar.bz2
 msarahan@0109-msarahan-2  ~/code  conda build -t out/osx-64/test-1-0.tar.bz2
TEST START: out/osx-64/test-1-0.tar.bz2
Updating index at /Users/msarahan/code/out/osx-64 to make package installable with dependencies
INFO:conda_build.build:Updating index at /Users/msarahan/code/out/osx-64 to make package installable with dependencies
Updating index at /Users/msarahan/code/out/noarch to make package installable with dependencies
INFO:conda_build.build:Updating index at /Users/msarahan/code/out/noarch to make package installable with dependencies
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Adding in variants from /var/folders/94/cb44zrcj06n_vj5zgxvjpb0h0000gp/T/tmpf14g0vne/info/recipe/conda_build_config.yaml
INFO:conda_build.variants:Adding in variants from /var/folders/94/cb44zrcj06n_vj5zgxvjpb0h0000gp/T/tmpf14g0vne/info/recipe/conda_build_config.yaml
Renaming work directory,  /Users/msarahan/miniconda3/conda-bld/test_1534784124602/work  to  /Users/msarahan/miniconda3/conda-bld/test_1534784124602/work_moved_test-1-0_osx-64
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/msarahan/miniconda3/conda-bld/test_1534784124602/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold


The following NEW packages will be INSTALLED:

    test: 1-0 local

Preparing transaction: ...working... done
Executing transaction: ...working... done
+ echo hi
hi
+ exit 0

Resource usage statistics from testing test:
   Process count: 1
   CPU time: Sys=0:00:00.0, User=0:00:00.0
   Memory: 1.3M
   Disk usage: 16B
   Time elapsed: 0:00:02.0

TEST END: out/osx-64/test-1-0.tar.bz2
--dirty flag and --keep-old-work not specified. Removing build/test folder after successful build/test.

INFO:conda_build.config:--dirty flag and --keep-old-work not specified. Removing build/test folder after successful build/test.

All tests passed


####################################################################################
Source and build intermediates have been left in /Users/msarahan/miniconda3/conda-bld.
There are currently 234 accumulated.
To remove them, you can run the ```conda build purge``` command
```
Interesting. I wonder if it's a linux specific bug?

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -1771,6 +1771,8 @@ def _construct_metadata_for_test_from_package(package, config):
     # HACK: because the recipe is fully baked, detecting "used" variables no longer works.  The set
     #     of variables in the hash_input suffices, though.
     metadata.config.used_vars = list(hash_input.keys())
+    metadata.config.channel_urls = list(utils.ensure_list(metadata.config.channel_urls))
+    metadata.config.channel_urls.insert(0, url_path(local_channel))
     return metadata, hash_input
 
 
@@ -1938,6 +1940,7 @@ def test(recipedir_or_package_or_metadata, config, stats, move_broken=True):
                 else metadata.config.host_subdir)
     # ensure that the test prefix isn't kept between variants
     utils.rm_rf(metadata.config.test_prefix)
+
     try:
         actions = environ.get_install_actions(metadata.config.test_prefix,
                                                 tuple(specs), 'host',


Test patch: