Sync branch magefile with main #104308
@ -7,6 +7,7 @@ bugs in actually-released versions.
|
||||
## 3.6 - in development
|
||||
|
||||
- Add `label` to job settings, to have full control over how they are presented in Blender's job submission GUI. If a job setting does not define a label, its `key` is used to generate one (like Flamenco 3.5 and older).
|
||||
- Add `shellSplit(someString)` function to the job compiler scripts. This splits a string into an array of strings using shell/CLI semantics.
|
||||
|
||||
## 3.5 - released 2024-04-16
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
"github.com/google/shlex"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
@ -33,6 +34,19 @@ func jsFormatTimestampLocal(timestamp time.Time) string {
|
||||
return timestamp.Local().Format("2006-01-02_150405")
|
||||
}
|
||||
|
||||
// jsShellSplit splits a string into its parts, using CLI/shell semantics.
|
||||
func jsShellSplit(vm *goja.Runtime, someCLIArgs string) []string {
|
||||
split, err := shlex.Split(someCLIArgs)
|
||||
|
||||
if err != nil {
|
||||
// Generate a JS exception by panicing with a Goja Value.
|
||||
exception := vm.ToValue(err)
|
||||
panic(exception)
|
||||
}
|
||||
|
||||
return split
|
||||
}
|
||||
|
||||
type ErrInvalidRange struct {
|
||||
Range string // The frame range that was invalid.
|
||||
Message string // The error message
|
||||
|
@ -5,10 +5,28 @@ package job_compilers
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestShellSplitHappy(t *testing.T) {
|
||||
expect := []string{"--python-expr", "print(1 + 1)"}
|
||||
actual := jsShellSplit(nil, "--python-expr 'print(1 + 1)'")
|
||||
assert.Equal(t, expect, actual)
|
||||
}
|
||||
|
||||
func TestShellSplitFailure(t *testing.T) {
|
||||
vm := goja.New()
|
||||
|
||||
testFunc := func() {
|
||||
jsShellSplit(vm, "--python-expr invalid_quoting(1 + 1)'")
|
||||
}
|
||||
// Testing that a goja.Value is used for the panic is a bit tricky, so just
|
||||
// test that the function panics.
|
||||
assert.Panics(t, testFunc)
|
||||
}
|
||||
|
||||
func TestFrameChunkerHappyBlenderStyle(t *testing.T) {
|
||||
chunks, err := jsFrameChunker("1..10,20..25,40,3..8", 4)
|
||||
require.NoError(t, err)
|
||||
|
@ -140,6 +140,9 @@ func newGojaVM(registry *require.Registry) *goja.Runtime {
|
||||
mustSet("alert", jsAlert)
|
||||
mustSet("frameChunker", jsFrameChunker)
|
||||
mustSet("formatTimestampLocal", jsFormatTimestampLocal)
|
||||
mustSet("shellSplit", func(cliArgs string) []string {
|
||||
return jsShellSplit(vm, cliArgs)
|
||||
})
|
||||
|
||||
// Pre-import some useful modules.
|
||||
registry.Enable(vm)
|
||||
|
Loading…
Reference in New Issue
Block a user