Files
magpie/main_test.go
T
yetone e8c7dddcb4 notices: the release carries the third-party licence notices
The owner asked for the licence notices in the release package (moejs
alpha.11 compiles Intl's data in, which carries its own notices).
THIRD_PARTY_NOTICES is embedded in the binary (main.go, //go:embed) and
handed to internal/notices; `magpie licenses` prints it, GET /api/notices
serves it, and Settings › About has an Open-source licenses row that
opens it in a dialog, in every language. `make app` copies the file into
the .app's Resources too. The core's scripts are 1,527,245 bytes, their
budget raised to it with no room added; app.js stays under its own.

Run at this head (rebased on origin/main):
- win-run (Windows 11): go vet -tags nogui . ./internal/notices
  ./internal/cli; go test TestNoticesFollowMoejs (.), ./internal/cli,
  TestCoreScriptBudget (./internal/gui): ok.
- wsl-run (Ubuntu 24.04): go vet -tags nogui ./..., go build -tags
  nogui: ok.
Run at the pre-rebase head 14e2d13fb, on mote (macOS):
- gofmt; make app's copy byte-identical to the file; `magpie licenses`
  output equal to the file; GOOS=linux/windows vet and build;
  go test . ./internal/cli: ok. ./internal/gui: only
  TestMainWindowCorners red, the same on origin/main (#3949).
- about-notices.test.cjs: chromium and webkit, en zh zh-TW ja de, 1100
  and 420px: all ok.
Broken by hand: TestNoticesFollowMoejs red with the embedded file cut.
Not run: the GUI suite at this head. The rebase met main's cancelAsk
helper where showNotices sat, and the dialog's Done now uses it (the
same stopPropagation + closeConfirmAsk). The whole GUI suite at
14e2d13fb was cut off when mote went down at load ~50: the files it
reached outside About had reds, most of them 180s browser-launch
timeouts, the rest passing in other languages or the other engine; they
are run again once mote is back, and any that stay red are filed.
2026-10-28 16:40:03 +08:00

36 lines
1.1 KiB
Go

package main
import (
"os"
"strings"
"testing"
)
// moejs compiles Intl's CLDR, Unicode, ICU and V8 material into every build
// and asks a program that includes it to carry sections 1 to 4 of its
// notices. The binary carries THIRD_PARTY_NOTICES; this holds it to the
// moejs version go.mod builds with, so an upgrade copies the new notices.
func TestNoticesFollowMoejs(t *testing.T) {
b, err := os.ReadFile("go.mod")
if err != nil {
t.Fatal(err)
}
var v string
for _, l := range strings.Split(string(b), "\n") {
if f := strings.Fields(l); len(f) >= 2 && f[0] == "github.com/MoeForge/moejs" {
v = f[1]
}
}
if v == "" {
t.Fatal("go.mod requires no github.com/MoeForge/moejs")
}
if !strings.Contains(thirdParty, "THIRD_PARTY_NOTICES at "+v+",") {
t.Errorf("THIRD_PARTY_NOTICES is not moejs %s's: copy sections 1 to 4 of its notices", v)
}
for _, s := range []string{"1. Unicode CLDR", "2. Unicode Character Database", "3. ICU", "4. V8"} {
if !strings.Contains(thirdParty, "\n"+s) {
t.Errorf("THIRD_PARTY_NOTICES has no section %q", s)
}
}
}