зеркало из https://github.com/mozilla/mig.git
[minor] Add travis-ci test for running agent from file.
I'm applying the changes suggested in PR #139 by @jvehent; these make runModuleDurectly to not use stdin, instead only use the given parameters. Now travis-ci should test mig-agent after installing to see that it can run an action individually.
This commit is contained in:
Родитель
78867ae5bb
Коммит
e2e687f9a1
|
@ -20,3 +20,4 @@ script:
|
|||
- cd "$GOPATH/src/mig.ninja/mig"
|
||||
- make
|
||||
- yes | bash tools/standalone_install.sh
|
||||
- ./bin/linux/amd64/mig-agent-latest -i actions/example_v2.json
|
||||
|
|
|
@ -179,11 +179,7 @@ func executeAction(action mig.Action, prettyPrint bool) (cmd mig.Command, err er
|
|||
|
||||
// launch each operation consecutively
|
||||
for _, op := range action.Operations {
|
||||
args, err := json.Marshal(op.Parameters)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
out := runModuleDirectly(op.Module, args, prettyPrint)
|
||||
out := runModuleDirectly(op.Module, op.Parameters, prettyPrint)
|
||||
var res modules.Result
|
||||
err = json.Unmarshal([]byte(out), &res)
|
||||
if err != nil {
|
||||
|
@ -195,13 +191,17 @@ func executeAction(action mig.Action, prettyPrint bool) (cmd mig.Command, err er
|
|||
}
|
||||
|
||||
// runModuleDirectly executes a module and displays the results on stdout
|
||||
func runModuleDirectly(mode string, args []byte, pretty bool) (out string) {
|
||||
func runModuleDirectly(mode string, args interface{}, pretty bool) (out string) {
|
||||
if _, ok := modules.Available[mode]; !ok {
|
||||
return fmt.Sprintf(`{"errors": ["module '%s' is not available"]}`, mode)
|
||||
}
|
||||
// instanciate and call module
|
||||
run := modules.Available[mode].NewRun()
|
||||
out = run.Run(os.Stdin)
|
||||
msg, err := modules.MakeMessage(modules.MsgClassParameters, args)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
out = run.Run(bytes.NewBuffer(msg))
|
||||
if pretty {
|
||||
var modres modules.Result
|
||||
err := json.Unmarshal([]byte(out), &modres)
|
||||
|
|
Загрузка…
Ссылка в новой задаче