holger krekel avatar holger krekel committed 1637a9b

fixes issue 7.

implement a "minversion" directive to allow for
specifying a required tox version

Comments (0)

Files changed (7)

 List of optional global options::
 
     [tox]
+    minversion=ver    # minimally required tox version
     toxworkdir=path   # tox working directory, defaults to {toxinidir}/.tox
     setupdir=path     # defaults to {toxinidir}
     distdir=path      # defaults to {toxworkdir}/dist
    changelog
    links
    announce/release-0.5
+   announce/release-1.0
 
 
 .. include:: links.txt

tests/test_cmdline.py

         "*created sdist package at*",
     ])
 
+def test_minversion(cmd, initproj):
+    initproj("interp123-0.5", filedefs={
+        'tests': {'test_hello.py': "def test_hello(): pass"},
+        'tox.ini': '''
+            [tox]
+            minversion = 6.0
+        '''
+    })
+    result = cmd.run("tox", "-v")
+    result.stdout.fnmatch_lines([
+        "*ERROR*tox version is * required is at least 6.0*"
+    ])
+    assert result.ret
+
 def test_unknown_interpreter(cmd, initproj):
     initproj("interp123-0.5", filedefs={
         'tests': {'test_hello.py': "def test_hello(): pass"},

tests/test_config.py

                 bp = "python%s.%s" %(name[2], name[3])
                 assert env.basepython == bp
 
+    def test_minversion(self, tmpdir, newconfig, monkeypatch):
+        inisource = """
+            [tox]
+            minversion = 3.0
+        """
+        config = newconfig([], inisource)
+        assert config.minversion == "3.0"
+
     def test_defaultenv_commandline(self, tmpdir, newconfig, monkeypatch):
         config = newconfig(["-epy24"], "")
         env = config.envconfigs['py24']
 commands=
     py.test -v \
         --junitxml={envlogdir}/junit-{envname}.xml \
-        check_sphinx.py
+        check_sphinx.py []
     def runcommand(self):
         #tw.sep("-", "tox info from %s" % self.options.configfile)
         self.report.using("tox-%s from %s" %(tox.__version__, tox.__file__))
+        if self.config.minversion:
+            minversion = NormalizedVersion(self.config.minversion)
+            toxversion = NormalizedVersion(tox.__version__)
+            #self.report.using("requires at least %s" %(minversion,))
+            if toxversion < minversion:
+                self.report.error(
+                    "tox version is %s, required is at least %s" %(
+                       toxversion, minversion))
+                raise SystemExit(1)
         if self.config.opts.showconfig:
             self.showconfig()
         else:
         config.opts.configfile = py.path.local(config.opts.configfile)
         config.toxinipath = config.opts.configfile
         config.toxinidir = toxinidir = config.toxinipath.dirpath()
+
         if not config.toxinipath.check():
             feedback("toxini file %r does not exist" %(
                 str(config.toxinipath)), sysexit=True)
                               homedir=config.homedir)
         config.toxworkdir = reader.getpath(toxsection, "toxworkdir",
                                            "{toxinidir}/.tox")
+        config.minversion = reader.getdefault(toxsection, "minversion", None)
 
         # determine indexserver dictionary
         config.indexserver = {'default': IndexServerConfig('default')}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.