Skip to content

Commit dd990bd

Browse files
mboveltgodzik
authored andcommitted
Add test cases project for presentation compiler
1 parent 48cfaf2 commit dd990bd

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

.github/workflows/ci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ on:
2727
- cron: '0 3 * * *' # Every day at 3 AM
2828
workflow_dispatch:
2929

30-
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
30+
# Cancels any in-progress runs within the same group identified by workflow name and GH reference (branch or tag)
3131
# For example it would:
3232
# - terminate previous PR CI execution after pushing more changes to the same PR branch
33-
# - terminate previous on-push CI run after merging new PR to main
33+
# - terminate previous on-push CI run after merging new PR to main
3434
concurrency:
3535
group: ${{ github.workflow }}-${{ github.ref }}
3636
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
@@ -183,7 +183,7 @@ jobs:
183183
uses: actions/checkout@v4
184184

185185
- name: Test
186-
run: sbt ";scala3-bootstrapped/compile; scala3-bootstrapped/testCompilation; scala3-presentation-compiler-bootstrapped/test; scala3-language-server/test"
186+
run: sbt ";scala3-bootstrapped/compile; scala3-bootstrapped/testCompilation; scala3-presentation-compiler/test; scala3-language-server/test"
187187
shell: cmd
188188

189189
- name: build binary

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ val dist = Build.dist
2929
val `community-build` = Build.`community-build`
3030
val `sbt-community-build` = Build.`sbt-community-build`
3131
val `scala3-presentation-compiler` = Build.`scala3-presentation-compiler`
32-
val `scala3-presentation-compiler-bootstrapped` = Build.`scala3-presentation-compiler-bootstrapped`
32+
val `scala3-presentation-compiler-testcases` = Build.`scala3-presentation-compiler-testcases`
3333

3434
val sjsSandbox = Build.sjsSandbox
3535
val sjsJUnitTests = Build.sjsJUnitTests

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
108108
case _ =>
109109
tree
110110

111+
def stripNamedArg(tree: Tree) = tree match
112+
case NamedArg(_, arg) => arg
113+
case _ => tree
114+
111115
/** The number of arguments in an application */
112116
def numArgs(tree: Tree): Int = unsplice(tree) match {
113117
case Apply(fn, args) => numArgs(fn) + args.length

presentation-compiler/test/dotty/tools/pc/base/BasePCSuite.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import org.junit.runner.RunWith
2525
import scala.meta.pc.CompletionItemPriority
2626

2727
object TestResources:
28-
val scalaLibrary = BuildInfo.ideTestsDependencyClasspath.map(_.toPath).toSeq
28+
val classpath = BuildInfo.ideTestsDependencyClasspath.map(_.toPath).toSeq
2929
val classpathSearch =
30-
ClasspathSearch.fromClasspath(scalaLibrary, ExcludedPackagesHandler.default)
30+
ClasspathSearch.fromClasspath(classpath, ExcludedPackagesHandler.default)
3131

3232
@RunWith(classOf[ReusableClassRunner])
3333
abstract class BasePCSuite extends PcAssertions:
@@ -38,11 +38,11 @@ abstract class BasePCSuite extends PcAssertions:
3838
val executorService: ScheduledExecutorService =
3939
Executors.newSingleThreadScheduledExecutor()
4040
val testingWorkspaceSearch = TestingWorkspaceSearch(
41-
TestResources.scalaLibrary.map(_.toString)
41+
TestResources.classpath.map(_.toString)
4242
)
4343

4444
lazy val presentationCompiler: PresentationCompiler =
45-
val myclasspath: Seq[Path] = TestResources.scalaLibrary
45+
val myclasspath: Seq[Path] = TestResources.classpath
4646
val scalacOpts = scalacOptions(myclasspath)
4747
val search = new MockSymbolSearch(
4848
testingWorkspaceSearch,

project/Build.scala

+14-13
Original file line numberDiff line numberDiff line change
@@ -1153,26 +1153,23 @@ object Build {
11531153
)
11541154

11551155
lazy val `scala3-presentation-compiler` = project.in(file("presentation-compiler"))
1156-
.asScala3PresentationCompiler(NonBootstrapped)
1157-
lazy val `scala3-presentation-compiler-bootstrapped` = project.in(file("presentation-compiler"))
1158-
.asScala3PresentationCompiler(Bootstrapped)
1156+
.withCommonSettings(Bootstrapped)
1157+
.dependsOn(`scala3-compiler-bootstrapped`, `scala3-library-bootstrapped`, `scala3-presentation-compiler-testcases` % "test->test")
1158+
.settings(presentationCompilerSettings)
1159+
.settings(scala3PresentationCompilerBuildInfo)
11591160

1160-
def scala3PresentationCompiler(implicit mode: Mode): Project = mode match {
1161-
case NonBootstrapped => `scala3-presentation-compiler`
1162-
case Bootstrapped => `scala3-presentation-compiler-bootstrapped`
1163-
}
1164-
1165-
def scala3PresentationCompilerBuildInfo(implicit mode: Mode) =
1161+
def scala3PresentationCompilerBuildInfo =
11661162
Seq(
11671163
ideTestsDependencyClasspath := {
1168-
val dottyLib = (dottyLibrary / Compile / classDirectory).value
1164+
val testCasesLib = (`scala3-presentation-compiler-testcases` / Compile / classDirectory).value
1165+
val dottyLib = (`scala3-library-bootstrapped` / Compile / classDirectory).value
11691166
val scalaLib =
1170-
(dottyLibrary / Compile / dependencyClasspath)
1167+
(`scala3-library-bootstrapped` / Compile / dependencyClasspath)
11711168
.value
11721169
.map(_.data)
11731170
.filter(_.getName.matches("scala-library.*\\.jar"))
11741171
.toList
1175-
dottyLib :: scalaLib
1172+
testCasesLib :: dottyLib :: scalaLib
11761173
// Nil
11771174
},
11781175
Compile / buildInfoPackage := "dotty.tools.pc.buildinfo",
@@ -1231,6 +1228,10 @@ object Build {
12311228
)
12321229
}
12331230

1231+
lazy val `scala3-presentation-compiler-testcases` = project.in(file("presentation-compiler-testcases"))
1232+
.dependsOn(`scala3-compiler-bootstrapped`)
1233+
.settings(commonBootstrappedSettings)
1234+
12341235
lazy val `scala3-language-server` = project.in(file("language-server")).
12351236
dependsOn(dottyCompiler(Bootstrapped)).
12361237
settings(commonBootstrappedSettings).
@@ -1959,7 +1960,7 @@ object Build {
19591960

19601961
// FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
19611962
def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings.
1962-
aggregate(`scala3-interfaces`, dottyLibrary, dottyCompiler, tastyCore, `scala3-sbt-bridge`, scala3PresentationCompiler).
1963+
aggregate(`scala3-interfaces`, dottyLibrary, dottyCompiler, tastyCore, `scala3-sbt-bridge`, `scala3-presentation-compiler`).
19631964
bootstrappedAggregate(`scala3-language-server`, `scala3-staging`,
19641965
`scala3-tasty-inspector`, `scala3-library-bootstrappedJS`, scaladoc).
19651966
dependsOn(tastyCore).

0 commit comments

Comments
 (0)