lang: Move stateful test objects into a per-test mode
Was this causing failures? Does this make things much slower?
This commit is contained in:
@@ -109,25 +109,6 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
|
|
||||||
variables := map[string]interfaces.Expr{
|
|
||||||
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
|
||||||
// TODO: change to a func when we can change hostname dynamically!
|
|
||||||
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
|
||||||
}
|
|
||||||
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
|
||||||
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
|
||||||
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("couldn't merge in consts: %+v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
scope := &interfaces.Scope{ // global scope
|
|
||||||
Variables: variables,
|
|
||||||
// all the built-in top-level, core functions enter here...
|
|
||||||
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
type test struct { // an individual test
|
type test struct { // an individual test
|
||||||
name string
|
name string
|
||||||
path string // relative txtar path inside tests dir
|
path string // relative txtar path inside tests dir
|
||||||
@@ -304,6 +285,25 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &util.AferoFs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
|
variables := map[string]interfaces.Expr{
|
||||||
|
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
||||||
|
// TODO: change to a func when we can change hostname dynamically!
|
||||||
|
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
||||||
|
}
|
||||||
|
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
||||||
|
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
||||||
|
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("couldn't merge in consts: %+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
scope := &interfaces.Scope{ // global scope
|
||||||
|
Variables: variables,
|
||||||
|
// all the built-in top-level, core functions enter here...
|
||||||
|
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
||||||
|
}
|
||||||
|
|
||||||
// use this variant, so that we don't copy the dir name
|
// use this variant, so that we don't copy the dir name
|
||||||
// this is the equivalent to running `rsync -a src/ /`
|
// this is the equivalent to running `rsync -a src/ /`
|
||||||
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
||||||
@@ -596,25 +596,6 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
|
|
||||||
variables := map[string]interfaces.Expr{
|
|
||||||
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
|
||||||
// TODO: change to a func when we can change hostname dynamically!
|
|
||||||
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
|
||||||
}
|
|
||||||
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
|
||||||
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
|
||||||
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("couldn't merge in consts: %+v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
scope := &interfaces.Scope{ // global scope
|
|
||||||
Variables: variables,
|
|
||||||
// all the built-in top-level, core functions enter here...
|
|
||||||
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
type test struct { // an individual test
|
type test struct { // an individual test
|
||||||
name string
|
name string
|
||||||
path string // relative txtar path inside tests dir
|
path string // relative txtar path inside tests dir
|
||||||
@@ -841,6 +822,25 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variables := map[string]interfaces.Expr{
|
||||||
|
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
||||||
|
// TODO: change to a func when we can change hostname dynamically!
|
||||||
|
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
||||||
|
}
|
||||||
|
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
||||||
|
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
||||||
|
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("couldn't merge in consts: %+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
scope := &interfaces.Scope{ // global scope
|
||||||
|
Variables: variables,
|
||||||
|
// all the built-in top-level, core functions enter here...
|
||||||
|
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
||||||
|
}
|
||||||
|
|
||||||
// use this variant, so that we don't copy the dir name
|
// use this variant, so that we don't copy the dir name
|
||||||
// this is the equivalent to running `rsync -a src/ /`
|
// this is the equivalent to running `rsync -a src/ /`
|
||||||
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
||||||
@@ -1411,25 +1411,6 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
|
|
||||||
variables := map[string]interfaces.Expr{
|
|
||||||
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
|
||||||
// TODO: change to a func when we can change hostname dynamically!
|
|
||||||
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
|
||||||
}
|
|
||||||
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
|
||||||
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
|
||||||
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("couldn't merge in consts: %+v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
scope := &interfaces.Scope{ // global scope
|
|
||||||
Variables: variables,
|
|
||||||
// all the built-in top-level, core functions enter here...
|
|
||||||
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
|
||||||
}
|
|
||||||
|
|
||||||
type test struct { // an individual test
|
type test struct { // an individual test
|
||||||
name string
|
name string
|
||||||
path string // relative txtar path inside tests dir
|
path string // relative txtar path inside tests dir
|
||||||
@@ -1650,6 +1631,25 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variables := map[string]interfaces.Expr{
|
||||||
|
"purpleidea": &ast.ExprStr{V: "hello world!"}, // james says hi
|
||||||
|
// TODO: change to a func when we can change hostname dynamically!
|
||||||
|
"hostname": &ast.ExprStr{V: ""}, // NOTE: empty b/c not used
|
||||||
|
}
|
||||||
|
consts := ast.VarPrefixToVariablesScope(vars.ConstNamespace) // strips prefix!
|
||||||
|
addback := vars.ConstNamespace + interfaces.ModuleSep // add it back...
|
||||||
|
variables, err = ast.MergeExprMaps(variables, consts, addback)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("couldn't merge in consts: %+v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
scope := &interfaces.Scope{ // global scope
|
||||||
|
Variables: variables,
|
||||||
|
// all the built-in top-level, core functions enter here...
|
||||||
|
Functions: ast.FuncPrefixToFunctionsScope(""), // runs funcs.LookupPrefix
|
||||||
|
}
|
||||||
|
|
||||||
// use this variant, so that we don't copy the dir name
|
// use this variant, so that we don't copy the dir name
|
||||||
// this is the equivalent to running `rsync -a src/ /`
|
// this is the equivalent to running `rsync -a src/ /`
|
||||||
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
if err := util.CopyDiskContentsToFs(fs, src, "/", false); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user