Skip to content

Commit 8c99c85

Browse files
authored
Merge pull request #264 from DistCompiler/em-no-cs
[tracelink] add missing "no critical sections" patch
2 parents 96751bc + eb75d7d commit 8c99c85

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

src/pgo/PGo.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ object PGo {
6767
s"missing or incorrect prefix for $str",
6868
)
6969

70+
final case class ConfigExit(code: Int) extends RuntimeException
71+
7072
class Config(arguments: Seq[String]) extends ScallopConf(arguments) {
7173
banner("PGo compiler")
7274

@@ -282,6 +284,13 @@ object PGo {
282284
descr = "directory containing log files to use",
283285
default = Some(destDir()),
284286
)
287+
validate(logsDir): logsDir =>
288+
if os.list(logsDir).filter(_.last.endsWith(".log")).isEmpty
289+
then
290+
Left(
291+
s"$logsDir has no .log files - you need to pass a folder formatted as if harvest-traces generated it",
292+
)
293+
else Right(())
285294
val cfgFragmentSuffix = opt[String](
286295
descr =
287296
"suffix to add to {model_name}Validate{suffix}.cfg, when looking for a manual config file",
@@ -438,7 +447,7 @@ object PGo {
438447
println(s"$printedName: $line")
439448
}
440449
printHelp()
441-
sys.exit(1)
450+
throw ConfigExit(1)
442451
}
443452

444453
verify()
@@ -560,7 +569,10 @@ object PGo {
560569

561570
def main(args: Array[String]): Unit = {
562571
val startTime = System.currentTimeMillis()
563-
val errors = run(ArraySeq.unsafeWrapArray(args))
572+
val errors = try
573+
run(ArraySeq.unsafeWrapArray(args))
574+
catch case ConfigExit(code) =>
575+
sys.exit(code)
564576
val endTime = System.currentTimeMillis()
565577
val duration = Duration(length = endTime - startTime, unit = MILLISECONDS)
566578
if (errors.nonEmpty) {

src/pgo/tracing/HarvestTraces.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object HarvestTraces:
5050

5151
val workspaceRoot = System.getenv("MILL_WORKSPACE_ROOT") match
5252
case null => os.pwd
53-
case path => path
53+
case path => os.Path(path, os.pwd)
5454

5555
// Add a go.work that resolves the library module relative to the dev checkout
5656
if os.exists(tmpDir / "go.mod")
@@ -59,7 +59,7 @@ object HarvestTraces:
5959
tmpDir / "go.work",
6060
s"""go 1.24.0
6161
|
62-
|use ${os.pwd / "distsys"}
62+
|use ${workspaceRoot / "distsys"}
6363
|use $tmpDir
6464
|""".stripMargin,
6565
)

src/pgo/tracing/JSONToTLA.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,13 @@ final class JSONToTLA private (
471471
| /\\ __clock = <<>>
472472
| /\\ __action = <<>>
473473
|
474-
|__Next_self(self, __commit(_, _)) ==${allValidateLabels
475-
.map(name => s"\n \\/ $name(self, __commit)")
476-
.mkString}
474+
|__Next_self(self, __commit(_, _)) ==${
475+
if allValidateLabels.size == 0 then "FALSE"
476+
else
477+
allValidateLabels
478+
.map(name => s"\n \\/ $name(self, __commit)")
479+
.mkString
480+
}
477481
|
478482
|__Next ==
479483
| \\E self \\in __self_values :

test/pgo/CLITests.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package pgo
2+
3+
class CLITests extends munit.FunSuite:
4+
val dqueueTLA = pgo.projectRoot / "systems" / "dqueue" / "dqueue.tla"
5+
test("tracegen with no log files in dir: errors returned"):
6+
val tmp = os.temp.dir()
7+
try
8+
val Nil = pgo.PGo.run(scala.collection.immutable.ArraySeq(
9+
"tracegen", dqueueTLA.toString, tmp.toString
10+
))
11+
fail("didn't exit with config error")
12+
catch
13+
case PGo.ConfigExit(1) => () // intended
14+
15+
test("tracegen with one empty log file: no errors"):
16+
val tmp = os.temp.dir()
17+
os.write(tmp / "foo.log", "")
18+
assertEquals(pgo.PGo.run(scala.collection.immutable.ArraySeq(
19+
"tracegen", dqueueTLA.toString, tmp.toString
20+
)), Nil)
21+
end CLITests
22+

test/pgo/TracingTests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package pgo
22

33
import pgo.util.TLC
4-
import os.makeDir.all
54
import scala.concurrent.duration.{MINUTES, Duration}
65

76
class TracingTests extends munit.FunSuite:

0 commit comments

Comments
 (0)