pkg/prog: Bump deprecation level to 20.

Also add support for setting deprecation level in transcript tests.
This commit is contained in:
Qi Xiao 2024-02-06 14:14:23 +01:00
parent 7e0b6ee8e6
commit c9e26cc20f
3 changed files with 10 additions and 1 deletions

View File

@ -102,6 +102,8 @@ Exception: port does not support value output
# eawk #
////////
//with-deprecation-level 19
~> echo " ax by cz \n11\t22 33" | eawk {|@a| put $a[-1] }
▶ cz
▶ 33

View File

@ -8,6 +8,7 @@ import (
"io/fs"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
@ -18,6 +19,7 @@ import (
"src.elv.sh/pkg/mods"
"src.elv.sh/pkg/must"
"src.elv.sh/pkg/parse"
"src.elv.sh/pkg/prog"
"src.elv.sh/pkg/testutil"
"src.elv.sh/pkg/transcript"
)
@ -68,6 +70,8 @@ import (
// and GOOS values and "unix" are recognized as tags; other tags are always
// false.
//
// - deprecation-level $x: Run with deprecation level set to $x.
//
// Since directives in a higher level propagated to all its descendants, this
// mechanism can be used to specify setup functions that apply to an entire
// .elvts file (or an entire elvish-transcript code block in a .elv file) or an
@ -162,6 +166,9 @@ func buildSetupMaps(setupPairs []any) (map[string]func(*testing.T, *eval.Evaler)
t.Skipf("constraint not satisfied: %s", arg)
}
},
"deprecation-level": func(t *testing.T, _ *eval.Evaler, arg string) {
testutil.Set(t, &prog.DeprecationLevel, must.OK1(strconv.Atoi(arg)))
},
}
for i := 0; i < len(setupPairs); i += 2 {
name := setupPairs[i].(string)

View File

@ -18,7 +18,7 @@ import (
// DeprecationLevel is a global flag that controls which deprecations to show.
// If its value is X, Elvish shows deprecations that should be shown for version
// 0.X.
var DeprecationLevel = 19
var DeprecationLevel = 20
// Program represents a subprogram.
type Program interface {