Search in sources :

Example 1 with DefaultRunExecutor

use of com.intellij.execution.executors.DefaultRunExecutor in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoEventsConverterTestCase method doTest.

protected void doTest() {
    Executor executor = new DefaultRunExecutor();
    GoTestRunConfiguration runConfig = new GoTestRunConfiguration(myFixture.getProject(), "", GoTestRunConfigurationType.getInstance());
    runConfig.setTestFramework(getTestFramework());
    GoTestConsoleProperties consoleProperties = new GoTestConsoleProperties(runConfig, executor);
    GoTestEventsConverterBase converter = (GoTestEventsConverterBase) consoleProperties.createTestEventsConverter("gotest", consoleProperties);
    LoggingServiceMessageVisitor serviceMessageVisitor = new LoggingServiceMessageVisitor();
    try {
        for (String line : FileUtil.loadLines(new File(getTestDataPath(), getTestName(true) + ".txt"), CharsetToolkit.UTF8)) {
            converter.processServiceMessages(line + "\n", ProcessOutputTypes.STDOUT, serviceMessageVisitor);
        }
    } catch (IOException | ParseException e) {
        throw new RuntimeException(e);
    }
    ((OutputToGeneralTestEventsConverter) converter).flushBufferBeforeTerminating();
    Disposer.dispose((OutputToGeneralTestEventsConverter) converter);
    assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + "-expected.txt", serviceMessageVisitor.getLog());
}
Also used : OutputToGeneralTestEventsConverter(com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ParseException(java.text.ParseException) File(java.io.File) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor)

Example 2 with DefaultRunExecutor

use of com.intellij.execution.executors.DefaultRunExecutor in project intellij-community by JetBrains.

the class GeneralToSMTRunnerEventsConvertorTest method testPreserveFullOutputAfterImport.

public void testPreserveFullOutputAfterImport() throws Exception {
    mySuite.addChild(mySimpleTest);
    for (int i = 0; i < 550; i++) {
        String message = "line" + i + "\n";
        mySimpleTest.addLast(printer -> printer.print(message, ConsoleViewContentType.NORMAL_OUTPUT));
    }
    mySimpleTest.setFinished();
    mySuite.setFinished();
    SAXTransformerFactory transformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
    TransformerHandler handler = transformerFactory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
    handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    File output = FileUtil.createTempFile("output", "");
    try {
        FileUtilRt.createParentDirs(output);
        handler.setResult(new StreamResult(new FileWriter(output)));
        MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
        TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
        String savedText = FileUtil.loadFile(output);
        assertTrue(savedText.split("\n").length > 550);
        myEventsProcessor.onStartTesting();
        ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
        myEventsProcessor.onFinishTesting();
        List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
        assertSize(1, children);
        SMTestProxy testProxy = children.get(0);
        MockPrinter mockPrinter = new MockPrinter();
        testProxy.printOn(mockPrinter);
        assertSize(550, mockPrinter.getAllOut().split("\n"));
    } finally {
        FileUtil.delete(output);
    }
}
Also used : TransformerHandler(javax.xml.transform.sax.TransformerHandler) StreamResult(javax.xml.transform.stream.StreamResult) FileWriter(java.io.FileWriter) SAXTransformerFactory(javax.xml.transform.sax.SAXTransformerFactory) StringReader(java.io.StringReader) MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter) File(java.io.File) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor)

Aggregations

DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)2 File (java.io.File)2 Executor (com.intellij.execution.Executor)1 OutputToGeneralTestEventsConverter (com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter)1 MockPrinter (com.intellij.execution.testframework.sm.runner.ui.MockPrinter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ParseException (java.text.ParseException)1 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)1 TransformerHandler (javax.xml.transform.sax.TransformerHandler)1 StreamResult (javax.xml.transform.stream.StreamResult)1