Skip to content

Commit

Permalink
test_cli - remove requirement to run in base dir (fixes a FIXME, thou…
Browse files Browse the repository at this point in the history
…gh a bit hackily)

Ignore-this: 79c993335d267ec912fa194db22a55fe

darcs-hash:20140502145804-3a4db-9f0d6aed706f4b5443ffe7b9740ddc5939882fdd
  • Loading branch information
MattShannon committed May 2, 2014
1 parent a3785bb commit 08c8a43
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions bin/test_cli.py
Expand Up @@ -20,7 +20,10 @@
import tempfile
from filecmp import cmpfiles

# (FIXME : this script currently only works from repo root directory)
# (FIXME : bit of a hacky way to find base dir)
import mcd as mcd_temp
baseDir = os.path.dirname(os.path.dirname(mcd_temp.__file__))
print '(using baseDir %s)' % baseDir

class TempDir(object):
def __init__(self, prefix='mcd.', removeOnException=False):
Expand Down Expand Up @@ -50,15 +53,15 @@ def readUttIds(uttIdsFile):
class TestCliTools(unittest.TestCase):
def test_dtw_synth(self):
"""Simple characterization test for dtw_synth."""
uttIds = readUttIds(join('test_data', 'corpus.lst'))
uttIds = readUttIds(join(baseDir, 'test_data', 'corpus.lst'))
with TempDir() as tempDir:
synthOutDir = tempDir.location
p = subprocess.Popen([
join('bin', 'dtw_synth'),
join(baseDir, 'bin', 'dtw_synth'),
'--exts', 'mgc,lf0,bap',
'--param_orders', '40,1,5',
join('test_data', 'ref-examples'),
join('test_data', 'synth-examples'),
join(baseDir, 'test_data', 'ref-examples'),
join(baseDir, 'test_data', 'synth-examples'),
synthOutDir,
] + uttIds, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
Expand All @@ -75,7 +78,7 @@ def test_dtw_synth(self):
)
self.assertEqual(stderr, '')
self.assertEqual(stdout, stdoutGood)
synthOutDirGood = join('test_data', 'out-dtw_synth')
synthOutDirGood = join(baseDir, 'test_data', 'out-dtw_synth')
filenames = [ '%s.mgc' % uttId for uttId in uttIds ]
match, mismatch, errors = cmpfiles(synthOutDir, synthOutDirGood,
filenames, shallow = False)
Expand All @@ -85,13 +88,13 @@ def test_dtw_synth(self):

def test_get_mcd_dtw(self):
"""Simple characterization test for get_mcd_dtw."""
uttIds = readUttIds(join('test_data', 'corpus.lst'))
uttIds = readUttIds(join(baseDir, 'test_data', 'corpus.lst'))
p = subprocess.Popen([
join('bin', 'get_mcd_dtw'),
join(baseDir, 'bin', 'get_mcd_dtw'),
'--ext', 'mgc',
'--param_order', '40',
join('test_data', 'ref-examples'),
join('test_data', 'synth-examples'),
join(baseDir, 'test_data', 'ref-examples'),
join(baseDir, 'test_data', 'synth-examples'),
] + uttIds, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
stdoutGood = (
Expand All @@ -104,13 +107,13 @@ def test_get_mcd_dtw(self):

def test_get_mcd_plain(self):
"""Simple characterization test for get_mcd_plain."""
uttIds = readUttIds(join('test_data', 'corpus.lst'))
uttIds = readUttIds(join(baseDir, 'test_data', 'corpus.lst'))
p = subprocess.Popen([
join('bin', 'get_mcd_plain'),
join(baseDir, 'bin', 'get_mcd_plain'),
'--ext', 'mgc',
'--param_order', '40',
join('test_data', 'ref-examples'),
join('test_data', 'aligned-synth-examples'),
join(baseDir, 'test_data', 'ref-examples'),
join(baseDir, 'test_data', 'aligned-synth-examples'),
] + uttIds, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
stdoutGood = (
Expand All @@ -123,17 +126,18 @@ def test_get_mcd_plain(self):

def test_get_mcd_plain_exc_pau(self):
"""Simple characterization test for get_mcd_plain excluding pau."""
uttIds = readUttIds(join('test_data', 'corpus.lst'))
labelsDir = join('test_data', 'aligned-synth-examples', 'labels')
uttIds = readUttIds(join(baseDir, 'test_data', 'corpus.lst'))
labelsDir = join(baseDir, 'test_data', 'aligned-synth-examples',
'labels')
p = subprocess.Popen([
join('bin', 'get_mcd_plain'),
join(baseDir, 'bin', 'get_mcd_plain'),
'--ext', 'mgc',
'--param_order', '40',
'--remove_segments', '.-pau\+',
'--labels_dir', labelsDir,
'--frame_period', '0.005',
join('test_data', 'ref-examples'),
join('test_data', 'aligned-synth-examples'),
join(baseDir, 'test_data', 'ref-examples'),
join(baseDir, 'test_data', 'aligned-synth-examples'),
] + uttIds, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
stdoutGood = (
Expand Down

0 comments on commit 08c8a43

Please sign in to comment.