Skip to content

Commit 6f97b98

Browse files
committed
Add tests on Windows CI
1 parent 3d22958 commit 6f97b98

File tree

9 files changed

+29
-12
lines changed

9 files changed

+29
-12
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@v10
2121
- run: sbt '++2.12.13 docs/mdoc'
22+
test-windows:
23+
name: "Windows 'test'"
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 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(Paths.get(v.path).getFileName().toString()).getOrElse(v.path)
2327
case _ => input.syntax
2428
}
2529
def relativeFilename(sourceroot: AbsolutePath): RelativePath =

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

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ abstract class BaseCliSuite extends BaseSuite {
2626
override def postProcessObtained: Map[Compat.ScalaVersion, String => String] =
2727
Map(
2828
Compat.All -> { old =>
29+
pprint.log(out().toString())
30+
pprint.log(in().toString())
2931
old
3032
.replace(out().toString(), "<output>")
3133
.replace(in().toString(), "<input>")

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/FileSuite.scala

+6-5
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

@@ -124,7 +125,7 @@ class FileSuite extends BaseCliSuite {
124125
includeOutputPath = includeOutputPath,
125126
onStdout = { stdout =>
126127
assertNoDiff(
127-
stdout,
128+
stdout.replace('\\', '/'),
128129
"""|info: Compiling 3 files to <output>
129130
|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.
130131
| -- root --> <input>/readme.md:1
@@ -158,7 +159,7 @@ class FileSuite extends BaseCliSuite {
158159
includeOutputPath = includeOutputPath,
159160
onStdout = { stdout =>
160161
assertNoDiff(
161-
stdout,
162+
stdout.replace('\\', '/'),
162163
"""|info: Compiling 3 files to <output>
163164
|error: <input>/hello1.sc:1:23: type mismatch;
164165
| found : Int(42)
@@ -260,7 +261,7 @@ class FileSuite extends BaseCliSuite {
260261
includeOutputPath = includeOutputPath,
261262
onStdout = { stdout =>
262263
assertNoDiff(
263-
stdout,
264+
stdout.replace('\\', '/'),
264265
"""|info: Compiling 2 files to <output>
265266
|error: <input>/readme.md:2:16: unimports are not supported for $file imports. To fix this problem, remove the unimported symbol.
266267
|import $file.{ hello0 => _ }
@@ -286,7 +287,7 @@ class FileSuite extends BaseCliSuite {
286287
includeOutputPath = includeOutputPath,
287288
onStdout = { stdout =>
288289
assertNoDiff(
289-
stdout,
290+
stdout.replace('\\', '/'),
290291
"""|info: Compiling 2 files to <output>
291292
|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.
292293
|import $file._
@@ -320,7 +321,7 @@ class FileSuite extends BaseCliSuite {
320321
// import qualifier. This works because we employ token edit distance to
321322
// map positions from the instrumented source to the original source.
322323
assertNoDiff(
323-
stdout,
324+
stdout.replace('\\', '/'),
324325
"""|info: Compiling 3 files to <output>
325326
|error: <input>/inner/hello1.sc:2:11: value number is not a member of object $file.hello0
326327
|val one = hello0.number + 1

0 commit comments

Comments
 (0)