Skip to content

Commit 49ba3cf

Browse files
authored
Implement fix for #296 (#297)
Simply replace '"fail"' with 'msg' to use the provided custom error message Additionally: * Add 3.3.1 as a cross-build target * Put quotes in the "Common Commands" section of the README so that the commands are directly copyable for Zsh, Csh, Bash, etc. Should work on Windows too
1 parent 579132a commit 49ba3cf

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ compiled to Scala.js. These all live in `demo/`.
4646
Common Commands
4747
---------------
4848

49-
- `mill -w fastparse.jvm[2.12.10].test` runs the main testsuite. If you're
49+
Note: you should use mill 0.11 or later.
50+
51+
- `mill -w "fastparse.jvm[2.12.10].test"` runs the main testsuite. If you're
5052
hacking on FastParse, this is often where you want to go
5153

5254
- You can run the other suites via `fastparse.js`, `scalaparse.jvm`, etc. if you
5355
wish, but I typically don't and leave that to CI unless I'm actively working
5456
on the sub-project
5557

56-
- You can use `mill -w fastparse.jvm[_].test` to run it under different Scala
58+
- You can use `mill -w "fastparse.jvm[_].test"` to run it under different Scala
5759
versions, but again I usually don't bother
5860

5961
- `mill __.test.test` is the aggregate test-all command, but is pretty slow. You
60-
can use `mill __.jvm[2.12.10].test` to run all tests only under JVM/Scala-2.12,
62+
can use `mill "__.jvm[2.12.17].test"` to run all tests only under JVM/Scala-2.12,
6163
which is much faster and catches most issues
6264

6365
- `mill demo.fullOpt && sbt readme/run` builds the documentation site, which can

build.sc

+33-18
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ import $ivy.`com.github.lolgab::mill-mima::0.0.23`
1313
import de.tobiasroeser.mill.vcs.version.VcsVersion
1414
import com.github.lolgab.mill.mima._
1515

16-
val scala31 = "3.2.2"
16+
val scala33 = "3.3.1"
17+
val scala32 = "3.2.2"
1718
val scala213 = "2.13.10"
1819
val scala212 = "2.12.17"
1920
val scala211 = "2.11.12"
2021
val scalaJS1 = "1.12.0"
2122
val scalaNative04 = "0.4.9"
22-
val crossVersions = Seq(scala31, scala213, scala212, scala211)
23+
val crossVersions = Seq(scala33, scala32, scala213, scala212, scala211)
24+
val scalaNativeCrossVersions = crossVersions.filterNot(v => v == scala32 || v == scala33 )
2325

2426
object fastparse extends Module{
2527
object jvm extends Cross[fastparseJvmModule](crossVersions)
2628
trait fastparseJvmModule extends FastparseModule{
27-
object test extends ScalaModuleTests with CommonTestModule
29+
object test extends ScalaTests with CommonTestModule
2830
}
2931

3032
object js extends Cross[fastparseJsModule](crossVersions)
@@ -42,14 +44,15 @@ object fastparse extends Module{
4244

4345
override def scalacOptions = super.scalacOptions() ++ sourceMapOptions()
4446

45-
object test extends ScalaJSModuleTests with CommonTestModule
47+
object test extends ScalaJSTests with CommonTestModule
4648
}
4749

48-
object native extends Cross[fastparseNativeModule](crossVersions)
50+
51+
object native extends Cross[fastparseNativeModule](scalaNativeCrossVersions)
4952
trait fastparseNativeModule extends FastparseModule with ScalaNativeModule {
5053
def scalaNativeVersion = scalaNative04
5154

52-
object test extends ScalaNativeModuleTests with CommonTestModule
55+
object test extends ScalaNativeTests with CommonTestModule
5356
}
5457
}
5558

@@ -119,7 +122,7 @@ object scalaparse extends Module{
119122
object jvm extends Cross[ScalaParseJvmModule](crossVersions)
120123
trait ScalaParseJvmModule extends ExampleParseJvmModule
121124

122-
object native extends Cross[ScalaParseNativeModule](crossVersions)
125+
object native extends Cross[ScalaParseNativeModule](scalaNativeCrossVersions)
123126
trait ScalaParseNativeModule extends ExampleParseNativeModule
124127
}
125128

@@ -130,7 +133,8 @@ object cssparse extends Module{
130133
object jvm extends Cross[CssParseJvmModule](crossVersions)
131134
trait CssParseJvmModule extends ExampleParseJvmModule
132135

133-
object native extends Cross[CssParseNativeModule](crossVersions)
136+
object native extends Cross[CssParseNativeModule](scalaNativeCrossVersions)
137+
134138
trait CssParseNativeModule extends ExampleParseNativeModule
135139
}
136140

@@ -141,21 +145,21 @@ object pythonparse extends Module{
141145
object jvm extends Cross[PythonParseJvmModule](crossVersions)
142146
trait PythonParseJvmModule extends ExampleParseJvmModule
143147

144-
object native extends Cross[PythonParseNativeModule](crossVersions)
148+
object native extends Cross[PythonParseNativeModule](scalaNativeCrossVersions)
145149
trait PythonParseNativeModule extends ExampleParseNativeModule
146150
}
147151

148152
trait ExampleParseJsModule extends CommonCrossModule with ScalaJSModule{
149153
def moduleDeps = Seq(fastparse.js())
150154
def scalaJSVersion = scalaJS1
151155

152-
object test extends ScalaJSModuleTests with CommonTestModule
156+
object test extends ScalaJSTests with CommonTestModule
153157
}
154158

155159
trait ExampleParseJvmModule extends CommonCrossModule{
156160
def moduleDeps = Seq(fastparse.jvm())
157161

158-
object test extends ScalaModuleTests with CommonTestModule{
162+
object test extends ScalaTests with CommonTestModule{
159163
def ivyDeps = super.ivyDeps() ++ Agg(
160164
ivy"net.sourceforge.cssparser:cssparser:0.9.18",
161165
) ++ Agg.when(!isScala3(crossScalaVersion))(
@@ -168,7 +172,7 @@ trait ExampleParseNativeModule extends CommonCrossModule with ScalaNativeModule{
168172
def scalaNativeVersion = scalaNative04
169173
def moduleDeps = Seq(fastparse.native())
170174

171-
object test extends ScalaNativeModuleTests with CommonTestModule
175+
object test extends ScalaNativeTests with CommonTestModule
172176
}
173177

174178
trait CommonCrossModule extends CrossScalaModule with PublishModule with PlatformScalaModule{
@@ -218,14 +222,25 @@ object perftests extends Module{
218222
)
219223
}
220224

221-
object benchScala3 extends PerfTestModule {
222-
def scalaVersion0 = scala31
225+
object benchScala33 extends PerfTestModule {
226+
def scalaVersion0 = scala33
227+
def sources = T.sources { bench2.sources() }
228+
def moduleDeps = Seq(
229+
scalaparse.jvm(scala33).test,
230+
pythonparse.jvm(scala33).test,
231+
cssparse.jvm(scala33).test,
232+
fastparse.jvm(scala33).test,
233+
)
234+
}
235+
236+
object benchScala32 extends PerfTestModule {
237+
def scalaVersion0 = scala32
223238
def sources = T.sources{ bench2.sources() }
224239
def moduleDeps = Seq(
225-
scalaparse.jvm(scala31).test,
226-
pythonparse.jvm(scala31).test,
227-
cssparse.jvm(scala31).test,
228-
fastparse.jvm(scala31).test,
240+
scalaparse.jvm(scala32).test,
241+
pythonparse.jvm(scala32).test,
242+
cssparse.jvm(scala32).test,
243+
fastparse.jvm(scala32).test,
229244
)
230245
}
231246

fastparse/src/fastparse/SharedPackageDefs.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ trait SharedPackageDefs {
161161
*/
162162
def Fail(msg: String)(implicit ctx: P[_]): P[Nothing] = {
163163
val res = ctx.freshFailure()
164-
if (ctx.verboseFailures) ctx.reportTerminalMsg(ctx.index, () => "fail")
164+
if (ctx.verboseFailures) ctx.reportTerminalMsg(ctx.index, () => msg)
165165
res
166166
}
167167
/**

fastparse/test/src/fastparse/ExampleTests.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object ExampleTests extends TestSuite{
133133

134134
def failWithLabel[$: P] = P( Fail("custom fail msg") )
135135
val Parsed.Failure(_, 0, extra) = parse("asdad", failWithLabel(_))
136-
assert(extra.trace().longMsg == """Expected failWithLabel:1:1 / fail:1:1, found "asdad"""")
136+
assert(extra.trace().longMsg == """Expected failWithLabel:1:1 / custom fail msg:1:1, found "asdad"""")
137137
}
138138

139139
test("index"){

0 commit comments

Comments
 (0)