This is an automated email from the ASF dual-hosted git repository.

hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new ca3b537a22 [VL] Follow up on #9384 to avoid swallowing exceptions in 
UT (#9393)
ca3b537a22 is described below

commit ca3b537a2204eb9c1bed4da747b1d79e6c23551b
Author: Hongze Zhang <[email protected]>
AuthorDate: Wed Apr 23 12:57:34 2025 +0100

    [VL] Follow up on #9384 to avoid swallowing exceptions in UT (#9393)
---
 .../gluten/component/ComponentSkippable.scala      | 31 --------------
 .../apache/gluten/component/WithDummyBackend.scala | 49 ++++++++++++++++++++++
 .../columnar/MiscColumnarRulesSuite.scala          |  4 +-
 .../columnar/transition/TransitionSuite.scala      | 16 +------
 4 files changed, 53 insertions(+), 47 deletions(-)

diff --git 
a/gluten-core/src/test/scala/org/apache/gluten/component/ComponentSkippable.scala
 
b/gluten-core/src/test/scala/org/apache/gluten/component/ComponentSkippable.scala
deleted file mode 100644
index e07e82b007..0000000000
--- 
a/gluten-core/src/test/scala/org/apache/gluten/component/ComponentSkippable.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-package org.apache.gluten.component
-
-import org.scalatest.BeforeAndAfterAll
-import org.scalatest.funsuite.AnyFunSuite
-
-trait ComponentSkippable extends AnyFunSuite with BeforeAndAfterAll {
-  override def beforeAll(): Unit = {
-    try {
-      ensureAllComponentsRegistered()
-    } catch {
-      case _: IllegalArgumentException =>
-    }
-    super.beforeAll()
-  }
-}
diff --git 
a/gluten-core/src/test/scala/org/apache/gluten/component/WithDummyBackend.scala 
b/gluten-core/src/test/scala/org/apache/gluten/component/WithDummyBackend.scala
new file mode 100644
index 0000000000..d03385366d
--- /dev/null
+++ 
b/gluten-core/src/test/scala/org/apache/gluten/component/WithDummyBackend.scala
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.gluten.component
+
+import org.apache.gluten.backend.Backend
+import org.apache.gluten.extension.columnar.cost.{LongCoster, LongCostModel}
+import org.apache.gluten.extension.columnar.cost.LongCostModel.Legacy
+import org.apache.gluten.extension.injector.Injector
+
+import org.apache.spark.sql.execution.SparkPlan
+
+import org.scalatest.{BeforeAndAfterAll, Suite}
+
+trait WithDummyBackend extends BeforeAndAfterAll {
+  this: Suite =>
+  import WithDummyBackend._
+
+  override protected def beforeAll(): Unit = {
+    super.beforeAll()
+    DummyBackend.ensureRegistered()
+  }
+}
+
+object WithDummyBackend {
+  object DummyBackend extends Backend {
+    override def name(): String = "dummy-backend"
+    override def buildInfo(): Component.BuildInfo =
+      Component.BuildInfo("DUMMY_BACKEND", "N/A", "N/A", "N/A")
+    override def injectRules(injector: Injector): Unit = {}
+    override def costers(): Seq[LongCoster] = Seq(new LongCoster {
+      override def kind(): LongCostModel.Kind = Legacy
+      override def selfCostOf(node: SparkPlan): Option[Long] = Some(1)
+    })
+  }
+}
diff --git 
a/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/MiscColumnarRulesSuite.scala
 
b/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/MiscColumnarRulesSuite.scala
index fc09353278..12480976ce 100644
--- 
a/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/MiscColumnarRulesSuite.scala
+++ 
b/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/MiscColumnarRulesSuite.scala
@@ -16,14 +16,14 @@
  */
 package org.apache.gluten.extension.columnar
 
-import org.apache.gluten.component.ComponentSkippable
+import org.apache.gluten.component.WithDummyBackend
 import 
org.apache.gluten.extension.columnar.MiscColumnarRules.PreventBatchTypeMismatchInTableCache
 import org.apache.gluten.extension.columnar.transition.Convention
 import 
org.apache.gluten.extension.columnar.transition.TransitionSuite.BatchToRow
 
 import org.apache.spark.sql.test.SharedSparkSession
 
-class MiscColumnarRulesSuite extends SharedSparkSession with 
ComponentSkippable {
+class MiscColumnarRulesSuite extends SharedSparkSession with WithDummyBackend {
 
   test("Fix ColumnarToRowRemovalGuard not able to be copied") {
     val dummyPlan =
diff --git 
a/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/transition/TransitionSuite.scala
 
b/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/transition/TransitionSuite.scala
index 574a61b588..77dd66e12e 100644
--- 
a/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/transition/TransitionSuite.scala
+++ 
b/gluten-substrait/src/test/scala/org/apache/gluten/extension/columnar/transition/TransitionSuite.scala
@@ -16,12 +16,9 @@
  */
 package org.apache.gluten.extension.columnar.transition
 
-import org.apache.gluten.backend.Backend
-import org.apache.gluten.component.Component
+import org.apache.gluten.component.WithDummyBackend
 import org.apache.gluten.exception.GlutenException
 import org.apache.gluten.execution.{ColumnarToColumnarExec, GlutenPlan}
-import org.apache.gluten.extension.columnar.cost.{LegacyCoster, LongCoster}
-import org.apache.gluten.extension.injector.Injector
 
 import org.apache.spark.SparkConf
 import org.apache.spark.rdd.RDD
@@ -31,7 +28,7 @@ import org.apache.spark.sql.execution._
 import org.apache.spark.sql.test.SharedSparkSession
 import org.apache.spark.sql.vectorized.ColumnarBatch
 
-class TransitionSuite extends SharedSparkSession {
+class TransitionSuite extends SharedSparkSession with WithDummyBackend {
   import TransitionSuite._
 
   override protected def sparkConf: SparkConf =
@@ -40,7 +37,6 @@ class TransitionSuite extends SharedSparkSession {
 
   override protected def beforeAll(): Unit = {
     super.beforeAll()
-    new DummyBackend().ensureRegistered()
     Convention.ensureSparkRowAndBatchTypesRegistered()
     TypeA.ensureRegistered()
     TypeB.ensureRegistered()
@@ -152,12 +148,4 @@ object TransitionSuite extends TransitionSuiteBase {
     override protected def mapIterator(in: Iterator[ColumnarBatch]): 
Iterator[ColumnarBatch] =
       throw new UnsupportedOperationException()
   }
-
-  class DummyBackend extends Backend {
-    override def name(): String = "dummy-backend"
-    override def buildInfo(): Component.BuildInfo =
-      Component.BuildInfo("DUMMY_BACKEND", "N/A", "N/A", "N/A")
-    override def injectRules(injector: Injector): Unit = {}
-    override def costers(): Seq[LongCoster] = Seq(LegacyCoster)
-  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to