Skip to content
This repository
Browse code

Merge pull request #360 from g2p/develop

Increase coverage, refactor cli-building, close #358
  • Loading branch information...
commit 3bc37626ab8655f113bbc958369e4522135dbcc2 2 parents 6a984b4 + 0bd111c
Paul Nasrat authored November 23, 2012

Showing 2 changed files with 36 additions and 24 deletions. Show diff stats Hide diff stats

  1. 15  .travis.yml
  2. 45  virtualenv.py
15  .travis.yml
@@ -6,12 +6,21 @@ python:
6 6
   - "3.2"
7 7
   - "pypy"
8 8
 install:
9  
-  - pip install --use-mirrors nose
  9
+  - pip install --use-mirrors nose coverage
10 10
 script:
  11
+  - coverage erase
11 12
 # Unit tests
12  
-  - python setup.py test
  13
+  - coverage run -a setup.py test
13 14
 # Integration test
14  
-  - python virtualenv.py --distribute ./test-venv
  15
+  - coverage run -a virtualenv.py --distribute ./test-venv-01
  16
+# Another integration test, where we must download
  17
+  - cp -t bin virtualenv.py; coverage run -a bin/virtualenv.py --distribute ./test-venv-02
  18
+# Also test with setuptools if we are on Python 2
  19
+  - python -c 'import sys; sys.exit(0 if sys.version_info >= (3,) else 1)' || coverage run -a virtualenv.py --setuptools ./test-venv-03
  20
+# Setuptools + download
  21
+  - python -c 'import sys; sys.exit(0 if sys.version_info >= (3,) else 1)' || coverage run -a bin/virtualenv.py --setuptools ./test-venv-04
  22
+# How was our test coverage?
  23
+  - coverage report --show-missing
15 24
 notifications:
16 25
   irc:
17 26
     channels: "irc.freenode.org#pip"
45  virtualenv.py
@@ -505,6 +505,9 @@ def _install_req(py_executable, unzip=False, distribute=False,
505 505
             bootstrap_script = DISTRIBUTE_FROM_EGG_PY
506 506
         else:
507 507
             # Fall back to sdist
  508
+            # NB: egg_path is not None iff tgz_path is None
  509
+            # iff bootstrap_script is a generic setup script accepting
  510
+            # the standard arguments.
508 511
             egg_path = None
509 512
             tgz_path = 'distribute-*.tar.gz'
510 513
             found, tgz_path = _find_file(tgz_path, search_dirs)
@@ -534,28 +537,28 @@ def _install_req(py_executable, unzip=False, distribute=False,
534 537
             env['PYTHONPATH'] = egg_path + os.path.pathsep + os.environ['PYTHONPATH']
535 538
         else:
536 539
             env['PYTHONPATH'] = egg_path
537  
-    else:
  540
+    elif tgz_path is not None and os.path.exists(tgz_path):
538 541
         # Found a tgz source dist, let's chdir
539  
-        if tgz_path is not None and os.path.exists(tgz_path):
540  
-            logger.info('Using existing %s egg: %s' % (project_name, tgz_path))
541  
-            os.chdir(os.path.dirname(tgz_path))
542  
-            # in this case, we want to be sure that PYTHONPATH is unset (not
543  
-            # just empty, really unset), else CPython tries to import the
544  
-            # site.py that it's in virtualenv_support
545  
-            remove_from_env.append('PYTHONPATH')
546  
-        else:
547  
-            if never_download:
548  
-                logger.fatal("Can't find any local distributions of %s to install "
549  
-                             "and --never-download is set.  Either re-run virtualenv "
550  
-                             "without the --never-download option, or place a %s "
551  
-                             "distribution (%s) in one of these "
552  
-                             "locations: %r" % (project_name, project_name,
553  
-                                                egg_path or tgz_path,
554  
-                                                search_dirs))
555  
-                sys.exit(1)
556  
-
557  
-            logger.info('No %s egg found; downloading' % project_name)
558  
-            cmd.extend(['--always-copy', '-U', project_name])
  542
+        logger.info('Using existing %s egg: %s' % (project_name, tgz_path))
  543
+        os.chdir(os.path.dirname(tgz_path))
  544
+        # in this case, we want to be sure that PYTHONPATH is unset (not
  545
+        # just empty, really unset), else CPython tries to import the
  546
+        # site.py that it's in virtualenv_support
  547
+        remove_from_env.append('PYTHONPATH')
  548
+    elif never_download:
  549
+        logger.fatal("Can't find any local distributions of %s to install "
  550
+                     "and --never-download is set.  Either re-run virtualenv "
  551
+                     "without the --never-download option, or place a %s "
  552
+                     "distribution (%s) in one of these "
  553
+                     "locations: %r" % (project_name, project_name,
  554
+                                        egg_path or tgz_path,
  555
+                                        search_dirs))
  556
+        sys.exit(1)
  557
+    elif egg_path:
  558
+        logger.info('No %s egg found; downloading' % project_name)
  559
+        cmd.extend(['--always-copy', '-U', project_name])
  560
+    else:
  561
+        logger.info('No %s tgz found; downloading' % project_name)
559 562
     logger.start_progress('Installing %s...' % project_name)
560 563
     logger.indent += 2
561 564
     cwd = None

0 notes on commit 3bc3762

Please sign in to comment.
Something went wrong with that request. Please try again.