Repository: conda/conda-build

Issue:
Packages with malformed version and tests build infinitely in a loop
If I build the recipe:

````
package:
    name: mypackage
    version: ".0.wqqw"

source:
    file: .

build:
    command: echo

test:
    commands:
        - echo
````

It starts building again immediately after it finishes:

````
$ conda build .
BUILD START: mypackage-.0.wqqw-0
Package: mypackage-.0.wqqw-0
source tree in: /home/zah/anaconda3/conda-bld/pkg_1482102768196/work
number of files: 0
Fixing permissions
Fixing permissions
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating: mypackage-.0.wqqw-0.tar.bz2
TEST START: mypackage-.0.wqqw-0
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating index in: /home/zah/anaconda3/conda-bld/noarch
# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload /home/zah/anaconda3/conda-bld/linux-64/mypackage-.0.wqqw-0.tar.bz2
#
# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

BUILD START: mypackage-.0.wqqw-0
Package: mypackage-.0.wqqw-0
source tree in: /home/zah/anaconda3/conda-bld/pkg_1482102771898/work
number of files: 0
Fixing permissions
Fixing permissions
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating: mypackage-.0.wqqw-0.tar.bz2
TEST START: mypackage-.0.wqqw-0
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating index in: /home/zah/anaconda3/conda-bld/noarch
# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload /home/zah/anaconda3/conda-bld/linux-64/mypackage-.0.wqqw-0.tar.bz2
#
# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

BUILD START: mypackage-.0.wqqw-0
Package: mypackage-.0.wqqw-0
source tree in: /home/zah/anaconda3/conda-bld/pkg_1482102775221/work
number of files: 0
Fixing permissions
Fixing permissions
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating: mypackage-.0.wqqw-0.tar.bz2
TEST START: mypackage-.0.wqqw-0
updating index in: /home/zah/anaconda3/conda-bld/linux-64
updating index in: /home/zah/anaconda3/conda-bld/noarch
# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload /home/zah/anaconda3/conda-bld/linux-64/mypackage-.0.wqqw-0.tar.bz2
#
# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

BUILD START: mypackage-.0.wqqw-0
Package: mypackage-.0.wqqw-0
````
and so on. This happens if:

 - The recipe has some tests.
 - The recipe has a malformed version (starting with dot), which can happen for example if `git describe --tag` fails for some reason and part of the version string gets sliced.


Discussion:

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -546,6 +546,7 @@ def version(self):
         if res is None:
             sys.exit("Error: package/version missing in: %r" % self.meta_path)
         check_bad_chrs(res, 'package/version')
+        assert not res.startswith('.'), "Version can't start with leading period -  got %s" % res
         return res
 
     def build_number(self):


Test patch:
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -1,6 +1,8 @@
 import os
 import unittest
 
+import pytest
+
 from conda_build.conda_interface import MatchSpec
 
 from conda_build.metadata import select_lines, handle_config_version, expand_globs
@@ -108,3 +110,8 @@ def test_numpy(self):
                           handle_config_version,
                           MatchSpec('numpy x.x'), None)
 
+
+def test_disallow_leading_period_in_version(test_metadata):
+    test_metadata.meta['package']['version'] = '.ste.ve'
+    with pytest.raises(AssertionError):
+        test_metadata.version()