outfile = None

test = sys.argv[1]
outfn = sys.argv[2]
for o in sys.argv[1:]:
    if o.find("--js=") == 0:
        js = o.split("--js=")[1]
    elif o.find("--out=") == 0:
        outfile = o.split("--out=")[1]
    elif o.find("--timeout=") == 0:
        timeout = int(o.split("--timeout=")[1])

anyRemoved = True

if outfile == None:
    (failure, rcode) = R.getOutputReturn(test, js, timeout)
else:
    failure = []
    for l in open(outfile):
        failure.append(l)

def checkFail(text):
    tname = str(os.getpid()) + ".test"
    tfile = open(tname,'w')
    tfile.write(text)
    tfile.close()
    success = R.failSame(tname, failure, operator.eq, js, timeout)
    os.remove(tname)
    return success

text = ""
Exemple #2
0
    elif mode == "right":
        tokens = True
        tokenMode = "right"

    if tokens:
        lines = open(toMin).readlines()
        fileContents = []
        for l in lines:
            fileContents.extend(tokenSplit(l, tokenMode))
    
    for delta in fileContents:
        deltas.append((index, delta))
        index = index + 1

    if mydd.outfile == None:
        (mydd.originalOutput, rcode) = R.getOutputReturn(toMin, mydd.js, mydd.timeout)
    else:
        for l in open(mydd.outfile):
            mydd.originalOutput.append(l)

    c = mydd.ddmin(deltas)              # Invoke DDMIN

    text = mydd.coerce(c)

    outf = open(minOut,'w')
    outf.write(text)
    if (mode == "chars") and (text[-1] != "\n"):
        outf.write("\n")
    outf.close()

Exemple #3
0
collect = False

dnull = open(os.devnull,'w')

for o in sys.argv[2:]:
    if o.find("--js=") == 0:
        js = o.split("--js=")[1]
    if o.find("--timeout=") == 0:
        timeout = int(o.split("--timeout=")[1])
    if o.find("--collect=") == 0:
        collect = True
        clen = o.split("--collect=")[1]

# Create an output file for all minimizing

(outlines, rcode) = R.getOutputReturn(testIn, js, timeout)

tr = str(os.getpid())
tmpOut = tr + ".out"
tmpOutF = open(tmpOut, 'w')
for l in outlines:
    tmpOutF.write(l)
tmpOutF.close()

tmpTest = tr + ".test"

if collect:
    os.environ["COLLECT"] = "True"
    os.environ["SUCCFILE"] = testOut + ".succ"
    os.environ["DIFFFILE"] = testOut + ".diff"
    os.environ["FAILFILE"] = testOut + ".fail"