Skip to content

Commit 7ba0cbe

Browse files
committed
Add tests on Windows CI
1 parent 38a7121 commit 7ba0cbe

File tree

13 files changed

+93
-65
lines changed

13 files changed

+93
-65
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* eol=lf
2+
*.png eol=autocrlf

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ jobs:
1919
- uses: actions/checkout@v2
2020
- uses: olafurpg/setup-scala@v11
2121
- run: sbt '++2.12.13 docs/mdoc'
22+
test-windows:
23+
name: "Windows"
24+
runs-on: windows-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: olafurpg/setup-scala@v10
28+
with:
29+
java-version: adopt@1.11
30+
- run: sbt '++2.13.5 test'
31+
shell: bash
2232
test:
2333
name: ${{ matrix.command }} ${{ matrix.java }}
2434
runs-on: ubuntu-latest

.jvmopts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-Xss4m
22
-Xms1G
3-
-Xmx4G
3+
-Xmx2G
44
-XX:ReservedCodeCacheSize=1024m
55
-XX:+TieredCompilation
66
-XX:+CMSClassUnloadingEnabled

cli/src/main/scala/mdoc/internal/cli/CliEnrichments.scala

+4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ import coursierapi.Dependency
1414
import scala.meta.internal.io.FileIO
1515
import scala.meta.internal.inputs._
1616
import java.io.PrintStream
17+
import scala.util.Try
1718

1819
trait CliEnrichments {
1920
implicit class XtensionInputMdoc(input: Input) {
2021
def filename: String =
2122
input match {
2223
case s: Input.Slice => s.input.filename
24+
case f: Input.File => f.path.filename
25+
case v: Input.VirtualFile =>
26+
Try(AbsolutePath(Paths.get(v.path)).filename).getOrElse(v.path)
2327
case _ => input.syntax
2428
}
2529
def relativeFilename(sourceroot: AbsolutePath): RelativePath =

mdoc-sbt/src/test/scala/tests/RelativizeSuite.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
package tests
22

3-
import java.nio.file.Paths
4-
import munit.TestOptions
53
import munit.FunSuite
4+
import munit.TestOptions
65
import sbtdocusaurus.internal.Relativize
6+
7+
import java.nio.file.Files
8+
import java.nio.file.Paths
79
import scala.meta.internal.io.PathIO
10+
import scala.meta.io.AbsolutePath
811
import scala.meta.testkit.StringFS
912

1013
class RelativizeSuite extends FunSuite {
1114

1215
def check(name: TestOptions, original: String, expected: String): Unit = {
1316
test(name) {
14-
val root = StringFS.fromString(original)
17+
val root = AbsolutePath(Files.createTempDirectory("mdoc"))
18+
StringFS.fromString(original, root)
1519
Relativize.htmlSite(root.toNIO)
16-
root.toRelative(PathIO.workingDirectory).toURI(true)
1720
val isTrivial = Set(
1821
"<html>",
1922
"<body>",

mdoc/src/main/scala-2/mdoc/internal/markdown/MarkdownCompiler.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ class MarkdownCompiler(
7070
}
7171

7272
private def toSource(input: Input): BatchSourceFile = {
73-
val filename = Paths.get(input.syntax).getFileName.toString
74-
new BatchSourceFile(filename, new String(input.chars))
73+
new BatchSourceFile(input.filename, new String(input.chars))
7574
}
7675

7776
def shutdown(): Unit = {

mdoc/src/main/scala-3/mdoc/internal/markdown/MarkdownCompiler.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ class MarkdownCompiler(
9898
}
9999

100100
private def toSource(input: Input): SourceFile = {
101-
val filename = Paths.get(input.syntax).getFileName.toString
102-
SourceFile.virtual(filename, new String(input.chars))
101+
SourceFile.virtual(input.filename, new String(input.chars))
103102
}
104103

105104
private def toInput(sourceFile: ISourceFile): Input = {

tests/unit/src/main/scala/tests/cli/BaseCliSuite.scala

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ abstract class BaseCliSuite extends BaseSuite {
2626
override def postProcessObtained: Map[Compat.ScalaVersion, String => String] =
2727
Map(
2828
Compat.All -> { old =>
29-
old
30-
.replace(out().toString(), "<output>")
31-
.replace(in().toString(), "<input>")
32-
.linesIterator
33-
.filterNot(line => line.startsWith("info: Compiled in"))
34-
.mkString("\n")
29+
{
30+
val outDir = out().toString().replace("\\", "/")
31+
val inDir = in().toString().replace("\\", "/")
32+
old
33+
.replace("\\", "/")
34+
.replace(outDir, "<output>")
35+
.replace(inDir, "<input>")
36+
.linesIterator
37+
.filterNot(line => line.startsWith("info: Compiled in"))
38+
.mkString("\n")
39+
}
3540
}
3641
)
3742
override def munitFixtures: Seq[Fixture[_]] = List(in, out)

tests/unit/src/main/scala/tests/markdown/BaseMarkdownSuite.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ abstract class BaseMarkdownSuite extends tests.BaseSuite {
6565
test(name) {
6666
val reporter = newReporter()
6767
val context = newContext(settings, reporter)
68-
val input = Input.VirtualFile(name.name + ".md", original)
68+
val input = Input.VirtualFile(name.name.replace(':', '-') + ".md", original)
6969
val file = InputFile.fromRelativeFilename(input.path, settings)
7070
Markdown.toMarkdown(input, context, file, baseSettings.site, reporter, settings)
7171
assert(reporter.hasErrors, "Expected errors but reporter.hasErrors=false")
@@ -90,7 +90,7 @@ abstract class BaseMarkdownSuite extends tests.BaseSuite {
9090
test(name) {
9191
val reporter = newReporter()
9292
val context = newContext(settings, reporter)
93-
val input = Input.VirtualFile(name.name + ".md", original)
93+
val input = Input.VirtualFile(name.name.replace(":", "-") + ".md", original)
9494
val file = InputFile.fromRelativeFilename(input.path, settings)
9595
val obtained =
9696
Markdown.toMarkdown(input, context, file, baseSettings.site, reporter, settings)

tests/unit/src/test/scala/tests/imports/DependencySuite.scala

+37-17
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tests.imports
22

33
import tests.markdown.BaseMarkdownSuite
44
import tests.markdown.Compat
5+
import scala.util.Properties
56

67
class DependencySuite extends BaseMarkdownSuite {
78
val userHome = System.getProperty("user.home")
@@ -79,23 +80,42 @@ class DependencySuite extends BaseMarkdownSuite {
7980
|import $dep.`org.scalameta::munit:0.7.5` // resolves OK
8081
|println(42)
8182
|```
82-
| """.stripMargin,
83-
"""|error: dep-error.md:3:49: Error downloading org.scalameta:foobar:1.2.1
84-
|<redacted user.home>
85-
| not found: https://repo1.maven.org/maven2/org/scalameta/foobar/1.2.1/foobar-1.2.1.pom
86-
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
87-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88-
|error: dep-error.md:4:13: Error downloading org.scalameta:not-exists_2.13.6:2.3.4
89-
|<redacted user.home>
90-
| not found: https://repo1.maven.org/maven2/org/scalameta/not-exists_2.13.6/2.3.4/not-exists_2.13.6-2.3.4.pom
91-
|import $dep.`org.scalameta:::not-exists:2.3.4`
92-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93-
|error: dep-error.md:3:13: Error downloading org.scalameta:mmunit_2.13:2.3.4
94-
|<redacted user.home>
95-
| not found: https://repo1.maven.org/maven2/org/scalameta/mmunit_2.13/2.3.4/mmunit_2.13-2.3.4.pom
96-
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
97-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98-
|""".stripMargin
83+
| """.stripMargin, {
84+
if (Properties.isWin)
85+
"""|error: dep-error.md:3:13: Error downloading org.scalameta:mmunit_2.13:2.3.4
86+
|<redacted user.home>
87+
| not found: https://repo1.maven.org/maven2/org/scalameta/mmunit_2.13/2.3.4/mmunit_2.13-2.3.4.pom
88+
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
90+
|error: dep-error.md:3:49: Error downloading org.scalameta:foobar:1.2.1
91+
|<redacted user.home>
92+
| not found: https://repo1.maven.org/maven2/org/scalameta/foobar/1.2.1/foobar-1.2.1.pom
93+
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
94+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95+
|error: dep-error.md:4:13: Error downloading org.scalameta:not-exists_2.13.6:2.3.4
96+
|<redacted user.home>
97+
| not found: https://repo1.maven.org/maven2/org/scalameta/not-exists_2.13.6/2.3.4/not-exists_2.13.6-2.3.4.pom
98+
|import $dep.`org.scalameta:::not-exists:2.3.4`
99+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100+
|""".stripMargin
101+
else
102+
"""|error: dep-error.md:3:49: Error downloading org.scalameta:foobar:1.2.1
103+
|<redacted user.home>
104+
| not found: https://repo1.maven.org/maven2/org/scalameta/foobar/1.2.1/foobar-1.2.1.pom
105+
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
106+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107+
|error: dep-error.md:4:13: Error downloading org.scalameta:not-exists_2.13.6:2.3.4
108+
|<redacted user.home>
109+
| not found: https://repo1.maven.org/maven2/org/scalameta/not-exists_2.13.6/2.3.4/not-exists_2.13.6-2.3.4.pom
110+
|import $dep.`org.scalameta:::not-exists:2.3.4`
111+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112+
|error: dep-error.md:3:13: Error downloading org.scalameta:mmunit_2.13:2.3.4
113+
|<redacted user.home>
114+
| not found: https://repo1.maven.org/maven2/org/scalameta/mmunit_2.13/2.3.4/mmunit_2.13-2.3.4.pom
115+
|import $dep.`org.scalameta::mmunit:2.3.4`, $dep.`org.scalameta:foobar:1.2.1`
116+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117+
|""".stripMargin
118+
}
99119
)
100120

101121
checkError(

tests/unit/src/test/scala/tests/imports/FileSuite.scala

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package tests.imports
33
import tests.markdown.BaseMarkdownSuite
44
import tests.cli.BaseCliSuite
55
import scala.meta.io.RelativePath
6+
import java.io.File
67

78
class FileSuite extends BaseCliSuite {
89

@@ -126,10 +127,10 @@ class FileSuite extends BaseCliSuite {
126127
assertNoDiff(
127128
stdout,
128129
"""|info: Compiling 3 files to <output>
129-
|error: <input>/readme.md:2:14: illegal cyclic dependency. To fix this problem, refactor the code so that no transitive $file imports end up depending on the original file.
130-
| -- root --> <input>/readme.md:1
131-
| -- depends on --> <input>/hello1.sc:0
132-
| -- depends on --> <input>/hello2.sc:0
130+
|error: readme.md:2:14: illegal cyclic dependency. To fix this problem, refactor the code so that no transitive $file imports end up depending on the original file.
131+
| -- root --> readme.md:1
132+
| -- depends on --> hello1.sc:0
133+
| -- depends on --> hello2.sc:0
133134
| -- cycle --> <input>/hello1.sc
134135
|import $file.hello1
135136
| ^^^^^^
@@ -170,7 +171,7 @@ class FileSuite extends BaseCliSuite {
170171
| required: Int
171172
|val number: Int = ""
172173
| ^^
173-
|error: <input>/readme.md:3:22: type mismatch;
174+
|error: readme.md:3:22: type mismatch;
174175
| found : String("")
175176
| required: Int
176177
|val something: Int = ""
@@ -262,7 +263,7 @@ class FileSuite extends BaseCliSuite {
262263
assertNoDiff(
263264
stdout,
264265
"""|info: Compiling 2 files to <output>
265-
|error: <input>/readme.md:2:16: unimports are not supported for $file imports. To fix this problem, remove the unimported symbol.
266+
|error: readme.md:2:16: unimports are not supported for $file imports. To fix this problem, remove the unimported symbol.
266267
|import $file.{ hello0 => _ }
267268
| ^^^^^^^^^^^
268269
|""".stripMargin
@@ -288,7 +289,7 @@ class FileSuite extends BaseCliSuite {
288289
assertNoDiff(
289290
stdout,
290291
"""|info: Compiling 2 files to <output>
291-
|error: <input>/readme.md:2:14: wildcards are not supported for $file imports. To fix this problem, explicitly import files using the `import $file.FILENAME` syntax.
292+
|error: readme.md:2:14: wildcards are not supported for $file imports. To fix this problem, explicitly import files using the `import $file.FILENAME` syntax.
292293
|import $file._
293294
| ^
294295
|""".stripMargin

tests/unit/src/test/scala/tests/markdown/ErrorSuite.scala

+4-19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class ErrorSuite extends BaseMarkdownSuite {
1010
line.startsWith("did you mean") ||
1111
line.contains("(crash.md")
1212
}
13+
// Predef lines change between versions and platforms
14+
.map(line => line.replaceAll("Predef\\.scala:\\d\\d\\d", "Predef.scala:???"))
1315
.mkString("\n")
1416
}
1517
)
@@ -32,25 +34,8 @@ class ErrorSuite extends BaseMarkdownSuite {
3234
|x + y + z
3335
|^^^^^^^^^
3436
|scala.NotImplementedError: an implementation is missing
35-
| at scala.Predef$.$qmark$qmark$qmark(Predef.scala:288)
36-
|""".stripMargin,
37-
compat = Map(
38-
Compat.Scala213 ->
39-
"""|error: crash.md:10:1: an implementation is missing
40-
|x + y + z
41-
|^^^^^^^^^
42-
|scala.NotImplementedError: an implementation is missing
43-
|<TAB>at scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
44-
|""".stripMargin.replace("<TAB>", tab),
45-
Compat.Scala3 ->
46-
// Anton: for some reason, the compiler(?) returns tab in this particular place
47-
"""|error: crash.md:10:1: an implementation is missing
48-
|x + y + z
49-
|^^^^^^^^^
50-
|scala.NotImplementedError: an implementation is missing
51-
|<TAB>at scala.Predef$.$qmark$qmark$qmark(Predef.scala:345)
52-
""".stripMargin.replace("<TAB>", tab)
53-
)
37+
| at scala.Predef$.$qmark$qmark$qmark(Predef.scala:???)
38+
|""".stripMargin
5439
)
5540

5641
checkError(

tests/unit/src/test/scala/tests/markdown/MultiModsSuite.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class MultiModsSuite extends BaseMarkdownSuite {
102102
|val x = 2
103103
|```
104104
""".stripMargin,
105-
"""|error: silent:invisible.md:2:15: invalid combination of modifiers 'silent' and 'invisible'
105+
"""|error: silent-invisible.md:2:15: invalid combination of modifiers 'silent' and 'invisible'
106106
|```scala mdoc:reset:silent:invisible
107107
| ^^^^^^^^^^^^^^^^^^^^^^
108108
""".stripMargin
@@ -115,7 +115,7 @@ class MultiModsSuite extends BaseMarkdownSuite {
115115
|val x = 2
116116
|```
117117
""".stripMargin,
118-
"""|error: fail:crash.md:2:15: invalid combination of modifiers 'crash' and 'fail'
118+
"""|error: fail-crash.md:2:15: invalid combination of modifiers 'crash' and 'fail'
119119
|```scala mdoc:reset:fail:crash
120120
| ^^^^^^^^^^^^^^^^
121121
""".stripMargin
@@ -128,7 +128,7 @@ class MultiModsSuite extends BaseMarkdownSuite {
128128
|val x = 2
129129
|```
130130
""".stripMargin,
131-
"""|error: compile-only:passthrough.md:2:15: compile-only cannot be used in combination with passthrough
131+
"""|error: compile-only-passthrough.md:2:15: compile-only cannot be used in combination with passthrough
132132
|```scala mdoc:compile-only:passthrough
133133
| ^^^^^^^^^^^^^^^^^^^^^^^^
134134
""".stripMargin
@@ -155,7 +155,7 @@ class MultiModsSuite extends BaseMarkdownSuite {
155155
|val x = "* 43"
156156
|```
157157
""".stripMargin,
158-
"""|error: nest:reset.md:5:15: the modifier 'nest' is redundant when used in combination with 'reset'. To fix this error, remove 'nest'
158+
"""|error: nest-reset.md:5:15: the modifier 'nest' is redundant when used in combination with 'reset'. To fix this error, remove 'nest'
159159
|```scala mdoc:nest:reset
160160
| ^^^^^^^^^^
161161
|""".stripMargin
@@ -168,7 +168,7 @@ class MultiModsSuite extends BaseMarkdownSuite {
168168
|val x = 2
169169
|```
170170
""".stripMargin,
171-
"""|error: compile-only:multiple.md:2:15: compile-only cannot be used in combination with to-string, silent
171+
"""|error: compile-only-multiple.md:2:15: compile-only cannot be used in combination with to-string, silent
172172
|```scala mdoc:compile-only:to-string:silent
173173
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174174
""".stripMargin

0 commit comments

Comments
 (0)