Manager: ensure the {jobs}
implicit variable uses forward slashes
Since the variable expansion is unaware of path semantics, using forward slashes is the safest way to go about things in a platform-indepdent way.
This commit is contained in:
parent
ce250a611e
commit
3c290b1f6d
@ -3,7 +3,7 @@ package api_impl
|
|||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"git.blender.org/flamenco/internal/manager/config"
|
"git.blender.org/flamenco/internal/manager/config"
|
||||||
"git.blender.org/flamenco/internal/manager/persistence"
|
"git.blender.org/flamenco/internal/manager/persistence"
|
||||||
"git.blender.org/flamenco/pkg/api"
|
"git.blender.org/flamenco/pkg/api"
|
||||||
|
"git.blender.org/flamenco/pkg/crosspath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func varreplTestTask() api.AssignedTask {
|
func varreplTestTask() api.AssignedTask {
|
||||||
@ -106,25 +107,33 @@ func TestReplaceJobsVariable(t *testing.T) {
|
|||||||
// An implicit variable "{jobs}" should be created, regardless of whether
|
// An implicit variable "{jobs}" should be created, regardless of whether
|
||||||
// Shaman is enabled or not.
|
// Shaman is enabled or not.
|
||||||
|
|
||||||
|
var storagePath string
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "windows":
|
||||||
|
storagePath = `C:\path\to\flamenco-storage`
|
||||||
|
default:
|
||||||
|
storagePath = "/path/to/flamenco-storage"
|
||||||
|
}
|
||||||
|
|
||||||
{ // Test with Shaman enabled.
|
{ // Test with Shaman enabled.
|
||||||
conf := config.GetTestConfig(func(c *config.Conf) {
|
conf := config.GetTestConfig(func(c *config.Conf) {
|
||||||
c.SharedStoragePath = "/path/to/flamenco-storage"
|
c.SharedStoragePath = storagePath
|
||||||
c.Shaman.Enabled = true
|
c.Shaman.Enabled = true
|
||||||
})
|
})
|
||||||
|
|
||||||
replacedTask := replaceTaskVariables(&conf, task, worker)
|
replacedTask := replaceTaskVariables(&conf, task, worker)
|
||||||
expectPath := path.Join(conf.Shaman.CheckoutPath(), "path/in/storage.blend")
|
expectPath := crosspath.Join(crosspath.ToSlash(conf.Shaman.CheckoutPath()), "path/in/storage.blend")
|
||||||
assert.Equal(t, expectPath, replacedTask.Commands[2].Parameters["filepath"])
|
assert.Equal(t, expectPath, replacedTask.Commands[2].Parameters["filepath"])
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Test without Shaman.
|
{ // Test without Shaman.
|
||||||
conf := config.GetTestConfig(func(c *config.Conf) {
|
conf := config.GetTestConfig(func(c *config.Conf) {
|
||||||
c.SharedStoragePath = "/path/to/flamenco-storage"
|
c.SharedStoragePath = storagePath
|
||||||
c.Shaman.Enabled = false
|
c.Shaman.Enabled = false
|
||||||
})
|
})
|
||||||
|
|
||||||
replacedTask := replaceTaskVariables(&conf, task, worker)
|
replacedTask := replaceTaskVariables(&conf, task, worker)
|
||||||
expectPath := "/path/to/flamenco-storage/jobs/path/in/storage.blend"
|
expectPath := crosspath.Join(storagePath, "jobs", "path/in/storage.blend")
|
||||||
assert.Equal(t, expectPath, replacedTask.Commands[2].Parameters["filepath"])
|
assert.Equal(t, expectPath, replacedTask.Commands[2].Parameters["filepath"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
yaml "gopkg.in/yaml.v2"
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
"git.blender.org/flamenco/internal/appinfo"
|
"git.blender.org/flamenco/internal/appinfo"
|
||||||
|
"git.blender.org/flamenco/pkg/crosspath"
|
||||||
shaman_config "git.blender.org/flamenco/pkg/shaman/config"
|
shaman_config "git.blender.org/flamenco/pkg/shaman/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -271,7 +272,7 @@ func (c *Conf) addImplicitVariables() {
|
|||||||
{
|
{
|
||||||
Audience: VariableAudienceAll,
|
Audience: VariableAudienceAll,
|
||||||
Platform: VariablePlatformAll,
|
Platform: VariablePlatformAll,
|
||||||
Value: c.EffectiveStoragePath(),
|
Value: crosspath.ToSlash(c.EffectiveStoragePath()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.blender.org/flamenco/pkg/crosspath"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +67,9 @@ func TestStorageImplicitVariablesWithShaman(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.False(t, c.implicitVariables["jobs"].IsTwoWay)
|
assert.False(t, c.implicitVariables["jobs"].IsTwoWay)
|
||||||
assert.Equal(t, c.Shaman.CheckoutPath(), c.implicitVariables["jobs"].Values[0].Value)
|
assert.Equal(t,
|
||||||
|
crosspath.ToSlash(c.Shaman.CheckoutPath()),
|
||||||
|
c.implicitVariables["jobs"].Values[0].Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStorageImplicitVariablesWithoutShaman(t *testing.T) {
|
func TestStorageImplicitVariablesWithoutShaman(t *testing.T) {
|
||||||
@ -92,5 +95,7 @@ func TestStorageImplicitVariablesWithoutShaman(t *testing.T) {
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
assert.False(t, c.implicitVariables["jobs"].IsTwoWay)
|
assert.False(t, c.implicitVariables["jobs"].IsTwoWay)
|
||||||
assert.Equal(t, c.SharedStoragePath, c.implicitVariables["jobs"].Values[0].Value)
|
assert.Equal(t,
|
||||||
|
crosspath.ToSlash(c.SharedStoragePath),
|
||||||
|
c.implicitVariables["jobs"].Values[0].Value)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user