示例#1
0
def test_file(infile, outfile, options):
    lexer = precompiler.createLexer()
    fi = precompiler.createFileInterface(lexer)
    ctx = precompiler.createContext(fi, None)
    ctx.AddInputFile(infile)
    ctx.SetOutputFile(outfile, options)
    ctx.Run()
示例#2
0
def create_context(file, context_option, output_options):
    lexer = precompiler.createLexer()
    fi = precompiler.createFileInterface(lexer)
    ctx = precompiler.createContext(fi, context_option)
    input_file_path = os.path.join(test_data, file)

    ctx.AddInputFile(input_file_path)
    output_file_path = os.path.join(test_data, file + ".tmp")
    ctx.SetOutputFile(output_file_path, output_options)

    return ctx
示例#3
0
def preprocess_and_test(file,ref_file,context_optione,output_options):
	lexer = precompiler.createLexer()
	fi = precompiler.createFileInterface(lexer)
	ctx = precompiler.createContext(fi,context_optione)
	input_file_path = os.path.join(test_data,file)
	ctx.AddInputFile(input_file_path)
	output_file_path = input_file_path + ".tmp"
	ctx.SetOutputFile(output_file_path,output_options)
	ctx.Run()
	result_content = _pc_file_utils.open_and_read_textfile(output_file_path)
	refference_content = _pc_file_utils.open_and_read_textfile(os.path.join(test_data,ref_file))
	if result_content != refference_content:
		return False

	return True
def test_file(infile, outfile, options, msgcheck):
    lexer = precompiler.createLexer()
    fi = precompiler.createFileInterface(lexer)
    ctx = precompiler.createContext(fi, None)
    ctx.AddInputFile(infile)
    ctx.SetOutputFile(outfile, options)
    try:
        ctx.Run()
    except precompiler.SourceCodeError as e:
        msg = str(e).replace("\r\n", "").replace("\n", "")
        msgcheck = msgcheck.replace("\r\n", "").replace("\n", "")
        #print("--:" + msg + ":--")
        #print("--:" + msgcheck + ":--")
        if msg != msgcheck:
            raise Exception("FAILED - [" + infile + "]")
        else:
            print("OK - [" + infile + "]")
示例#5
0
 def test_file(self):
     lexer = precompiler.createLexer()
     fi = precompiler.createFileInterface(lexer)
     token = fi.GetFileTokens(os.environ["LEXER_TEST_FILE"])
     self.assertTrue(True)  #at this point we did not throw any exception