begin replacement of modifiers, support generic criteria concatenation

This commit is contained in:
Aaron Meihm 2015-08-03 12:01:32 -05:00
Родитель 442fec773f
Коммит 01b55c6932
8 изменённых файлов: 59 добавлений и 120 удалений

29
src/scribe/concat.go Normal file
Просмотреть файл

@ -0,0 +1,29 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Contributor:
// - Aaron Meihm ameihm@mozilla.com
package scribe
func criteriaConcat(in []evaluationCriteria, concat string) []evaluationCriteria {
ret := make([]evaluationCriteria, 0)
if len(in) == 0 {
return ret
}
debugPrint("criteriaConcat(): applying concat with \"%v\"\n", concat)
n := evaluationCriteria{}
for _, x := range in {
if len(n.testValue) == 0 {
n.identifier = "concat:" + x.identifier
n.testValue = x.testValue
} else {
n.identifier = n.identifier + "," + x.identifier
n.testValue = n.testValue + concat + x.testValue
}
}
debugPrint("criteriaConcat(): concat result is \"%v\"\n", n.testValue)
ret = append(ret, n)
return ret
}

Просмотреть файл

@ -21,6 +21,7 @@ type filecontent struct {
Path string `json:"path"`
File string `json:"file"`
Expression string `json:"expression"`
Concat string `json:"concat"`
matches []contentMatch
}
@ -76,6 +77,9 @@ func (f *filecontent) getCriteria() (ret []evaluationCriteria) {
}
}
}
if len(f.Concat) != 0 {
return criteriaConcat(ret, f.Concat)
}
return ret
}

Просмотреть файл

@ -1,4 +1,4 @@
TESTDIRS = filecontent filename package concat raw evrtest
TESTDIRS = filecontent filename package import-chain raw evrtest
all:

Просмотреть файл

@ -1,119 +0,0 @@
{
"variables": [
{ "key": "root", "value": "REPLACE_IN_MAKEFILE" }
],
"tests": [
{
"identifier": "filename0",
"expectedresult": true,
"filecontent": {
"path": "${root}",
"file": "testfile0",
"expression": "var = \\((\\S+), (\\S+)\\)"
}
},
{
"identifier": "filename1",
"expectedresult": true,
"filecontent": {
"path": "${root}",
"file": "testfile1",
"expression": "minor = (\\S+)"
}
},
{
"identifier": "modifier0",
"expectedresult": false,
"modifier": {
"concat": {
"operator": "."
},
"sources": [
]
}
},
{
"identifier": "modifier1",
"expectedresult": true,
"modifier": {
"concat": {
"operator": "."
},
"sources": [
{
"identifier": "filename0",
"select": "all"
}
]
}
},
{
"identifier": "modifier2",
"expectedresult": true,
"modifier": {
"concat": {
"operator": "."
},
"sources": [
{
"identifier": "filename0",
"select": "all"
}
]
},
"evr": {
"operation": "=",
"value": "1.5"
}
},
{
"identifier": "modifier3",
"expectedresult": true,
"modifier": {
"concat": {
"operator": "."
},
"sources": [
{
"identifier": "filename0",
"select": "all"
}
]
},
"regexp": {
"value": "1.5"
}
},
{
"identifier": "modifier4",
"expectedresult": true,
"modifier": {
"concat": {
"operator": "."
},
"sources": [
{
"identifier": "filename0",
"select": "all"
},
{
"identifier": "filename1",
"select": "all"
}
]
},
"evr": {
"operation": "<",
"value": "1.5.9"
}
}
]
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,25 @@
{
"variables": [
{ "key": "root", "value": "REPLACE_IN_MAKEFILE" }
],
"objects": [
{
"object": "testfile0-content",
"filecontent": {
"path": "${root}",
"file": "testfile0",
"expression": "var = \\((\\S+), (\\S+)\\)",
"concat": "."
}
}
],
"tests": [
{
"test": "testfile0-noop",
"expectedresult": true,
"object": "testfile0-content"
}
]
}