From 169a7b068e43aafe19d9f296a4077ea9dc5b6560 Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Wed, 17 Jun 2026 00:03:59 +0200 Subject: [PATCH 1/7] Modify MLBs to build and test on polymlb as well --- src/Makefile | 4 ++++ src/call-main.sml | 1 + src/futpkg.mlb | 1 + src/futpkg.sml | 2 +- src/manifest/test.mlb | 5 ++++- src/manifest/test.sml | 23 ++++++++++------------- src/semver/test.mlb | 5 ++++- src/semver/test.sml | 11 +---------- src/smlpkg.mlb | 1 + src/smlpkg.sml | 2 +- src/solve/test.mlb | 5 ++++- src/solve/test.sml | 19 +++++++------------ src/test/postamble.sml | 21 +++++++++++++++++++++ src/test/preamble.sml | 36 ++++++++++++++++++++++++++++++++++++ src/util/test.mlb | 5 ++++- src/util/test.sml | 6 ------ src/util/test_system.sml | 6 ------ 17 files changed, 100 insertions(+), 53 deletions(-) create mode 100644 src/call-main.sml create mode 100644 src/test/postamble.sml create mode 100644 src/test/preamble.sml diff --git a/src/Makefile b/src/Makefile index 90112e9..e5fc95f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,6 +2,10 @@ PKGVERSION=$(shell cat ../version.txt) MLCOMP ?= mlkit +ifeq ($(MLCOMP), polymlb) +MLCOMP=polymlb -ignore-call-main +endif + SMLFILES=$(shell find . -name '*.sml') $(shell find . -name '*.sig') $(shell find . -name '*.mlb') GITVERSION=$(shell git describe --abbrev --dirty --always --tags) diff --git a/src/call-main.sml b/src/call-main.sml new file mode 100644 index 0000000..ccd9b5d --- /dev/null +++ b/src/call-main.sml @@ -0,0 +1 @@ +val _ = main () diff --git a/src/futpkg.mlb b/src/futpkg.mlb index b373fa0..3594c1a 100644 --- a/src/futpkg.mlb +++ b/src/futpkg.mlb @@ -1,2 +1,3 @@ pkg.mlb futpkg.sml +call-main.sml diff --git a/src/futpkg.sml b/src/futpkg.sml index 2b73589..d6cfa7e 100644 --- a/src/futpkg.sml +++ b/src/futpkg.sml @@ -1,2 +1,2 @@ -val () = Pkg.main "futhark.pkg" +fun main () = Pkg.main "futhark.pkg" diff --git a/src/manifest/test.mlb b/src/manifest/test.mlb index 0c68f30..9e8f5c8 100644 --- a/src/manifest/test.mlb +++ b/src/manifest/test.mlb @@ -1,4 +1,7 @@ local $(SML_LIB)/basis/basis.mlb manifest.mlb -in test.sml +in + ../test/preamble.sml + test.sml + ../test/postamble.sml end diff --git a/src/manifest/test.sml b/src/manifest/test.sml index 28d5368..12e44e8 100644 --- a/src/manifest/test.sml +++ b/src/manifest/test.sml @@ -1,25 +1,22 @@ +val () = println "Testing Manifest" open Manifest -fun test s f = - (if f() then print ("OK : " ^ s ^ "\n") - else print ("ERR: " ^ s ^ "\n")) - handle Fail e => print ("EXN: " ^ s ^ " raised Fail \"" ^ e ^ "\"\n") val m = "require {}" -val () = test "empty-m" (fn () => null(requires(fromString "str" m))) +val () = testf "empty-m" (fn () => null(requires(fromString "str" m))) val mp = "package github.com/owner/repo require {}" -val () = test "empty-mp" (fn () => null(requires(fromString "str" mp))) -val () = test "empty-mp-host" (fn () => SOME "github.com" = Option.map #host (package(fromString "str" mp))) -val () = test "empty-mp-owner" (fn () => SOME "owner" = Option.map #owner (package(fromString "str" mp))) -val () = test "empty-mp-repo" (fn () => SOME "repo" = Option.map #repo (package(fromString "str" mp))) +val () = testf "empty-mp" (fn () => null(requires(fromString "str" mp))) +val () = testf "empty-mp-host" (fn () => SOME "github.com" = Option.map #host (package(fromString "str" mp))) +val () = testf "empty-mp-owner" (fn () => SOME "owner" = Option.map #owner (package(fromString "str" mp))) +val () = testf "empty-mp-repo" (fn () => SOME "repo" = Option.map #repo (package(fromString "str" mp))) val mr1 = "require { github.com/owner/repo 1.2.3 #asdefsde }" -val () = test "empty-mr1-len" (fn () => 1 = length(requires(fromString "str" mr1))) -val () = test "empty-mr1" (fn () => SOME "asdefsde" = #3(List.hd(requires(fromString "str" mr1)))) +val () = testf "empty-mr1-len" (fn () => 1 = length(requires(fromString "str" mr1))) +val () = testf "empty-mr1" (fn () => SOME "asdefsde" = #3(List.hd(requires(fromString "str" mr1)))) val mr2 = "require { github.com/owner/repo 1.2.3 #asdefsde github.com/owner2/repo8 43.3.2-alpha #523424abcd }" -val () = test "empty-mr2" (fn () => 2 = length(requires(fromString "str" mr2))) -val () = test "empty-mr2-version" (fn () => "1.2.3" = SemVer.toString(#2(List.hd(requires(fromString "str" mr2))))) +val () = testf "empty-mr2" (fn () => 2 = length(requires(fromString "str" mr2))) +val () = testf "empty-mr2-version" (fn () => "1.2.3" = SemVer.toString(#2(List.hd(requires(fromString "str" mr2))))) diff --git a/src/semver/test.mlb b/src/semver/test.mlb index 2744670..7a569a5 100644 --- a/src/semver/test.mlb +++ b/src/semver/test.mlb @@ -1,4 +1,7 @@ local $(SML_LIB)/basis/basis.mlb semver.mlb -in test.sml +in + ../test/preamble.sml + test.sml + ../test/postamble.sml end diff --git a/src/semver/test.sml b/src/semver/test.sml index 04ea1a4..2bd08be 100644 --- a/src/semver/test.sml +++ b/src/semver/test.sml @@ -1,16 +1,6 @@ open SemVer -fun test s b = - if b then print ("OK : " ^ s ^ "\n") - else print ("ERR: " ^ s ^ "\n") - -fun testf s f = - (if f() then print ("OK : " ^ s ^ "\n") - else print ("ERR: " ^ s ^ "\n")) - handle Fail e => print ("EXN: " ^ s ^ " raised Fail \"" ^ e ^ "\"\n") - | Overflow => print ("EXN: " ^ s ^ " raised Overflow\n") - fun test_major_minor_patch s (z,a,b) = let val () = test ("major0" ^ s) (Option.map major (fromString z) = SOME 0) val () = test ("major1" ^ s) (Option.map major (fromString a) = SOME 3) @@ -140,3 +130,4 @@ val () = testf "ovf" (fn () => let val t = fromString "0.0.0-20180801102532+b70028521e4dbcc286834b32ce82c1d2721a6209" in Option.map major t = SOME 0 end) + diff --git a/src/smlpkg.mlb b/src/smlpkg.mlb index 6fd77d6..491ebbe 100644 --- a/src/smlpkg.mlb +++ b/src/smlpkg.mlb @@ -1,2 +1,3 @@ pkg.mlb smlpkg.sml +call-main.sml diff --git a/src/smlpkg.sml b/src/smlpkg.sml index 655937b..19f3cd0 100644 --- a/src/smlpkg.sml +++ b/src/smlpkg.sml @@ -1,2 +1,2 @@ -val () = Pkg.main "sml.pkg" +fun main () = Pkg.main "sml.pkg" diff --git a/src/solve/test.mlb b/src/solve/test.mlb index f06f624..908e1fb 100644 --- a/src/solve/test.mlb +++ b/src/solve/test.mlb @@ -4,5 +4,8 @@ local $(SML_LIB)/basis/basis.mlb ../util/util.mlb solve.sig solve.sml -in test.sml +in + ../test/preamble.sml + test.sml + ../test/postamble.sml end diff --git a/src/solve/test.sml b/src/solve/test.sml index 476d050..716f3c1 100644 --- a/src/solve/test.sml +++ b/src/solve/test.sml @@ -1,13 +1,6 @@ -fun println s = print (s ^ "\n") - val () = println "Testing Solve" -fun test s f = - (if f() then print ("OK : " ^ s ^ "\n") - else print ("ERR: " ^ s ^ "\n")) - handle Fail e => print ("EXN: " ^ s ^ " raised Fail \"" ^ e ^ "\"\n") - fun no_version p v = raise Fail ("cannot find version " ^ v ^ " for package " ^ p ^ ".") @@ -74,28 +67,30 @@ fun solveManifest (m:Manifest.t) : string = in Solve.buildListToString bl end -val () = test "solve1" (fn () => solveManifest m_repo10_0_1_0 = "{}") +val () = testf "solve1" (fn () => solveManifest m_repo10_0_1_0 = "{}") -val () = test "solve2" (fn () => +val () = testf "solve2" (fn () => let val res = solveManifest m_repo20_0_2_0 val () = println (" result = " ^ res) in res = "{github.com/owner1/repo10:0.1.0}" end) -val () = test "solve3" (fn () => +val () = testf "solve3" (fn () => let val res = solveManifest m_repo20_0_2_1 val () = println (" result = " ^ res) in res = "{github.com/owner1/repo10:0.1.1}" end) -val () = test "solve4" (fn () => +val () = testf "solve4" (fn () => let val res = solveManifest m_repo30_0_3_0 val () = println (" result = " ^ res) in res = "{github.com/owner2/repo20:0.2.0,github.com/owner1/repo10:0.1.0}" end) -val () = test "solve5" (fn () => +val () = testf "solve5" (fn () => let val res = solveManifest m_repo30_0_3_1 val () = println (" result = " ^ res) in res = "{github.com/owner2/repo20:0.2.1,github.com/owner1/repo10:0.1.1}" end) + + diff --git a/src/test/postamble.sml b/src/test/postamble.sml new file mode 100644 index 0000000..ab2d966 --- /dev/null +++ b/src/test/postamble.sml @@ -0,0 +1,21 @@ +(* + test postamble + + Include this file at the end of your test suite to report test errors + to the OS. + + The main function needs to be defined for polymlb to create an executable. + If any tests fail, the creation of the executable itself will fail with a + nonzero exit code. + + If the tests pass, the executable itself is a no-op under PolyML. + + Under MLton and MLkit, the test executable, once compiled, will run the + tests and report any errors to the OS. + +*) + +fun main () = + if !errors > 0 then OS.Process.exit(OS.Process.failure) else () + +val _ = main () diff --git a/src/test/preamble.sml b/src/test/preamble.sml new file mode 100644 index 0000000..698f948 --- /dev/null +++ b/src/test/preamble.sml @@ -0,0 +1,36 @@ +(* + test preamble + + Defines common test functions and contains an imperative method + of counting test errors. + + Include this before your test suite, and add postamble.sml at the end + + e.g. + ../test/preamble.sml + test_system.sml + ../test/postamble.sml + +*) + + +val errors = ref 0; +fun println s = print (s ^ "\n") + +fun reportOk s = println ("OK: " ^ s) + +fun reportErr s = (errors := !errors + 1; println ("ERR: " ^ s)) + +fun reportExn s e = (errors := !errors + 1; + println ("EXN: " ^ s ^ " raised Fail \"" ^ e ^ "\"")) + +fun reportExn' s exn_name = (errors := !errors + 1; + println ("EXN: " ^ s ^ " raised " ^ exn_name)) + +fun test s b = (if b then reportOk s else reportErr s) + handle Fail e => reportExn s e + +fun testf s f = + (if f() then reportOk s else reportErr s) + handle Fail e => reportExn s e + | Overflow => reportExn' s "Overflow" diff --git a/src/util/test.mlb b/src/util/test.mlb index d671024..a8e2303 100644 --- a/src/util/test.mlb +++ b/src/util/test.mlb @@ -1,5 +1,8 @@ local $(SML_LIB)/basis/basis.mlb util.mlb -in test.sml +in + ../test/preamble.sml + test.sml test_system.sml + ../test/postamble.sml end diff --git a/src/util/test.sml b/src/util/test.sml index f020c10..180e64a 100644 --- a/src/util/test.sml +++ b/src/util/test.sml @@ -1,11 +1,5 @@ -fun println s = print (s ^ "\n") - val () = println "Testing FinMapEq" -fun test s b = - println(if b then ("OK : " ^ s) - else ("ERR: " ^ s)) - open FinMapEq val m : (int,string)t = empty_eq() diff --git a/src/util/test_system.sml b/src/util/test_system.sml index 0136398..9e20e8c 100644 --- a/src/util/test_system.sml +++ b/src/util/test_system.sml @@ -1,11 +1,5 @@ -fun println s = print (s ^ "\n") - val () = println "Testing System" -fun test s b = - println(if b then ("OK : " ^ s) - else ("ERR: " ^ s)) - open System val cmd = "cat testfile.txt" From 82822d9a179c62ea7e1cd36f1d451e1d8f03a9fa Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Wed, 17 Jun 2026 09:33:05 +0200 Subject: [PATCH 2/7] Ensure independent compilation of {sml,fut}pkg under mlkit --- Makefile | 6 ++++++ src/Makefile | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c1681e6..5efa6e1 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,12 @@ clean: src/smlpkg: $(MAKE) -C src all +.PHONY: test-all-supported-compilers +test-all-supported-compilers: + $(MAKE) clean ; $(MAKE) test MLCOMP=mlton + $(MAKE) clean ; $(MAKE) test MLCOMP=mlkit + $(MAKE) clean ; $(MAKE) test MLCOMP=polymlb + # ----------------------------------------------------- # Target for building binary distribution for smlpkg # ----------------------------------------------------- diff --git a/src/Makefile b/src/Makefile index e5fc95f..690459e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,10 +1,15 @@ PKGVERSION=$(shell cat ../version.txt) MLCOMP ?= mlkit +MLCOMP_FLAGS ?= ifeq ($(MLCOMP), polymlb) -MLCOMP=polymlb -ignore-call-main +MLCOMP_FLAGS=-ignore-call-main endif +ifeq ($(MLCOMP), mlkit) +MLCOMP_FLAGS=--mlb-subdir $(shell mktemp -d) +endif + SMLFILES=$(shell find . -name '*.sml') $(shell find . -name '*.sig') $(shell find . -name '*.mlb') @@ -14,10 +19,12 @@ GITVERSION=$(shell git describe --abbrev --dirty --always --tags) all: smlpkg futpkg smlpkg: smlpkg.mlb $(SMLFILES) version.gen.sml - $(MLCOMP) -output $@ $< + rm -rf MLB + $(MLCOMP) $(MLCOMP_FLAGS) -output $@ $< futpkg: futpkg.mlb $(SMLFILES) - $(MLCOMP) -output $@ $< + rm -rf MLB + $(MLCOMP) $(MLCOMP_FLAGS) -output $@ $< .PHONY: test test: From 2978dc98ce736810d6a1c960a0deb47cbc5cfb99 Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Thu, 18 Jun 2026 10:19:20 +0200 Subject: [PATCH 3/7] Use separate call-main-* files for smlpkg and futpkg --- src/Makefile | 8 +------- src/{call-main.sml => call-main-futpkg.sml} | 0 src/call-main-smlpkg.sml | 1 + src/futpkg.mlb | 2 +- src/smlpkg.mlb | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) rename src/{call-main.sml => call-main-futpkg.sml} (100%) create mode 100644 src/call-main-smlpkg.sml diff --git a/src/Makefile b/src/Makefile index 690459e..417edaa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,12 +4,8 @@ MLCOMP ?= mlkit MLCOMP_FLAGS ?= ifeq ($(MLCOMP), polymlb) -MLCOMP_FLAGS=-ignore-call-main +MLCOMP_FLAGS=-ann 'ignoreFiles call-main-smlpkg.sml,call-main-futpkg.sml' endif -ifeq ($(MLCOMP), mlkit) -MLCOMP_FLAGS=--mlb-subdir $(shell mktemp -d) -endif - SMLFILES=$(shell find . -name '*.sml') $(shell find . -name '*.sig') $(shell find . -name '*.mlb') @@ -19,11 +15,9 @@ GITVERSION=$(shell git describe --abbrev --dirty --always --tags) all: smlpkg futpkg smlpkg: smlpkg.mlb $(SMLFILES) version.gen.sml - rm -rf MLB $(MLCOMP) $(MLCOMP_FLAGS) -output $@ $< futpkg: futpkg.mlb $(SMLFILES) - rm -rf MLB $(MLCOMP) $(MLCOMP_FLAGS) -output $@ $< .PHONY: test diff --git a/src/call-main.sml b/src/call-main-futpkg.sml similarity index 100% rename from src/call-main.sml rename to src/call-main-futpkg.sml diff --git a/src/call-main-smlpkg.sml b/src/call-main-smlpkg.sml new file mode 100644 index 0000000..ccd9b5d --- /dev/null +++ b/src/call-main-smlpkg.sml @@ -0,0 +1 @@ +val _ = main () diff --git a/src/futpkg.mlb b/src/futpkg.mlb index 3594c1a..668721c 100644 --- a/src/futpkg.mlb +++ b/src/futpkg.mlb @@ -1,3 +1,3 @@ pkg.mlb futpkg.sml -call-main.sml +call-main-futpkg.sml diff --git a/src/smlpkg.mlb b/src/smlpkg.mlb index 491ebbe..2e669e9 100644 --- a/src/smlpkg.mlb +++ b/src/smlpkg.mlb @@ -1,3 +1,3 @@ pkg.mlb smlpkg.sml -call-main.sml +call-main-smlpkg.sml From 4e20e53d4faf9e7bd1f2225ae1c6899e464fc2bc Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Thu, 18 Jun 2026 10:36:14 +0200 Subject: [PATCH 4/7] Use TestSuite functor in semver tests --- src/semver/Makefile | 7 ++++++- src/semver/test.mlb | 3 +-- src/semver/test.sml | 4 ++++ src/test/postamble.sml | 21 ------------------- src/test/testSuite.mlb | 5 +++++ src/test/{preamble.sml => testSuite.sml} | 26 ++++++++++-------------- 6 files changed, 27 insertions(+), 39 deletions(-) delete mode 100644 src/test/postamble.sml create mode 100644 src/test/testSuite.mlb rename src/test/{preamble.sml => testSuite.sml} (70%) diff --git a/src/semver/Makefile b/src/semver/Makefile index 6a36958..50c9b35 100644 --- a/src/semver/Makefile +++ b/src/semver/Makefile @@ -1,8 +1,13 @@ MLCOMP ?= mlkit +MLCOMP_FLAGS ?= + +ifeq ($(MLCOMP), polymlb) +MLCOMP_FLAGS=-main reportAndExit +endif .PHONY: test test: - $(MLCOMP) -output test.exe test.mlb + $(MLCOMP) $(MLCOMP_FLAGS) -output test.exe test.mlb ./test.exe .PHONY: clean diff --git a/src/semver/test.mlb b/src/semver/test.mlb index 7a569a5..c93f96b 100644 --- a/src/semver/test.mlb +++ b/src/semver/test.mlb @@ -1,7 +1,6 @@ local $(SML_LIB)/basis/basis.mlb + ../test/testSuite.mlb semver.mlb in - ../test/preamble.sml test.sml - ../test/postamble.sml end diff --git a/src/semver/test.sml b/src/semver/test.sml index 2bd08be..fd2ec4f 100644 --- a/src/semver/test.sml +++ b/src/semver/test.sml @@ -1,6 +1,9 @@ open SemVer +structure T = TestSuite () +open T + fun test_major_minor_patch s (z,a,b) = let val () = test ("major0" ^ s) (Option.map major (fromString z) = SOME 0) val () = test ("major1" ^ s) (Option.map major (fromString a) = SOME 3) @@ -131,3 +134,4 @@ val () = testf "ovf" (fn () => in Option.map major t = SOME 0 end) +val _ = reportAndExit(); diff --git a/src/test/postamble.sml b/src/test/postamble.sml deleted file mode 100644 index ab2d966..0000000 --- a/src/test/postamble.sml +++ /dev/null @@ -1,21 +0,0 @@ -(* - test postamble - - Include this file at the end of your test suite to report test errors - to the OS. - - The main function needs to be defined for polymlb to create an executable. - If any tests fail, the creation of the executable itself will fail with a - nonzero exit code. - - If the tests pass, the executable itself is a no-op under PolyML. - - Under MLton and MLkit, the test executable, once compiled, will run the - tests and report any errors to the OS. - -*) - -fun main () = - if !errors > 0 then OS.Process.exit(OS.Process.failure) else () - -val _ = main () diff --git a/src/test/testSuite.mlb b/src/test/testSuite.mlb new file mode 100644 index 0000000..22b6f35 --- /dev/null +++ b/src/test/testSuite.mlb @@ -0,0 +1,5 @@ +local + $(SML_LIB)/basis/basis.mlb +in + testSuite.sml +end diff --git a/src/test/preamble.sml b/src/test/testSuite.sml similarity index 70% rename from src/test/preamble.sml rename to src/test/testSuite.sml index 698f948..baed2f3 100644 --- a/src/test/preamble.sml +++ b/src/test/testSuite.sml @@ -1,20 +1,8 @@ -(* - test preamble - - Defines common test functions and contains an imperative method - of counting test errors. - - Include this before your test suite, and add postamble.sml at the end - - e.g. - ../test/preamble.sml - test_system.sml - ../test/postamble.sml - -*) - +functor TestSuite () = +struct val errors = ref 0; + fun println s = print (s ^ "\n") fun reportOk s = println ("OK: " ^ s) @@ -34,3 +22,11 @@ fun testf s f = (if f() then reportOk s else reportErr s) handle Fail e => reportExn s e | Overflow => reportExn' s "Overflow" + | _ => reportExn' s "Other" + +fun reportAndExit () = + if !errors > 0 + then OS.Process.exit OS.Process.failure + else () (* Do not exit on success, for polymlb *) + +end; From 07eab935639d24e652eceec7cae6205f711b2ef6 Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Thu, 18 Jun 2026 10:43:21 +0200 Subject: [PATCH 5/7] Extract test.mk; convert manifest tests --- src/manifest/Makefile | 11 +---------- src/manifest/test.mlb | 3 +-- src/manifest/test.sml | 7 +++++-- src/semver/Makefile | 16 +--------------- src/semver/test.sml | 5 +---- src/test/test.mk | 15 +++++++++++++++ 6 files changed, 24 insertions(+), 33 deletions(-) create mode 100644 src/test/test.mk diff --git a/src/manifest/Makefile b/src/manifest/Makefile index 6a36958..1cecf2c 100644 --- a/src/manifest/Makefile +++ b/src/manifest/Makefile @@ -1,10 +1 @@ -MLCOMP ?= mlkit - -.PHONY: test -test: - $(MLCOMP) -output test.exe test.mlb - ./test.exe - -.PHONY: clean -clean: - rm -rf *~ MLB run *.exe +include ../test/test.mk diff --git a/src/manifest/test.mlb b/src/manifest/test.mlb index 9e8f5c8..5d9c869 100644 --- a/src/manifest/test.mlb +++ b/src/manifest/test.mlb @@ -1,7 +1,6 @@ local $(SML_LIB)/basis/basis.mlb manifest.mlb + ../test/testSuite.mlb in - ../test/preamble.sml test.sml - ../test/postamble.sml end diff --git a/src/manifest/test.sml b/src/manifest/test.sml index 12e44e8..31fc04c 100644 --- a/src/manifest/test.sml +++ b/src/manifest/test.sml @@ -1,7 +1,8 @@ -val () = println "Testing Manifest" -open Manifest +open Manifest +structure T = TestSuite (); open T +val () = println "Testing Manifest" val m = "require {}" @@ -20,3 +21,5 @@ val () = testf "empty-mr1" (fn () => SOME "asdefsde" = #3(List.hd(requires(fromS val mr2 = "require { github.com/owner/repo 1.2.3 #asdefsde github.com/owner2/repo8 43.3.2-alpha #523424abcd }" val () = testf "empty-mr2" (fn () => 2 = length(requires(fromString "str" mr2))) val () = testf "empty-mr2-version" (fn () => "1.2.3" = SemVer.toString(#2(List.hd(requires(fromString "str" mr2))))) + +val _ = reportAndExit(); diff --git a/src/semver/Makefile b/src/semver/Makefile index 50c9b35..1cecf2c 100644 --- a/src/semver/Makefile +++ b/src/semver/Makefile @@ -1,15 +1 @@ -MLCOMP ?= mlkit -MLCOMP_FLAGS ?= - -ifeq ($(MLCOMP), polymlb) -MLCOMP_FLAGS=-main reportAndExit -endif - -.PHONY: test -test: - $(MLCOMP) $(MLCOMP_FLAGS) -output test.exe test.mlb - ./test.exe - -.PHONY: clean -clean: - rm -rf *~ MLB run *.exe +include ../test/test.mk diff --git a/src/semver/test.sml b/src/semver/test.sml index fd2ec4f..c7131c6 100644 --- a/src/semver/test.sml +++ b/src/semver/test.sml @@ -1,8 +1,5 @@ - open SemVer - -structure T = TestSuite () -open T +structure T = TestSuite (); open T fun test_major_minor_patch s (z,a,b) = let val () = test ("major0" ^ s) (Option.map major (fromString z) = SOME 0) diff --git a/src/test/test.mk b/src/test/test.mk new file mode 100644 index 0000000..50c9b35 --- /dev/null +++ b/src/test/test.mk @@ -0,0 +1,15 @@ +MLCOMP ?= mlkit +MLCOMP_FLAGS ?= + +ifeq ($(MLCOMP), polymlb) +MLCOMP_FLAGS=-main reportAndExit +endif + +.PHONY: test +test: + $(MLCOMP) $(MLCOMP_FLAGS) -output test.exe test.mlb + ./test.exe + +.PHONY: clean +clean: + rm -rf *~ MLB run *.exe From ee0fe46212b18fe9d1b31ec717194ba701d97d17 Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Thu, 18 Jun 2026 10:47:39 +0200 Subject: [PATCH 6/7] Convert solve tests --- src/solve/Makefile | 11 +---------- src/solve/test.mlb | 3 +-- src/solve/test.sml | 3 ++- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/solve/Makefile b/src/solve/Makefile index 6a36958..1cecf2c 100644 --- a/src/solve/Makefile +++ b/src/solve/Makefile @@ -1,10 +1 @@ -MLCOMP ?= mlkit - -.PHONY: test -test: - $(MLCOMP) -output test.exe test.mlb - ./test.exe - -.PHONY: clean -clean: - rm -rf *~ MLB run *.exe +include ../test/test.mk diff --git a/src/solve/test.mlb b/src/solve/test.mlb index 908e1fb..87de5b2 100644 --- a/src/solve/test.mlb +++ b/src/solve/test.mlb @@ -2,10 +2,9 @@ local $(SML_LIB)/basis/basis.mlb ../semver/semver.mlb ../manifest/manifest.mlb ../util/util.mlb + ../test/testSuite.mlb solve.sig solve.sml in - ../test/preamble.sml test.sml - ../test/postamble.sml end diff --git a/src/solve/test.sml b/src/solve/test.sml index 716f3c1..8980adb 100644 --- a/src/solve/test.sml +++ b/src/solve/test.sml @@ -1,4 +1,4 @@ - +structure T = TestSuite (); open T val () = println "Testing Solve" fun no_version p v = @@ -94,3 +94,4 @@ val () = testf "solve5" (fn () => end) +val _ = reportAndExit(); From ed558831f8885117b903e41c7e88727c35627fd2 Mon Sep 17 00:00:00 2001 From: Simon Zelazny Date: Thu, 18 Jun 2026 10:50:48 +0200 Subject: [PATCH 7/7] Convert util tests --- src/util/Makefile | 11 +---------- src/util/test.mlb | 4 +--- src/util/test.sml | 28 ++++++++++++++++++++++++++-- src/util/test_system.sml | 17 ----------------- 4 files changed, 28 insertions(+), 32 deletions(-) delete mode 100644 src/util/test_system.sml diff --git a/src/util/Makefile b/src/util/Makefile index 6a36958..1cecf2c 100644 --- a/src/util/Makefile +++ b/src/util/Makefile @@ -1,10 +1 @@ -MLCOMP ?= mlkit - -.PHONY: test -test: - $(MLCOMP) -output test.exe test.mlb - ./test.exe - -.PHONY: clean -clean: - rm -rf *~ MLB run *.exe +include ../test/test.mk diff --git a/src/util/test.mlb b/src/util/test.mlb index a8e2303..96959fc 100644 --- a/src/util/test.mlb +++ b/src/util/test.mlb @@ -1,8 +1,6 @@ local $(SML_LIB)/basis/basis.mlb + ../test/testSuite.mlb util.mlb in - ../test/preamble.sml test.sml - test_system.sml - ../test/postamble.sml end diff --git a/src/util/test.sml b/src/util/test.sml index 180e64a..6e21bdb 100644 --- a/src/util/test.sml +++ b/src/util/test.sml @@ -1,6 +1,7 @@ -val () = println "Testing FinMapEq" +structure T = TestSuite (); open T -open FinMapEq +val () = println "Testing FinMapEq" +local open FinMapEq in val m : (int,string)t = empty_eq() @@ -12,3 +13,26 @@ val toS : (int,string)t -> string = toString (Int.toString,fn s=>s) val () = test "empty-toString" (toS m = "{}") val () = test "add1-toString" (toS m1 = "{5:five}") val () = test "add2-toString" (toS m2 = "{8:eight,5:five}") +end + + +val () = println "Testing System" +local open System in + +val cmd = "cat testfile.txt" +val (status,out,err) = command cmd + +val () = test "system.ok.out" (out = "Hi there\n") +val () = test "system.ok.err" (err = "") +val () = test "system.ok.status" (OS.Process.isSuccess status) + +val cmd_err = "cat doesnotexist.txt" +val (status_err,out_err,err_err) = command cmd_err + +val () = test "system.err.out" (out_err = "") +val () = test "system.err.err" (err_err = "cat: doesnotexist.txt: No such file or directory\n") +val () = test "system.err.status" (not(OS.Process.isSuccess status_err)) +end + + +val _ = reportAndExit () diff --git a/src/util/test_system.sml b/src/util/test_system.sml deleted file mode 100644 index 9e20e8c..0000000 --- a/src/util/test_system.sml +++ /dev/null @@ -1,17 +0,0 @@ -val () = println "Testing System" - -open System - -val cmd = "cat testfile.txt" -val (status,out,err) = command cmd - -val () = test "system.ok.out" (out = "Hi there\n") -val () = test "system.ok.err" (err = "") -val () = test "system.ok.status" (OS.Process.isSuccess status) - -val cmd_err = "cat doesnotexist.txt" -val (status_err,out_err,err_err) = command cmd_err - -val () = test "system.err.out" (out_err = "") -val () = test "system.err.err" (err_err = "cat: doesnotexist.txt: No such file or directory\n") -val () = test "system.err.status" (not(OS.Process.isSuccess status_err))