mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
On baremetal platforms, use simpler test matcher. Fixes #2666.
Uses same matcher in testdata (because now we can't replace it in testdata).
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build baremetal
|
||||
// +build baremetal
|
||||
|
||||
package testing
|
||||
|
||||
const isBaremetal = true
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright 2016 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
//
|
||||
//go:build !baremetal
|
||||
// +build !baremetal
|
||||
|
||||
package testing
|
||||
|
||||
const isBaremetal = false
|
||||
@@ -26,6 +26,11 @@ type matcher struct {
|
||||
var matchMutex sync.Mutex
|
||||
|
||||
func newMatcher(matchString func(pat, str string) (bool, error), patterns, name string) *matcher {
|
||||
if isBaremetal {
|
||||
// Probably not enough ram to load regexp, substitute something simpler.
|
||||
matchString = fakeMatchString
|
||||
}
|
||||
|
||||
var filter []string
|
||||
if patterns != "" {
|
||||
filter = splitRegexp(patterns)
|
||||
@@ -166,3 +171,14 @@ func isSpace(r rune) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// A fake regexp matcher.
|
||||
// Inflexible, but saves 50KB of flash and 50KB of RAM per -size full,
|
||||
// and lets tests pass on cortex-m.
|
||||
func fakeMatchString(pat, str string) (bool, error) {
|
||||
if pat == ".*" {
|
||||
return true, nil
|
||||
}
|
||||
matched := strings.Contains(str, pat)
|
||||
return matched, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user