From issues-return-133667-archive-asf-public=cust-asf.ponee.io@maven.apache.org Thu Jun 7 17:52:39 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 01F06180663 for ; Thu, 7 Jun 2018 17:52:37 +0200 (CEST) Received: (qmail 27576 invoked by uid 500); 7 Jun 2018 15:52:37 -0000 Mailing-List: contact issues-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list issues@maven.apache.org Received: (qmail 27554 invoked by uid 99); 7 Jun 2018 15:52:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2018 15:52:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A7FA01804D2; Thu, 7 Jun 2018 15:52:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.899 X-Spam-Level: * X-Spam-Status: No, score=1.899 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id pC6Yfwv6n2Yz; Thu, 7 Jun 2018 15:52:31 +0000 (UTC) Received: from mail-ua0-f180.google.com (mail-ua0-f180.google.com [209.85.217.180]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 129885F57D; Thu, 7 Jun 2018 15:52:31 +0000 (UTC) Received: by mail-ua0-f180.google.com with SMTP id z16-v6so6817419uaz.10; Thu, 07 Jun 2018 08:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vVwkwDGDpTAJeWZVWBMz/I+fOEK+7LEI9gMf57qB6Fo=; b=TA0EgjjqwyawcUK/Qnf6TnFOQz81q7NME8W/e4YigPupC5+G3/i3HZiXEdoGGjjchP DL12IzdfRVRUjyV9DiJ01g7OJU/8Lj1ZJ7hTYyiOCs8zOXYKXl0VlbLvk+1+yRxK6OIm NSv+hpo7uDgzIQ1YVJe8owYvvw6w/OKU7Sy8rdoa/LqWlqsv1mQaBmouUvAqq5vFwwD7 TpTa5pDffOFbhE1pRzw9EY5EGslOlUcxf0mCxkve84SghNw27MtKZBo+akOFU6WFll+y t9AHyeUPoQw2/PM2PYEWOJKza5EtFNBjpomH31O7xgCL6Fvo2+8LtSV2nv/bNEgtG2by w7Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vVwkwDGDpTAJeWZVWBMz/I+fOEK+7LEI9gMf57qB6Fo=; b=VQRN6bwMveKB5v0eBqL9yvlo1mM9XWR8ax98huQYfinc+Xmg/BS8gDw2rw8g1Gik/G y6yItPLj56vdCRlJH08QXC+fQhKDCeuITrttBrsyrWBGQgZqvXP9BfDwq5fdPrh1TeBb Dgcezy5uPuWZUk8rOgrHoSHRZMOy0kdqMqf+gF8prysJoM0iUvDkC1+Icmrvb+cnV8sh A/RUFLJme5tp8wFapN33BT8SHDC+nNGDLNqpidwl2Y4H1F3q/njrHpV+o3bSD9PDpuHo 1+ji14YkLR9AEjRfXceYN8aoFFS8Z2/vPmqCVVGGfh4W25p4TXJmpNstupXtASUHpXYH QpHQ== X-Gm-Message-State: APt69E0eIK9VhlONStE/ru+XCoqWQeTr8I0o+qBR7jpbOnijEUVeQQIH GffdW3Rp5SPsLiDh56gIU90BEc12suU2rA65p3E+Eg== X-Google-Smtp-Source: ADUXVKJ+nTDYNfXBHvinJx/Efce1UHWxzCkbqPxG7DxuNZtocPp2t/PzDj+dppMYyjtDXWqxRHjDFTcuhEI+ivWHMhA= X-Received: by 2002:ab0:2085:: with SMTP id r5-v6mr1574080uak.71.1528386749938; Thu, 07 Jun 2018 08:52:29 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9f:3399:0:0:0:0:0 with HTTP; Thu, 7 Jun 2018 08:52:29 -0700 (PDT) In-Reply-To: <152838616764.29625.7775934628971407580.gitbox@gitbox.apache.org> References: <152838616764.29625.7775934628971407580.gitbox@gitbox.apache.org> From: Vishal Kumar Gupta Date: Thu, 7 Jun 2018 21:22:29 +0530 Message-ID: Subject: Re: [GitHub] marcphilipp commented on a change in pull request #184: Donate current sources from junit-platform-surefire-provider To: dev@maven.apache.org Cc: issues@maven.apache.org Content-Type: multipart/related; boundary="0000000000004fb348056e0f45a9" --0000000000004fb348056e0f45a9 Content-Type: multipart/alternative; boundary="0000000000004fb346056e0f45a8" --0000000000004fb346056e0f45a8 Content-Type: text/plain; charset="UTF-8" On Thu, Jun 7, 2018 at 9:12 PM, GitBox wrote: > marcphilipp commented on a change in pull request #184: Donate current > sources from junit-platform-surefire-provider > URL: https://github.com/apache/maven-surefire/pull/184# > discussion_r193795566 > > > > ########## > File path: surefire-providers/surefire-junit-platform/src/main/java/ > org/apache/maven/surefire/junitplatform/RunListenerAdapter.java > ########## > @@ -0,0 +1,272 @@ > +package org.apache.maven.surefire.junitplatform; > + > +/* > + * Licensed to the Apache Software Foundation (ASF) under one > + * or more contributor license agreements. See the NOTICE file > + * distributed with this work for additional information > + * regarding copyright ownership. The ASF licenses this file > + * to you under the Apache License, Version 2.0 (the > + * "License"); you may not use this file except in compliance > + * with the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, > + * software distributed under the License is distributed on an > + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > + * KIND, either express or implied. See the License for the > + * specific language governing permissions and limitations > + * under the License. > + */ > + > +import static org.apache.maven.surefire.report.SimpleReportEntry.ignored; > +import static org.junit.platform.engine.TestExecutionResult.Status. > ABORTED; > +import static org.junit.platform.engine.TestExecutionResult.Status. > FAILED; > + > +import java.util.Optional; > +import java.util.Set; > +import java.util.concurrent.ConcurrentHashMap; > + > +import org.apache.maven.surefire.report.PojoStackTraceWriter; > +import org.apache.maven.surefire.report.RunListener; > +import org.apache.maven.surefire.report.SimpleReportEntry; > +import org.apache.maven.surefire.report.StackTraceWriter; > +import org.junit.platform.engine.TestExecutionResult; > +import org.junit.platform.engine.TestSource; > +import org.junit.platform.engine.support.descriptor.ClassSource; > +import org.junit.platform.engine.support.descriptor.MethodSource; > +import org.junit.platform.launcher.TestExecutionListener; > +import org.junit.platform.launcher.TestIdentifier; > +import org.junit.platform.launcher.TestPlan; > +import org.junit.platform.launcher.listeners.LegacyReportingUtils; > + > +/** > + * @since 2.22.0 > + */ > +final class RunListenerAdapter > + implements TestExecutionListener > +{ > + > + private final RunListener runListener; > + > + private TestPlan testPlan; > + > + private Set testSetNodes = > ConcurrentHashMap.newKeySet(); > + > + RunListenerAdapter( RunListener runListener ) > + { > + this.runListener = runListener; > + } > + > + @Override > + public void testPlanExecutionStarted( TestPlan testPlan ) > + { > + updateTestPlan( testPlan ); > + } > + > + @Override > + public void testPlanExecutionFinished( TestPlan testPlan ) > + { > + updateTestPlan( null ); > + } > + > + @Override > + public void executionStarted( TestIdentifier testIdentifier ) > + { > + if ( testIdentifier.isContainer() > + && testIdentifier.getSource().filter( > ClassSource.class::isInstance ).isPresent() ) > + { > + startTestSetIfPossible( testIdentifier ); > + } > + if ( testIdentifier.isTest() ) > + { > + ensureTestSetStarted( testIdentifier ); > + runListener.testStarting( createReportEntry( testIdentifier ) > ); > + } > + } > + > + @Override > + public void executionSkipped( TestIdentifier testIdentifier, String > reason ) > + { > + ensureTestSetStarted( testIdentifier ); > + String source = getLegacyReportingClassName( testIdentifier ); > + runListener.testSkipped( ignored( source, getLegacyReportingName( > testIdentifier ), reason ) ); > + completeTestSetIfNecessary( testIdentifier ); > + } > + > + @Override > + public void executionFinished( > + TestIdentifier testIdentifier, TestExecutionResult > testExecutionResult ) > + { > + if ( testExecutionResult.getStatus() == ABORTED ) > + { > + runListener.testAssumptionFailure( createReportEntry( > testIdentifier, testExecutionResult ) ); > + } > + else if ( testExecutionResult.getStatus() == FAILED ) > + { > + reportFailedTest( testIdentifier, testExecutionResult ); > + } > + else if ( testIdentifier.isTest() ) > + { > + runListener.testSucceeded( createReportEntry( testIdentifier > ) ); > + } > + completeTestSetIfNecessary( testIdentifier ); > + } > + > + private void updateTestPlan( TestPlan testPlan ) > + { > + this.testPlan = testPlan; > + testSetNodes.clear(); > + } > + > + private void ensureTestSetStarted( TestIdentifier testIdentifier ) > + { > + if ( isTestSetStarted( testIdentifier ) ) > + { > + return; > + } > + if ( testIdentifier.isTest() ) > + { > + startTestSet( testPlan.getParent( testIdentifier ).orElse( > testIdentifier ) ); > + } > + else > + { > + startTestSet( testIdentifier ); > + } > + } > + > + private boolean isTestSetStarted( TestIdentifier testIdentifier ) > + { > + return testSetNodes.contains( testIdentifier ) > + || testPlan.getParent( testIdentifier ).map( > this::isTestSetStarted ).orElse( false ); > > Review comment: > No real engine will do that so I don't think it's crucial to introduce > a (temporary) workaround in Surefire. > > ---------------------------------------------------------------- > This is an automated message from the Apache Git Service. > To respond to the message, please log on GitHub and use the > URL above to go to the specific comment. > > For queries about this service, please contact Infrastructure at: > users@infra.apache.org > > > With regards, > Apache Git Services > --0000000000004fb346056e0f45a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable





On Thu, Jun 7, 2= 018 at 9:12 PM, GitBox <git@apache.org> wrote:
marcphilipp commented on a change in pull request #184: D= onate current sources from junit-platform-surefire-provider
URL: https://github.com/apach= e/maven-surefire/pull/184#discussion_r193795566



=C2=A0##########
=C2=A0File path: surefire-providers/surefire-junit-platform/src/main/j= ava/org/apache/maven/surefire/junitplatform/RunListenerAdapt= er.java
=C2=A0##########
=C2=A0@@ -0,0 +1,272 @@
+package org.apache.maven.surefire.junitplatform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.=C2=A0 See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.=C2=A0 The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance + * with the License.=C2=A0 You may obtain a copy of the License at
+ *
+ *=C2=A0 =C2=A0 =C2=A0http://www.apache.org/licenses= /LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.=C2=A0 See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static org.apache.maven.surefire.report.SimpleReportEntry.ignored;
+import static org.junit.platform.engine.TestExecutionResult.Status.ABORTED;
+import static org.junit.platform.engine.TestExecutionResult.Status.FAILED;
+
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.maven.surefire.report.PojoStackTraceWriter;
+import org.apache.maven.surefire.report.RunListener;
+import org.apache.maven.surefire.report.SimpleReportEntry;
+import org.apache.maven.surefire.report.StackTraceWriter;
+import org.junit.platform.engine.TestExecutionResult;
+import org.junit.platform.engine.TestSource;
+import org.junit.platform.engine.support.descriptor.ClassSource;=
+import org.junit.platform.engine.support.descriptor.MethodSource= ;
+import org.junit.platform.launcher.TestExecutionListener;
+import org.junit.platform.launcher.TestIdentifier;
+import org.junit.platform.launcher.TestPlan;
+import org.junit.platform.launcher.listeners.LegacyReportingUtil= s;
+
+/**
+ * @since 2.22.0
+ */
+final class RunListenerAdapter
+=C2=A0 =C2=A0 implements TestExecutionListener
+{
+
+=C2=A0 =C2=A0 private final RunListener runListener;
+
+=C2=A0 =C2=A0 private TestPlan testPlan;
+
+=C2=A0 =C2=A0 private Set<TestIdentifier> testSetNodes =3D Concurren= tHashMap.newKeySet();
+
+=C2=A0 =C2=A0 RunListenerAdapter( RunListener runListener )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.runListener =3D runListener;
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 @Override
+=C2=A0 =C2=A0 public void testPlanExecutionStarted( TestPlan testPlan ) +=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 updateTestPlan( testPlan );
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 @Override
+=C2=A0 =C2=A0 public void testPlanExecutionFinished( TestPlan testPlan ) +=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 updateTestPlan( null );
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 @Override
+=C2=A0 =C2=A0 public void executionStarted( TestIdentifier testIdentifier = )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ( testIdentifier.isContainer()
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 && testIdentifier.getSource().filter( ClassSource.c= lass::isInstance ).isPresent() )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 startTestSetIfPossible( testIden= tifier );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ( testIdentifier.isTest() )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ensureTestSetStarted( testIdenti= fier );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 runListener.testStarting( create= ReportEntry( testIdentifier ) );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 @Override
+=C2=A0 =C2=A0 public void executionSkipped( TestIdentifier testIdentifier,= String reason )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 ensureTestSetStarted( testIdentifier );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 String source =3D getLegacyReportingClassName(= testIdentifier );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 runListener.testSkipped( ignored( source, getL= egacyReportingName( testIdentifier ), reason ) );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 completeTestSetIfNecessary( testIdentifier );<= br> +=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 @Override
+=C2=A0 =C2=A0 public void executionFinished(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Test= Identifier testIdentifier, TestExecutionResult testExecutionResult )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ( testExecutionResult.getStatus() =3D= =3D ABORTED )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 runListener.testAssumptionF= ailure( createReportEntry( testIdentifier, testExecutionResult ) );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else if ( testExecutionResult.getStatus()= =3D=3D FAILED )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 reportFailedTest( testIdentifier= , testExecutionResult );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else if ( testIdentifier.isTest() )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 runListener.testSucceeded( creat= eReportEntry( testIdentifier ) );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 completeTestSetIfNecessary( testIdentifier );<= br> +=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 private void updateTestPlan( TestPlan testPlan )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.testPlan =3D testPlan;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 testSetNodes.clear();
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 private void ensureTestSetStarted( TestIdentifier testIdenti= fier )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ( isTestSetStarted( testIdentifier ) )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ( testIdentifier.isTest() )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 startTestSet( testPlan.getParent= ( testIdentifier ).orElse( testIdentifier ) );
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 else
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 startTestSet( testIdentifier );<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
+=C2=A0 =C2=A0 }
+
+=C2=A0 =C2=A0 private boolean isTestSetStarted( TestIdentifier testIdentif= ier )
+=C2=A0 =C2=A0 {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 return testSetNodes.contains( testIdentifier )=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 || testPlan.getParent( testIdentifier ).map( this::isTestSetStar= ted ).orElse( false );

=C2=A0Review comment:
=C2=A0 =C2=A0No real engine will do that so I don't think it's cruc= ial to introduce a (temporary) workaround in Surefire.

----------------------------------------------------------------<= br> This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

--0000000000004fb346056e0f45a8-- --0000000000004fb348056e0f45a9--