Ejemplo n.º 1
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')
        outfile = basename + '.html'
        if lib.initTest(basename, infile, outfile):
            cmdline = [infile]
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
    # using smart filters, same files generate more than one output
    for alias in ALIASES.keys():
        infile = ALIASES[alias] + '.t2t'
        outfile = alias + '.html'
        if lib.initTest(alias, infile, outfile):
            cmdline = addFilters(FILTERS.get(alias))
            cmdline.append('-H')
            cmdline.extend(['-o', outfile, infile])
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)
    
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 2
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')
        outfile = basename + '.html'
        if lib.initTest(basename, infile, outfile):
            cmdline = addFilters(FILTERS.get(basename))
            cmdline.append(infile)
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
    # using smart filters, same files generate more than one output
    for alias in ALIASES.keys():
        infile = ALIASES[alias] + '.t2t'
        outfile = alias + '.html'
        if lib.initTest(alias, infile, outfile):
            cmdline = addFilters(FILTERS.get(alias))
            cmdline.extend(['-o', outfile, infile])
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 3
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')
        outfile = basename + '.html'
        if lib.initTest(basename, infile, outfile):
            cmdline = [infile]
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)

    # extra: bar.t2t as TXT
    infile = 'bar.t2t'
    basename = 'bar'
    outfile = basename + '.txt'
    if lib.initTest(basename, infile, outfile):
        cmdline = ['-t', 'txt', '-i', infile]
        cmdline.extend(['--width', '150'])  # to avoid wrapping
        lib.convert(cmdline)
        lib.diff(outfile)
        lib.convert(cmdline, True)
        lib.diff(outfile)

    # using smart filters, same files generate more than one output
    for alias in ALIASES.keys():
        infile = ALIASES[alias] + '.t2t'
        outfile = alias + '.html'
        if lib.initTest(alias, infile, outfile):
            cmdline = addFilters(FILTERS.get(alias))
            cmdline.append('-H')
            cmdline.extend(['-o', outfile, infile])
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)

    # extra: bar2.t2t as TXT
    alias = 'bar2'
    infile = ALIASES[alias] + '.t2t'
    outfile = alias + '.txt'
    if lib.initTest(alias, infile, outfile):
        cmdline = addFilters(FILTERS.get(alias))
        cmdline.append('-H')
        cmdline.extend(['--width', '150'])  # to avoid wrapping
        cmdline.extend(['-t', 'txt', '-o', outfile, infile])
        lib.convert(cmdline)
        lib.diff(outfile)
        lib.convert(cmdline, True)
        lib.diff(outfile)

    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 4
0
def run():
    for test in tests:
        infile = test["name"] + ".t2t"
        outfile = test["name"] + "." + (test.get("target") or "out")
        extra = test.get("extra") or []
        cmdline = test["cmdline"]
        if "noinfile" not in extra:
            cmdline = test["cmdline"] + [infile]
        if lib.initTest(test["name"], infile, outfile):
            # create the extra files (if needed for this test)
            if "config" in extra:
                lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
            if "css" in extra:
                lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
            # may I add the -t target automatically?
            if "notarget" not in extra:
                cmdline = ["-t", test["target"]] + cmdline
            # may I redirect the output to a file?
            if test.get("redir"):
                cmdline.extend(test["redir"])
            # always catch the error output
            cmdline.append("2>&1")
            # create the source file
            lib.WriteFile(infile, test["content"])
            # convert and check results
            lib.test(cmdline, outfile)
            # remove the trash
            os.remove(infile)
            if os.path.isfile(lib.CSS_FILE):
                os.remove(lib.CSS_FILE)
            if os.path.isfile(lib.CONFIG_FILE):
                os.remove(lib.CONFIG_FILE)
Ejemplo n.º 5
0
def run():
    # test all OK files found
    # Note: txt target is to test the table-to-verbatim mapping
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        outfilelite = basename + '.' + (lib.EXTENSION.get(target) or target)
        if target == 'out':
            target = 'txt'
            stderr = 1
        infile = basename + ".t2t"
        outfile = outfile.replace('ok/', '')

        if lib.initTest(basename, infile, outfile):
            cmdline = ['-H']
            cmdline.extend(['-t', target])
            cmdline.extend(['-i', infile])
            if stderr:
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfilelite, os.path.join(lib.DIR_OK, outfile))
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)
    
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 6
0
def run():
    # test all OK files found
    # Note: txt target is to test the table-to-verbatim mapping
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        if target == 'out':
            target = 'txt'
            stderr = 1
        infile = basename + ".t2t"
        outfile = outfile.replace('ok/', '')

        if lib.initTest(basename, infile, outfile):
            cmdline = ['-H']
            cmdline.extend(['-t', target])
            cmdline.extend(['-i', infile])
            if stderr:
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 7
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        if target == 'out':
            target = 'txt'
            stderr = 1
        infile = basename + ".t2t"
        # Using filename -H suffix to run new tests using -H option
        if basename.endswith('-H'):
            infile = basename.replace('-H', '') + ".t2t"
        outfile = outfile.replace('ok/', '')

        if lib.initTest(basename, infile, outfile):
            cmdline = []
            cmdline = addFilters(FILTERS)
            if basename == 'path':
                cmdline.extend(['--width', '200'])
            if basename.endswith('-H'):
                cmdline.append('-H')
                cmdline.extend(['-o', outfile])
            cmdline.extend(['-t', target])
            cmdline.extend(['-i', infile])
            if stderr:
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 8
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')

        # Choose targets
        targets = all_targets
        if basename == 'table':
            targets = tableable

        for target in targets:
            outfile = basename + '.' + target
            outfilelite = basename + '.' + (lib.EXTENSION.get(target)
                                            or target)
            testname = '%s in %s' % (basename, target)
            if lib.initTest(testname, infile, outfile):
                cmdline = []
                cmdline.extend(['-i', infile])
                cmdline.extend(['-t', target])
                if target == 'aap':
                    cmdline.extend(['--width', '80'])
                lib.convert(cmdline)
                lib.diff(outfile)
                lib.convert(cmdline, True)
                lib.diff(outfilelite, os.path.join(lib.DIR_OK, outfile))
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 9
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        if target == 'out':
            target = 'txt'
            stderr = 1
        infile = basename + ".t2t"
        # Using filename -H suffix to run new tests using -H option
        if basename.endswith('-H'):
            infile = basename.replace('-H', '') + ".t2t"
        outfile = outfile.replace('ok/', '')

        if lib.initTest(basename, infile, outfile):
            cmdline = []
            cmdline = addFilters(FILTERS)
            if basename == 'path':
                cmdline.extend(['--width', '200'])
            if basename.endswith('-H'):
                cmdline.append('-H')
                cmdline.extend(['-o', outfile])
            cmdline.extend(['-t', target])
            cmdline.extend(['-i', infile])
            if stderr:
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 10
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')
        
        # Choose targets
        targets = all_targets
        if basename == 'table':
            targets = tableable
        
        for target in targets:
            outfile = basename + '.' + target
            outfilelite = basename + '.' + (lib.EXTENSION.get(target) or target)
            testname = '%s in %s' % (basename, target)
            if lib.initTest(testname, infile, outfile):
                cmdline = []
                cmdline.extend(['-i', infile])
                cmdline.extend(['-t', target])
                if target == 'aap':
                    cmdline.extend(['--width', '80'])
                lib.convert(cmdline)
                lib.diff(outfile)
                lib.convert(cmdline, True)
                lib.diff(outfilelite, os.path.join(lib.DIR_OK, outfile))
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 11
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        infile = basename + ".t2t"
        if infile in remote_infiles:
            infile = remote_root + infile
        if basename in remote_mapping:
            infile = remote_root + remote_mapping[basename]
        outfile = outfile.replace('ok/', '')
        if lib.initTest(basename, infile, outfile):
            cmdline = []
            cmdline.extend(['-i', infile])
            if infile.startswith(remote_root) \
                and basename != 'remote-outfile':
                cmdline.extend(['-o', outfile])
            if basename == 'not-found':
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            elif basename == 'stdout':
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
            elif basename == 'remote-outfile':
                cmdline.append('2>' + outfile)
            elif basename == 'relative-path':
                cmdline.extend(['-t', 'html'])
                cmdline.append('--fix-path')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 12
0
def run():
	# test all OK files found
	for outfile in glob.glob("ok/*"):
		stderr = 0
		basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
		target = re.sub('.*\.', '', outfile)
		if target == 'out':
			target = 'txt'
			stderr = 1
		infile = basename + ".t2t"
		outfile = outfile.replace('ok/', '')
		if lib.initTest(basename, infile, outfile):
			cmdline = ['-H']
			cmdline.extend(['-t', target])
			cmdline.extend(['-i', infile])
			if stderr:
				cmdline.extend(['-o', '-'])
				cmdline.append('>' + outfile)
				cmdline.append('2>&1')
			lib.convert(cmdline)
			lib.diff(outfile)
	# clean up
	if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
	
	return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 13
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        infile = basename + ".t2t"
        if infile in remote_infiles:
            infile = remote_root + infile
        if basename in remote_mapping:
            infile = remote_root + remote_mapping[basename]
        outfile = outfile.replace('ok/', '')
        if lib.initTest(basename, infile, outfile):
            cmdline = []
            cmdline.extend(['-i', infile])
            if infile.startswith(remote_root) \
                and basename != 'remote-outfile':
                cmdline.extend(['-o', outfile])
            if basename == 'not-found':
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            elif basename == 'stdout':
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
            elif basename == 'remote-outfile':
                cmdline.append('2>' + outfile)
            elif basename == 'relative-path':
                cmdline.extend(['-t', 'html'])
                cmdline.append('--fix-path')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 14
0
def run():
    # test all OK files found
    # Note: txt target is to test the table-to-verbatim mapping
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename, extension = os.path.splitext(os.path.basename(outfile))
        target = extension.lstrip('.')
        if target == 'out':
            target = 'txt'
            stderr = 1
        infile = basename + ".t2t"
        outfile = outfile.replace('ok/', '')
        if lib.initTest(basename, infile, outfile):
            cmdline = ['-H']
            cmdline.extend(['-t', target])
            cmdline.extend(['-i', infile])
            if stderr:
                cmdline.extend(['-o', '-'])
                cmdline.append('>' + outfile)
                cmdline.append('2>&1')
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 15
0
def run():
	for test in tests:
		infile  = test['name'] + '.t2t'
		outfile = test['name'] + '.' + (test.get('target') or 'out')
		extra   = test.get('extra') or []
		cmdline = test['cmdline']
		if not 'noinfile' in extra:
			cmdline = test['cmdline'] + [infile]
		if lib.initTest(test['name'], infile, outfile):
			# create the extra files (if needed for this test)
			if 'config' in extra:
				lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
			if 'css' in extra:
				lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
			# may I add the -t target automatically?
			if not 'notarget' in extra:
				cmdline = ['-t', test['target']] + cmdline
			# may I redirect the output to a file?
			if test.get('redir'):
				cmdline = cmdline + test['redir']
			# always catch the error output
			cmdline = cmdline + ['2>&1']
			# create the source file
			lib.WriteFile(infile, test['content'])
			# convert and check results
			lib.convert(cmdline)
			lib.diff(outfile)
			# remove the trash
			os.remove(infile)
			if os.path.isfile(lib.CSS_FILE): os.remove(lib.CSS_FILE)
			if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
	return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 16
0
Archivo: run.py Proyecto: kiennd/saigo
def run():
	for test in tests:
		infile  = test['name'] + '.t2t'
		outfile = test['name'] + '.' + (test.get('target') or 'out')
		cmdline = test['cmdline'] + [infile]
		extra   = test.get('extra') or []
		if lib.initTest(test['name'], infile, outfile):
			# create the extra files (if needed for this test)
			if 'config' in extra:
				lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
			if 'css' in extra:
				lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
			if not 'notarget' in extra:
				cmdline = ['-t', test['target']] + cmdline
			if test.get('redir'):
				cmdline = cmdline + test['redir']
			# create the source file
			lib.WriteFile(infile, test['content'])
			# convert and check results
			lib.convert(cmdline)
			lib.diff(outfile)
			# remove the trash
			os.remove(infile)
			if os.path.isfile(lib.CSS_FILE): os.remove(lib.CSS_FILE)
			if os.path.isfile(lib.CONFIG_FILE): os.remove(lib.CONFIG_FILE)
	return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 17
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace(".t2t", "")
        outfile = basename + ".html"
        if lib.initTest(basename, infile, outfile):
            cmdline = addFilters(FILTERS.get(basename))
            cmdline.append(infile)
            lib.test(cmdline, outfile)
    # using smart filters, same files generate more than one output
    for alias in ALIASES:
        infile = ALIASES[alias] + ".t2t"
        outfile = alias + ".html"
        if lib.initTest(alias, infile, outfile):
            cmdline = addFilters(FILTERS.get(alias))
            cmdline.extend(["-o", outfile, infile])
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)
Ejemplo n.º 18
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        basename = re.sub(r"\..*?$", "", outfile.replace("ok/", ""))
        target = re.sub(r".*\.", "", outfile)
        infile = basename + ".t2t"
        outfile = outfile.replace("ok/", "")
        if lib.initTest(basename, infile, outfile):
            cmdline = ["-H"]
            cmdline.extend(["-t", target])
            cmdline.append(infile)
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)
Ejemplo n.º 19
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        infile = basename + ".t2t"
        outfile = outfile.replace('ok/', '')
        if lib.initTest(basename, infile, outfile):
            cmdline = ['-H']
            cmdline.extend(['-t', target])
            cmdline.append(infile)
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 20
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        basename = re.sub('\..*?$', '', outfile.replace('ok/', ''))
        target = re.sub('.*\.', '', outfile)
        infile = basename + ".t2t"
        outfile = outfile.replace('ok/', '')
        if lib.initTest(basename, infile, outfile):
            cmdline = ['-H']
            cmdline.extend(['-t', target])
            cmdline.append(infile)
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 21
0
def run():
    for testid in tests.split():
        infile = testid + ".t2t"
        outfile = testid + ".html"
        cmdline = ["-t html -C test.conf", infile]
        if lib.initTest(testid, infile, outfile):
            # compose source file contents
            infile_txt = []
            for letter in testid:
                infile_txt.append(txt[letter])
            infile_txt = "\n".join(infile_txt)
            # create the source file
            lib.WriteFile(infile, infile_txt)
            # convert and check results
            lib.test(cmdline, outfile)
            # remove the trash
            os.remove(infile)
Ejemplo n.º 22
0
def run():
    for testid in tests.split():
        infile  = testid + '.t2t'
        outfile = testid + '.html'
        cmdline = ['-t html --css-sugar -C test.conf', infile]
        if lib.initTest(testid, infile, outfile):
            # compose source file contents
            infile_txt = []
            for letter in testid:
                infile_txt.append(txt[letter])
            infile_txt = '\n'.join(infile_txt)
            # create the source file
            lib.WriteFile(infile, infile_txt)
            # convert and check results
            lib.test(cmdline, outfile)
            # remove the trash
            os.remove(infile)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 23
0
def run():
    for test in tests:
        target = test.get('target') or 'txt'
        infile = test['name'] + '.t2t'
        outfile = test.get('outfile') or test['name'] + '.' + target
        extra = test.get('extra') or []
        cmdline = ['-i', infile] + test.get('cmdline', [])
        content = test['content']
        if 'noversion' in extra:
            content = VERSION_GOTCHA + content
        if 'error' in extra:
            outfile = test['name'] + '.out'
        if lib.initTest(test['name'], infile, outfile):
            # create the extra files (if needed for this test)
            if 'config' in extra:
                lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
            if 'css' in extra:
                lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
            # may I add the -t target automatically?
            if not 'notarget' in extra:
                cmdline = ['-t', target] + cmdline
            # may I redirect the output to a file?
            if test.get('redir'):
                cmdline.extend(test['redir'])
            elif 'error' in extra:
                cmdline.append('> %s.out' % test['name'])
            # always catch the error output
            cmdline.append('2>&1')
            # create the source file
            lib.WriteFile(infile, EMPTY_HEADER + content + '\n' + SIMPLE_BODY)
            # convert and check results
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
            # remove the trash
            os.remove(infile)
            if os.path.isfile(lib.CSS_FILE):
                os.remove(lib.CSS_FILE)
            if os.path.isfile(lib.CONFIG_FILE):
                os.remove(lib.CONFIG_FILE)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 24
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')

        # Choose targets
        targets = all_targets
        if basename == 'table':
            targets = tableable

        for target in targets:
            outfile = basename + '.' + target
            testname = '%s in %s' % (basename, target)
            if lib.initTest(testname, infile, outfile):
                cmdline = []
                cmdline.extend(['-i', infile])
                cmdline.extend(['-t', target])
                if target == 'aap':
                    cmdline.extend(['--width', '80'])
                lib.test(cmdline, outfile)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 25
0
def run():
    # test all .t2t files found
    for infile in glob.glob("*.t2t"):
        basename = infile.replace('.t2t', '')

        # Choose targets
        targets = all_targets
        if basename == 'table':
            targets = tableable

        for target in targets:
            outfile = basename + '.' + target
            testname = '%s in %s' % (basename, target)
            if lib.initTest(testname, infile, outfile):
                cmdline = []
                cmdline.extend(['-i', infile])
                cmdline.extend(['-t', target])
                if target == 'aap':
                    cmdline.extend(['--width', '80'])
                lib.test(cmdline, outfile)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 26
0
def run():
    for test in tests:
        infile = test['name'] + '.t2t'
        outfile = test['name'] + '.' + (test.get('target') or 'out')
        extra = test.get('extra') or []
        cmdline = test['cmdline']
        if not 'noinfile' in extra:
            cmdline = test['cmdline'] + [infile]
        if lib.initTest(test['name'], infile, outfile):
            # create the extra files (if needed for this test)
            if 'config' in extra:
                lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
            if 'css' in extra:
                lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
            # may I add the -t target automatically?
            if not 'notarget' in extra:
                cmdline = ['-t', test['target']] + cmdline
            # may I remove the SVN revision number?
            if 'norevision' in extra:
                cmdline.append(' | sed "%s;%s"' %
                               (SED_NO_REVISION1, SED_NO_REVISION2))
            # may I redirect the output to a file?
            if test.get('redir'):
                cmdline.extend(test['redir'])
            # always catch the error output
            cmdline.append('2>&1')
            # create the source file
            lib.WriteFile(infile, test['content'])
            # convert and check results
            lib.convert(cmdline)
            lib.diff(outfile)
            lib.convert(cmdline, True)
            lib.diff(outfile)
            # remove the trash
            os.remove(infile)
            if os.path.isfile(lib.CSS_FILE):
                os.remove(lib.CSS_FILE)
            if os.path.isfile(lib.CONFIG_FILE):
                os.remove(lib.CONFIG_FILE)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 27
0
def run():
    for test in tests:
        target  = test.get('target') or 'txt'
        infile  = test['name'] + '.t2t'
        outfile = test.get('outfile') or test['name'] + '.' + target
        extra   = test.get('extra') or []
        cmdline = ['-i', infile] + test.get('cmdline', [])
        content = test['content']
        if 'noversion' in extra:
            content = VERSION_GOTCHA + content
        if 'error' in extra:
            outfile = test['name'] + '.out'
        if lib.initTest(test['name'], infile, outfile):
            # create the extra files (if needed for this test)
            if 'config' in extra:
                lib.WriteFile(lib.CONFIG_FILE, CONFIG_FILE_TXT)
            if 'css' in extra:
                lib.WriteFile(lib.CSS_FILE, CSS_FILE_TXT)
            # may I add the -t target automatically?
            if not 'notarget' in extra:
                cmdline = ['-t', target] + cmdline
            # may I redirect the output to a file?
            if test.get('redir'):
                cmdline.extend(test['redir'])
            elif 'error' in extra:
                cmdline.append('> %s.out' % test['name'])
            # always catch the error output
            cmdline.append('2>&1')
            # create the source file
            lib.WriteFile(infile, EMPTY_HEADER + content + '\n' + SIMPLE_BODY)
            # convert and check results
            lib.test(cmdline, outfile)
            # remove the trash
            os.remove(infile)
            if os.path.isfile(lib.CSS_FILE):
                os.remove(lib.CSS_FILE)
            if os.path.isfile(lib.CONFIG_FILE):
                os.remove(lib.CONFIG_FILE)
    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 28
0
def run():
    # test all OK files found
    for outfile in glob.glob("ok/*"):
        stderr = 0
        basename = re.sub(r"\..*?$", "", outfile.replace("ok/", ""))
        target = re.sub(r".*\.", "", outfile)
        if target == "out":
            target = "txt"
            stderr = 1
        infile = basename + ".t2t"
        outfile = outfile.replace("ok/", "")
        if lib.initTest(basename, infile, outfile):
            cmdline = ["-H"]
            cmdline.extend(["-t", target])
            cmdline.extend(["-i", infile])
            if stderr:
                cmdline.extend(["-o", "-"])
                cmdline.append(">" + outfile)
                cmdline.append("2>&1")
            lib.test(cmdline, outfile)
    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)
Ejemplo n.º 29
0
def run():

    ### First test the %!includeconf command

    errors = [
        'includeconf-itself',
        'includeconf-not-found',
        'includeconf-targeted',
        'includeconf-text',
        ]
    unnumbered = [
        'includeconf-empty',
        ]

    # test all t2t files found
    for infile in glob.glob("includeconf-*.t2t"):
        basename = infile.replace('.t2t', '')
        outfile = basename + '.html'

        if basename in unnumbered:
            okfile = 'ok/not-numbered.html'
        else:
            okfile = 'ok/numbered.html'

        if basename in errors:
            outfile = basename + '.out'
            okfile = 'ok/' + outfile
            cmdline = ['-H', '-i', infile, '-o- >', outfile, '2>&1']
        else:
            cmdline = ['-H', '-i', infile, '-o', outfile]

        if lib.initTest(basename, infile, outfile, okfile):
            lib.convert(cmdline)
            lib.diff(outfile, okfile)
            lib.convert(cmdline, True)
            lib.diff(outfile, okfile)

    ### Now test -C and --config-file command line options

    errors = ['C-not-found', 'C-text']
    default_cmdline = ['-H -i body-only.t2t']
    infile = 'body-only.t2t'
    for test in tests:

        # --enum-title is used by this test?
        if test.get('not-numbered'):
            okfile = 'ok/not-numbered.html'
        else:
            okfile = 'ok/numbered.html'

        # 1st turn (-C), 2nd turn (--config-file)
        for i in (1, 2):

            if i == 1:
                name = test['name']
                cmdline = test['cmdline']
            else:
                name = test['name'].replace('C', 'config-file')
                cmdline = map(lambda x: x.replace('-C', '--config-file'), test['cmdline'])

            outfile = name + '.html'

            if test['name'] in errors:
                outfile = name + '.out'
                okfile = 'ok/' + outfile
                cmdline = default_cmdline + cmdline + ['-o- >', outfile, '2>&1']
            else:
                cmdline = default_cmdline + cmdline + ['-o', outfile]

            # convert and check results
            if lib.initTest(name, infile, outfile, okfile):
                lib.convert(cmdline)
                lib.diff(outfile, okfile)
                lib.convert(cmdline, True)
                lib.diff(outfile, okfile)

    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)

    return lib.OK, lib.FAILED, lib.ERROR_FILES
Ejemplo n.º 30
0
def run():

    # First test the %!includeconf command.
    errors = [
        "includeconf-itself",
        "includeconf-not-found",
        "includeconf-targeted",
        "includeconf-text",
    ]
    unnumbered = ["includeconf-empty"]

    # Test all t2t files found.
    for infile in glob.glob("includeconf-*.t2t"):
        basename = infile.replace(".t2t", "")
        outfile = basename + ".html"

        if basename in unnumbered:
            okfile = "ok/not-numbered.html"
        else:
            okfile = "ok/numbered.html"

        if basename in errors:
            outfile = basename + ".out"
            okfile = "ok/" + outfile
            cmdline = ["-H", "-i", infile, "-o- >", outfile, "2>&1"]
        else:
            cmdline = ["-H", "-i", infile, "-o", outfile]

        if lib.initTest(basename, infile, outfile, okfile):
            lib.test(cmdline, outfile, okfile)

    # Now test -C and --config-file command line options.
    errors = ["C-not-found", "C-text"]
    default_cmdline = ["-H -i body-only.t2t"]
    infile = "body-only.t2t"
    for test in tests:

        # --enum-title is used by this test?
        if test.get("not-numbered"):
            okfile = "ok/not-numbered.html"
        else:
            okfile = "ok/numbered.html"

        # 1st turn (-C), 2nd turn (--config-file)
        for i in (1, 2):

            if i == 1:
                name = test["name"]
                cmdline = test["cmdline"]
            else:
                name = test["name"].replace("C", "config-file")
                cmdline = [
                    x.replace("-C", "--config-file") for x in test["cmdline"]
                ]

            outfile = name + ".html"

            if test["name"] in errors:
                outfile = name + ".out"
                okfile = "ok/" + outfile
                cmdline = default_cmdline + cmdline + [
                    "-o- >", outfile, "2>&1"
                ]
            else:
                cmdline = default_cmdline + cmdline + ["-o", outfile]

            # convert and check results
            if lib.initTest(name, infile, outfile, okfile):
                lib.test(cmdline, outfile, okfile=okfile)

    # clean up
    if os.path.isfile(lib.CONFIG_FILE):
        os.remove(lib.CONFIG_FILE)