Patchwork [4,of,4] tests: add coverage to ensure Wix tracks 'help' and 'templates' files

login
register
mail settings
Submitter Matt Harbison
Date Dec. 14, 2015, 2:56 a.m.
Message ID <8baf8967301da99e22b5.1450061802@Envy>
Download mbox | patch
Permalink /patch/12028/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 14, 2015, 2:56 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1442199291 14400
#      Sun Sep 13 22:54:51 2015 -0400
# Node ID 8baf8967301da99e22b5c2ea345ef061708bf745
# Parent  2f3f443558ecd5176b9e6303cd98e1c97ad0f3db
tests: add coverage to ensure Wix tracks 'help' and 'templates' files

This would have caught the problem fixed by 65d2538ac993.  There are other *.wxs
files that can be checked, but they appear to be more complicated.  For example,
locale.wxs has what appears to be foreach loop support, as well as variable
substitution.

By checking `hg files` to determine tracked file, this is able to avoid false
failures when other junk is present in the filesystem, like *.orig files.

I can't tell if the map-cmdline.status file is not included on purpose, but I
don't see the purpose of excluding it.  The missing help files seem reasonable
for Windows.
Matt Harbison - Dec. 14, 2015, 3:37 a.m.
On Sun, 13 Dec 2015 21:56:42 -0500, Matt Harbison <mharbison72@gmail.com>  
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1442199291 14400
> #      Sun Sep 13 22:54:51 2015 -0400
> # Node ID 8baf8967301da99e22b5c2ea345ef061708bf745
> # Parent  2f3f443558ecd5176b9e6303cd98e1c97ad0f3db
> tests: add coverage to ensure Wix tracks 'help' and 'templates' files
>
> This would have caught the problem fixed by 65d2538ac993.  There are  
> other *.wxs
> files that can be checked, but they appear to be more complicated.  For  
> example,
> locale.wxs has what appears to be foreach loop support, as well as  
> variable
> substitution.
>
> By checking `hg files` to determine tracked file, this is able to avoid  
> false
> failures when other junk is present in the filesystem, like *.orig files.
>
> I can't tell if the map-cmdline.status file is not included on purpose,  
> but I
> don't see the purpose of excluding it.  The missing help files seem  
> reasonable
> for Windows.
>
> diff --git a/tests/test-install.t b/tests/test-install.t
> --- a/tests/test-install.t
> +++ b/tests/test-install.t
> @@ -41,3 +41,69 @@
>    checking commit editor...
>    checking username...
>    no problems detected
> +
> +  $ cat >> wixxml.py << EOF
> +  > import os, subprocess, sys
> +  > import xml.etree.ElementTree as ET
> +  >
> +  > # MSYS mangles the path if it expands $TESTDIR
> +  > testdir = os.environ['TESTDIR']
> +  > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'}
> +  >
> +  > def directory(node, relpath):
> +  >     '''generator of files in the xml node, rooted at relpath'''
> +  >     dirs = node.findall('./wix:Directory', ns)
> +  >
> +  >     for d in dirs:
> +  >         for subfile in directory(d, relpath + d.attrib['Name'] +  
> '/'):
> +  >             yield subfile
> +  >
> +  >     files = node.findall('./wix:Component/wix:File', ns)
> +  >
> +  >     for f in files:
> +  >         yield relpath + f.attrib['Name']
> +  >
> +  > def hgdirectory(relpath):
> +  >     '''generator of tracked files, rooted at relpath'''
> +  >     hgdir = "%s/../mercurial" % (testdir)
> +  >     args = ['hg', '--cwd', hgdir, 'files', '--rev', '.', relpath]

Do we want to check . or wdir()?  The test didn't catch it when I imported  
Greg's first doc patch without committing it.  But I tend to commit/amend  
often, and run the tests on a fully committed repo.  That's needed anyway  
to commit comment checking, etc.  Not sure if there's an existing  
philosophy for this kind of thing.
Matt Mackall - Dec. 16, 2015, 11:08 p.m.
On Sun, 2015-12-13 at 21:56 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1442199291 14400
> #      Sun Sep 13 22:54:51 2015 -0400
> # Node ID 8baf8967301da99e22b5c2ea345ef061708bf745
> # Parent  2f3f443558ecd5176b9e6303cd98e1c97ad0f3db
> tests: add coverage to ensure Wix tracks 'help' and 'templates' files

I've queued 1, 3, and 4 here, thanks.

> I can't tell if the map-cmdline.status file is not included on purpose, but I
> don't see the purpose of excluding it.

Definitely an oversight.

-- 
Mathematics is the supreme nostalgia of our time.
Yuya Nishihara - Dec. 17, 2015, 12:51 p.m.
On Sun, 13 Dec 2015 22:37:59 -0500, Matt Harbison wrote:
> On Sun, 13 Dec 2015 21:56:42 -0500, Matt Harbison <mharbison72@gmail.com>  
> > +  > def hgdirectory(relpath):
> > +  >     '''generator of tracked files, rooted at relpath'''
> > +  >     hgdir = "%s/../mercurial" % (testdir)
> > +  >     args = ['hg', '--cwd', hgdir, 'files', '--rev', '.', relpath]
> 
> Do we want to check . or wdir()?  The test didn't catch it when I imported  
> Greg's first doc patch without committing it.  But I tend to commit/amend  
> often, and run the tests on a fully committed repo.  That's needed anyway  
> to commit comment checking, etc.  Not sure if there's an existing  
> philosophy for this kind of thing.

Perhaps wdir. Tests can be run without committing, and the other similar tests
use "hg locate" or "hg files" with no -r option.

By the way, this would need '#if test-repo'.

Patch

diff --git a/tests/test-install.t b/tests/test-install.t
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -41,3 +41,69 @@ 
   checking commit editor...
   checking username...
   no problems detected
+
+  $ cat >> wixxml.py << EOF
+  > import os, subprocess, sys
+  > import xml.etree.ElementTree as ET
+  > 
+  > # MSYS mangles the path if it expands $TESTDIR
+  > testdir = os.environ['TESTDIR']
+  > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'}
+  > 
+  > def directory(node, relpath):
+  >     '''generator of files in the xml node, rooted at relpath'''
+  >     dirs = node.findall('./wix:Directory', ns)
+  > 
+  >     for d in dirs:
+  >         for subfile in directory(d, relpath + d.attrib['Name'] + '/'):
+  >             yield subfile
+  > 
+  >     files = node.findall('./wix:Component/wix:File', ns)
+  > 
+  >     for f in files:
+  >         yield relpath + f.attrib['Name']
+  > 
+  > def hgdirectory(relpath):
+  >     '''generator of tracked files, rooted at relpath'''
+  >     hgdir = "%s/../mercurial" % (testdir)
+  >     args = ['hg', '--cwd', hgdir, 'files', '--rev', '.', relpath]
+  >     proc = subprocess.Popen(args, stdout=subprocess.PIPE,
+  >                             stderr=subprocess.PIPE)
+  >     output = proc.communicate()[0]
+  > 
+  >     slash = '/'
+  >     for line in output.splitlines():
+  >         if os.name == 'nt':
+  >             yield line.replace(os.sep, slash)
+  >         else:
+  >             yield line
+  > 
+  > tracked = [f for f in hgdirectory(sys.argv[1])]
+  > 
+  > xml = ET.parse("%s/../contrib/wix/%s.wxs" % (testdir, sys.argv[1]))
+  > root = xml.getroot()
+  > dir = root.find('.//wix:DirectoryRef', ns)
+  > 
+  > installed = [f for f in directory(dir, '')]
+  > 
+  > print('Not installed:')
+  > for f in sorted(set(tracked) - set(installed)):
+  >     print('  %s' % f)
+  > 
+  > print('Not tracked:')
+  > for f in sorted(set(installed) - set(tracked)):
+  >     print('  %s' % f)
+  > EOF
+
+  $ python wixxml.py help
+  Not installed:
+    help/common.txt
+    help/hg.1.txt
+    help/hgignore.5.txt
+    help/hgrc.5.txt
+  Not tracked:
+
+  $ python wixxml.py templates
+  Not installed:
+    templates/map-cmdline.status
+  Not tracked: