<commit_before>/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.platform.console.tasks;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.platform.console.tasks.ColoredPrintingTestListener.INDENTATION;
import static org.junit.platform.engine.TestExecutionResult.failed;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.junit.jupiter.api.Test;
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.reporting.ReportEntry;
import org.junit.platform.engine.test.TestDescriptorStub;
import org.junit.platform.launcher.TestIdentifier;

/**
 * @since 1.0
 */
public class ColoredPrintingTestListenerTests {

	@Test
	public void executionSkippedMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.executionSkipped(newTestIdentifier(), "Test\n\tdisabled");
		String output = stringWriter.toString();

		String expected = "Skipped:     failingTest [[engine:junit]]\n" + INDENTATION + "=> Reason: Test\n"
				+ INDENTATION + "\tdisabled\n";

		assertEquals(expected, output);
	}

	@Test
	public void reportingEntryPublishedMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.reportingEntryPublished(newTestIdentifier(), ReportEntry.from("foo", "bar"));
		String[] split = stringWriter.toString().split(System.lineSeparator());

		assertEquals(2, split.length);
		assertAll("lines in the message", () -> assertEquals("Reported:    failingTest [[engine:junit]]", split[0]),
			() -> assertTrue(split[1].startsWith(INDENTATION + "=> Reported values: ReportEntry [timestamp =")),
			() -> assertTrue(split[1].endsWith(", foo = 'bar']")));
	}

	@Test
	public void exceptionMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.executionFinished(newTestIdentifier(),
			failed(new Throwable("Fail\n\texpected: <foo> but was: <bar>")));
		String output = stringWriter.toString();

		String expected = "Finished:    failingTest [[engine:junit]]\n" + INDENTATION + "=> Exception: Fail\n"
				+ INDENTATION + "\texpected: <foo> but was: <bar>\n";

		assertEquals(expected, output);
	}

	private static TestIdentifier newTestIdentifier() {
		TestDescriptorStub testDescriptor = new TestDescriptorStub(UniqueId.forEngine("junit"), "failingTest");
		return TestIdentifier.from(testDescriptor);
	}

}<commit_msg>Ensure build passes on Microsoft Windows<commit_after>/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.platform.console.tasks;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.platform.console.tasks.ColoredPrintingTestListener.INDENTATION;
import static org.junit.platform.engine.TestExecutionResult.failed;

import java.io.PrintWriter;
import java.io.StringWriter;

import org.junit.jupiter.api.Test;
import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.reporting.ReportEntry;
import org.junit.platform.engine.test.TestDescriptorStub;
import org.junit.platform.launcher.TestIdentifier;

/**
 * @since 1.0
 */
public class ColoredPrintingTestListenerTests {

	private static final String EOL = System.lineSeparator();

	@Test
	public void executionSkippedMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.executionSkipped(newTestIdentifier(), "Test" + EOL + "\tdisabled");
		String output = stringWriter.toString();

		// @formatter:off
		String expected = "Skipped:     failingTest [[engine:demo-engine]]" + EOL
				+ INDENTATION + "=> Reason: Test" + EOL
				+ INDENTATION + "\tdisabled" + EOL;
		// @formatter:on

		assertEquals(expected, output);
	}

	@Test
	public void reportingEntryPublishedMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.reportingEntryPublished(newTestIdentifier(), ReportEntry.from("foo", "bar"));
		String[] split = stringWriter.toString().split(System.lineSeparator());

		assertEquals(2, split.length);
		assertAll("lines in the message",
			() -> assertEquals("Reported:    failingTest [[engine:demo-engine]]", split[0]),
			() -> assertTrue(split[1].startsWith(INDENTATION + "=> Reported values: ReportEntry [timestamp =")),
			() -> assertTrue(split[1].endsWith(", foo = 'bar']")));
	}

	@Test
	public void exceptionMessageIndented() {
		StringWriter stringWriter = new StringWriter();
		PrintWriter out = new PrintWriter(stringWriter);
		ColoredPrintingTestListener listener = new ColoredPrintingTestListener(out, true);

		listener.executionFinished(newTestIdentifier(),
			failed(new Throwable("Fail" + EOL + "\texpected: <foo> but was: <bar>")));
		String output = stringWriter.toString();

		// @formatter:off
		String expected = "Finished:    failingTest [[engine:demo-engine]]" + EOL
				+ INDENTATION + "=> Exception: Fail" + EOL
				+ INDENTATION + "\texpected: <foo> but was: <bar>" + EOL;
		// @formatter:on

		assertEquals(expected, output);
	}

	private static TestIdentifier newTestIdentifier() {
		TestDescriptorStub testDescriptor = new TestDescriptorStub(UniqueId.forEngine("demo-engine"), "failingTest");
		return TestIdentifier.from(testDescriptor);
	}

}
{'fraction_non_alphanumeric': 0.12077368260737131, 'fraction_numerical': 0.005482790130977765, 'mean_word_length': 5.4955489614243325, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4632777', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1869, 'n_words': 431}