Skip to content

Commit

Permalink
pass test on 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Aug 20, 2023
1 parent 55a9098 commit 9e927bf
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 21 deletions.
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ ThisBuild / version := Properties.envOrElse("VERSION", "0.0.0-dev") +
(if ((ThisBuild / isSnapshot ).value) "-SNAPSHOT" else "")
ThisBuild / isSnapshot := Properties.envOrElse("IS_SNAPSHOT","true").toBoolean
ThisBuild / organization := "org.apache.toree.kernel"
ThisBuild / crossScalaVersions := Seq("2.13.8", "2.12.15")
//ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.8")
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.head
ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.8")
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions).value.last
ThisBuild / Dependencies.sparkVersion := {
val envVar = "APACHE_SPARK_VERSION"
val defaultVersion = "3.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import org.mockito.ArgumentMatchers.{eq => mockEq, _}
import org.mockito.Mockito._
import org.scalatest.concurrent.{Eventually, ScalaFutures}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.time.{Milliseconds, Span}
import org.scalatest.time.{Milliseconds, Seconds, Span}
import org.scalatest.funspec.AnyFunSpecLike
import org.scalatest.matchers.should.Matchers
import org.scalatest.BeforeAndAfterEach
Expand All @@ -60,7 +60,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
{
private val TestTimeout = Timeout(10.seconds)
implicit override val patienceConfig = PatienceConfig(
timeout = scaled(Span(200, Milliseconds)),
timeout = scaled(Span(1, Seconds)),
interval = scaled(Span(5, Milliseconds))
)
private val SignatureEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import org.apache.spark.sql.{Dataset, Row}
import org.apache.toree.plugins.Plugin
import play.api.libs.json.{JsObject, Json}

import scala.collection.immutable
import scala.collection.mutable
import scala.util.Try
import org.apache.toree.plugins.annotations.Init

Expand Down Expand Up @@ -84,7 +86,8 @@ object DataFrameConverter {
def fieldToString(any: Any): String =
any match {
case null => "null"
case seq: Seq[_] => seq.mkString("[", ", ", "]")
case seq: immutable.Seq[_] => seq.mkString("[", ", ", "]")
case seq: mutable.Seq[_] => seq.mkString("[", ", ", "]")
case _ => any.toString
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.toree.plugins

import org.clapper.classutil.ClassInfo

trait ClassFinderHelper {

def wrappedGetClassesReturnVal(classes: Seq[ClassInfo]): Object = {
classes.toStream
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.toree.plugins

import org.clapper.classutil.ClassInfo

trait ClassFinderHelper {

def wrappedGetClassesReturnVal(classes: Seq[ClassInfo]): Object = {
LazyList.from(classes)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package org.apache.toree.plugins

import java.io.File
import scala.collection.immutable

import org.clapper.classutil.{Modifier, ClassFinder}
import org.clapper.classutil.{ClassFinder, Modifier}
import org.scalatestplus.mockito.MockitoSugar
import org.scalatest.OneInstancePerTest
import org.scalatest.funspec.AnyFunSpec
Expand All @@ -27,8 +28,9 @@ import org.scalatest.matchers.should.Matchers
import org.mockito.Mockito._
import test.utils.TestClassInfo


class PluginSearcherSpec extends AnyFunSpec with Matchers
with OneInstancePerTest with MockitoSugar
with OneInstancePerTest with MockitoSugar with ClassFinderHelper
{
private val mockClassFinder = mock[ClassFinder]
private val pluginSearcher = new PluginSearcher {
Expand Down Expand Up @@ -65,7 +67,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
name = "abstract.plugin",
modifiers = Set(Modifier.Abstract)
)
private val classInfos = Seq(
private val classInfos = immutable.Seq(
pluginClassInfo,
directPluginClassInfo, directAsInterfacePluginClassInfo,
indirectPluginClassInfo, indirectAsInterfacePluginClassInfo,
Expand All @@ -77,7 +79,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins directly extending the Plugin class") {
val expected = directPluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.internal.map(_.name)

Expand All @@ -87,7 +89,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins directly extending the Plugin trait") {
val expected = directAsInterfacePluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.internal.map(_.name)

Expand All @@ -97,7 +99,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins indirectly extending the Plugin class") {
val expected = indirectPluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.internal.map(_.name)

Expand All @@ -107,7 +109,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins indirectly extending the Plugin trait") {
val expected = indirectAsInterfacePluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.internal.map(_.name)

Expand All @@ -120,7 +122,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
traitPluginClassInfo.name
)

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.internal.map(_.name)

Expand All @@ -132,7 +134,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins directly extending the Plugin class") {
val expected = directPluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.search().map(_.name).toSeq

Expand All @@ -142,7 +144,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins directly extending the Plugin trait") {
val expected = directAsInterfacePluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.search().map(_.name).toSeq

Expand All @@ -152,7 +154,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins indirectly extending the Plugin class") {
val expected = indirectPluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.search().map(_.name).toSeq

Expand All @@ -162,7 +164,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
it("should find any plugins indirectly extending the Plugin trait") {
val expected = indirectAsInterfacePluginClassInfo.name

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.search().map(_.name).toSeq

Expand All @@ -175,7 +177,7 @@ class PluginSearcherSpec extends AnyFunSpec with Matchers
traitPluginClassInfo.name
)

doReturn(classInfos.toStream, Nil: _*).when(mockClassFinder).getClasses()
doReturn(wrappedGetClassesReturnVal(classInfos), Nil: _*).when(mockClassFinder).getClasses()

val actual = pluginSearcher.search().map(_.name).toSeq

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I

definitions.append(s"$name: $func$funcType").append("\n")

case NamedResult(name, vtype, value) if read(name).nonEmpty =>
case NamedResult(_, _, name, vtype, value) if read(name).nonEmpty =>

val result = read(name)

Expand Down Expand Up @@ -419,7 +419,7 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I
object ScalaInterpreter {

val HigherOrderFunction: Regex = """(\w+):\s+(\(\s*.*=>\s*\w+\))(\w+)\s*.*""".r
val NamedResult: Regex = """(\w+):\s+([^=]+)\s+=\s*(.*)""".r
val NamedResult: Regex = """((val|var)\s+)?(\w+):\s+([^=]+)\s+=\s*(.*)""".r
val Definition: Regex = """defined\s+(\w+)\s+(.+)""".r
val Import: Regex = """import\s+([\w\.,\{\}\s]+)""".r

Expand Down

0 comments on commit 9e927bf

Please sign in to comment.