def setcode(testname, code):
    testname = os.path.split(testname)
    if not testname[1]:
        testname = os.path.split(testname[0])
    testname = os.path.splitext(testname[1])[0]
    pdfpath = os.path.join(autotest.PathInfo.outdir, testname + '.pdf')
    md5path = os.path.join(autotest.PathInfo.md5dir, testname + '.json')
    return autotest.checkmd5(pdfpath, md5path, [], code)
Example #2
0
def setcode(testname, code):
    testname = os.path.split(testname)
    if not testname[1]:
        testname = os.path.split(testname[0])
    testname = os.path.splitext(testname[1])[0]
    pdfpath = os.path.join(autotest.PathInfo.outdir, testname + '.pdf')
    md5path = os.path.join(autotest.PathInfo.md5dir, testname + '.json')
    return autotest.checkmd5(pdfpath, md5path, [], code)
Example #3
0
def run_installed_single(inpfname):
    """Like run_single, but runs the test using the installed version
    of rst2pdf"""

    iprefix = os.path.splitext(inpfname)[0]
    basename = os.path.basename(iprefix)
    if os.path.exists(iprefix + '.ignore'):
        return 'ignored', 0

    oprefix = os.path.join(PathInfo.outdir, basename)
    mprefix = os.path.join(PathInfo.md5dir, basename)
    outpdf = oprefix + '.pdf'
    outtext = oprefix + '.log'
    md5file = mprefix + '.json'

    inpfname = iprefix + '.txt'
    style = iprefix + '.style'
    cli = iprefix + '.cli'
    if os.path.isfile(cli):
        f = open(cli)
        extraargs = shlex.split(f.read())
        f.close()
    else:
        extraargs = []
    args = ['rst2pdf'
            ] + ['--date-invariant', '-v',
                 os.path.basename(inpfname)] + extraargs
    if os.path.exists(style):
        args.extend(('-s', os.path.basename(style)))
    args.extend(('-o', outpdf))
    errcode, result = textexec(args, cwd=dirname(inpfname), python_proc=None)

    checkinfo = checkmd5(outpdf, md5file, result, None, errcode, iprefix)
    log(result, '')
    outf = open(outtext, 'wb')
    outf.write('\n'.join(result))
    outf.close()
    return checkinfo, errcode
def run_installed_single(inpfname):
    """Like run_single, but runs the test using the installed version
    of rst2pdf"""

    iprefix = os.path.splitext(inpfname)[0]
    basename = os.path.basename(iprefix)
    if os.path.exists(iprefix + ".ignore"):
        return "ignored", 0

    oprefix = os.path.join(PathInfo.outdir, basename)
    mprefix = os.path.join(PathInfo.md5dir, basename)
    outpdf = oprefix + ".pdf"
    outtext = oprefix + ".log"
    md5file = mprefix + ".json"

    inpfname = iprefix + ".txt"
    style = iprefix + ".style"
    cli = iprefix + ".cli"
    if os.path.isfile(cli):
        f = open(cli)
        extraargs = shlex.split(f.read())
        f.close()
    else:
        extraargs = []
    args = ["rst2pdf"] + ["--date-invariant", "-v", os.path.basename(inpfname)] + extraargs
    if os.path.exists(style):
        args.extend(("-s", os.path.basename(style)))
    args.extend(("-o", outpdf))
    errcode, result = textexec(args, cwd=dirname(inpfname), python_proc=None)

    checkinfo = checkmd5(outpdf, md5file, result, None, errcode, iprefix)
    log(result, "")
    outf = open(outtext, "wb")
    outf.write("\n".join(result))
    outf.close()
    return checkinfo, errcode
Example #5
0
def run_installed_single(inpfname):
    """Like run_single, but runs the test using the installed version
    of rst2pdf"""

    iprefix = os.path.splitext(inpfname)[0]
    basename = os.path.basename(iprefix)
    if os.path.exists(iprefix + '.ignore'):
        return 'ignored', 0
        
    oprefix = os.path.join(PathInfo.outdir, basename)
    mprefix = os.path.join(PathInfo.md5dir, basename)
    outpdf = oprefix + '.pdf'
    outtext = oprefix + '.log'
    md5file = mprefix + '.json'
    
    inpfname = iprefix + '.txt'
    style = iprefix + '.style'
    cli = iprefix + '.cli'
    if os.path.isfile(cli):
        f = open(cli)
        extraargs=shlex.split(f.read())
        f.close()
    else:
        extraargs=[]
    args = ['rst2pdf'] + ['--date-invariant', '-v', os.path.basename(inpfname)]+extraargs
    if os.path.exists(style):
        args.extend(('-s', os.path.basename(style)))
    args.extend(('-o', outpdf))
    errcode, result = textexec(args, cwd=dirname(inpfname), python_proc=None)

    checkinfo = checkmd5(outpdf, md5file, result, None, errcode, iprefix)
    log(result, '')
    outf = open(outtext, 'wb')
    outf.write('\n'.join(result))
    outf.close()
    return checkinfo, errcode
Example #6
0
  It will print 'GOOD ARTIFACT', and then copy that file into reference/
"""

import glob
import shutil

from autotest import checkmd5

# First, let's check that the existing artifacts are "good"

artifacts = glob.glob('reference/*.pdf')

for artifact in artifacts:
    md5_path = artifact.replace('.pdf', '.json').replace('reference/', 'md5/')
    res, _ = checkmd5(artifact, md5_path, [], False)
    if res != 'good':
        print 'BAD ARTIFACT: %s ' % res, artifact

# Check if any output file is good and has no matching artifact

for new_artifact in glob.glob('output/*.pdf'):
    artifact = new_artifact.replace('output/', 'reference/')
    if artifact in artifacts:
        continue  # We already have an artifact for this test
    else:
        md5_path = artifact.replace('.pdf',
                                    '.json').replace('reference/', 'md5/')
        res, _ = checkmd5(new_artifact, md5_path, [], False)
        if res == 'good':
            print 'GOOD ARTIFACT: %s ' % res, new_artifact