refactor: modernize stdlib usage and move matchers into dsl
All checks were successful
build-dsl-smoke / Build judge (push) Successful in 16s
build-dsl-smoke / debug / clang / linux (push) Successful in 6s
build-dsl-smoke / debug / gcc / linux (push) Successful in 7s
build-dsl-smoke / release / clang / linux (push) Successful in 8s
build-dsl-smoke / release / gcc / linux (push) Successful in 9s
build-dsl-smoke / sanitized / gcc / linux (push) Successful in 6s
build-dsl-smoke / sanitized / clang / linux (push) Successful in 9s
build-dsl-smoke / debug-valgrind / gcc / linux (push) Successful in 15s
build-dsl-smoke / debug / clang / windows (push) Successful in 15s
build-dsl-smoke / debug / msvc / windows (push) Successful in 19s
build-dsl-smoke / release / clang / windows (push) Successful in 18s
build-dsl-smoke / release / msvc / windows (push) Successful in 18s
build-dsl-smoke / SUMMARY (push) Successful in 4s

- Move Matcher types and matching logic from runner/matcher.go into
  the dsl package as methods on the Matcher types. Runner now calls
  t.Stdout.Match(label, actual) instead of type-switching via a
  package-level applyMatcher helper.
- Replace custom contains/containsString helpers with slices.Contains
  in dsl/build.go and runner/compiler.go.
- Use maps.Copy instead of manual map copy in BuildConfig.MergeFrom.
- Adopt strings.SplitSeq, strings.CutPrefix and the `for range N` loop
  form in runner/limiter_linux.go.
- Ignore example/imdb build artifact.
This commit is contained in:
2026-04-15 21:24:11 +03:00
parent 52202abb53
commit c85c65ed49
8 changed files with 123 additions and 139 deletions

View File

@@ -1,5 +1,10 @@
package dsl
import (
"maps"
"slices"
)
type BuildProfile int
const (
@@ -105,9 +110,7 @@ func (dst *BuildConfig) MergeFrom(src *BuildConfig) {
if dst.Defines == nil {
dst.Defines = map[string]string{}
}
for k, v := range src.Defines {
dst.Defines[k] = v
}
maps.Copy(dst.Defines, src.Defines)
}
}
@@ -132,24 +135,15 @@ func (b *BuildConfig) Resolve(defaults *BuildConfig, os string) BuildConfig {
}
func (b *BuildConfig) AppliesTo(os, compiler string) bool {
if len(b.Platforms) > 0 && !contains(b.Platforms, os) {
if len(b.Platforms) > 0 && !slices.Contains(b.Platforms, os) {
return false
}
if len(b.Compilers) > 0 && !contains(b.Compilers, compiler) {
if len(b.Compilers) > 0 && !slices.Contains(b.Compilers, compiler) {
return false
}
return true
}
func contains(xs []string, x string) bool {
for _, v := range xs {
if v == x {
return true
}
}
return false
}
type ToolchainSpec struct {
Name string
Platforms []string