Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning keyword names #2

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2016, David Luu
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# gorrs
Generic Robot Framework remote library server implementation in go

Pronounced like "gore's", abbreviation for "GO Robot Remote Server", a generic [Robot Framework](http://robotframework.org) [remote library server implementation](https://github.com/robotframework/RemoteInterface) in go.

This is a proof of concept prototype. Not fully working at the moment. See the source code for insight/details. Others are welcome to pick up where I left off.

## Setup

1. Have a version of [go](https://golang.org/dl/) installed. Recommend go 1.13+. And set up your $GOPATH and $GOBIN environment variables.
2. Get a copy of gorrs: ```go get -u github.com/daluu/gorrs```

The combination of go modules (`go.mod` + `go.sum`) & `go get -u` should pick up all the (versioned) dependencies to build gorrs. If you prefer using a different method of go dependency management, feel free to do so yourself.

## Intended usage (when gorrs is fully working):

1. Add an import statement/entry into ```protocol/protocol.go``` for the desired go-based library (go src path) to be served with gorrs. e.g. for the example remote library, ```import "github.com/daluu/gorrs/libraries"```.
2. Run the server: from source from repo path via ```go run main.go [args]```; or from compiled binary with ```go build``` or ```go install```, then run ```gorrs [args]```.

With ```go build```, the executable is in repo path, and you may move it elsewhere for use. With ```go install```, the binary is set to the $GOPATH/bin or $GOBIN paths, and can typically be executed from anywhere.

There's some issues with the gorrs XML-RPC library integration dependencies to resolve for it to fully work, and the go code reflection for dynamically serving remote libraries hasn't been implemented yet due to the existing issues. See source code for details.
16 changes: 16 additions & 0 deletions example/example_tests.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*** Settings ***
Library Remote http://${ADDRESS}:${PORT}

*** Variables ***
${ADDRESS} 127.0.0.1
${PORT} 8270

*** Test Cases ***
Count Items in Directory
${items1} = Count Items In Directory ${CURDIR}
${items2} = Count Items In Directory ${TEMPDIR}
Log ${items1} items in '${CURDIR}' and ${items2} items in '${TEMPDIR}'

Failing Example
Strings Should Be Equal Hello Hello
Strings Should Be Equal not equal
7 changes: 7 additions & 0 deletions example/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/daluu/gorrs/example

go 1.13

require github.com/daluu/gorrs v0.0.0-20191113073619-c1ebfd7cfc64 // indirect

replace github.com/daluu/gorrs v0.0.0-20191113073619-c1ebfd7cfc64 => ../
8 changes: 8 additions & 0 deletions example/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/daluu/gorrs v0.0.0-20191113073619-c1ebfd7cfc64 h1:xL3464UC/iZOSZfu7i+pEGZYFjQRqM/EAM7eVmtdKhM=
github.com/daluu/gorrs v0.0.0-20191113073619-c1ebfd7cfc64/go.mod h1:oo2wZm9B9woepF3VGBfQPFmhDQfajFLLeepu5QqyS5s=
github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda h1:q6BJCx6rxRJv/sLreclgzu4dK4dPF8x48afqcXtRtLQ=
github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda/go.mod h1:3Cp6mWQcmK3erqkPrriKEkSpok0LO1uB2M5GxGzifhc=
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31 h1:DE4LcMKyqAVa6a0CGmVxANbnVb7stzMmPkQiieyNmfQ=
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
10 changes: 10 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import (
"github.com/daluu/gorrs/libraries"
"github.com/daluu/gorrs/runner"
)

func main() {
runner.RunRemoteServer(new(libraries.ExampleRemoteLibrary))
}
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/daluu/gorrs

go 1.13

require (
github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda
github.com/gorilla/rpc v1.2.0
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31 // indirect
)

replace github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda => github.com/samirkut/gorilla-xmlrpc v0.0.0-20200110153911-8acdd7083791
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda h1:q6BJCx6rxRJv/sLreclgzu4dK4dPF8x48afqcXtRtLQ=
github.com/divan/gorilla-xmlrpc v0.0.0-20190926132722-f0686da74fda/go.mod h1:3Cp6mWQcmK3erqkPrriKEkSpok0LO1uB2M5GxGzifhc=
github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk=
github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ=
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31 h1:DE4LcMKyqAVa6a0CGmVxANbnVb7stzMmPkQiieyNmfQ=
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/samirkut/gorilla-xmlrpc v0.0.0-20200110153911-8acdd7083791 h1:xrBucR0ZjpmFRYe2dwzobq01njvwffuWp8CaS01VMJ4=
github.com/samirkut/gorilla-xmlrpc v0.0.0-20200110153911-8acdd7083791/go.mod h1:cpCVXo7AA8zZqhx4ApNmJXo3i+UgHUk7IVKYxgdBvD0=
48 changes: 48 additions & 0 deletions libraries/example_library.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package libraries

import (
"errors"
"fmt"
"io/ioutil"
)

//ExampleRemoteLibrary to be used with Robot Framework's remote server.
type ExampleRemoteLibrary struct{}

//CountItemsInDirectory the number of items in the directory specified by `path`.
func (lib *ExampleRemoteLibrary) CountItemsInDirectory(path string) (int, error) {
fileCount := 0
files, err := ioutil.ReadDir(path)
if err != nil {
return fileCount, err
}
fileCount = len(files)
return fileCount, err
}

//StringsShouldBeEqual ...
func (lib *ExampleRemoteLibrary) StringsShouldBeEqual(str1 string, str2 string) error {
fmt.Printf("Comparing '%s' to '%s'.", str1, str2)
if str1 != str2 {
return errors.New("Given strings are not equal.")
} else {
return nil
}
}

//optional extra keyword below, following phrrs (PHP robot framework remote server)
//comment out if it interferes with running example remote library tests against gorrs

//TruthOfLife ...
func (lib *ExampleRemoteLibrary) TruthOfLife() int {
return 42
}

//TruthOfLife ...
func (lib *ExampleRemoteLibrary) ReturnArray() []interface{} {
var testArray []interface{}
testArray = append(testArray, "string")
testArray = append(testArray, 1)
testArray = append(testArray, 1.1)
return testArray
}
25 changes: 25 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"log"
)

/* add to import list of github.com/daluu/gorrs/protocol/protocol.go,
* the (exported) go remote (test) library packages
* to be served by this remote server via reflection. To do that since we
* have to explicitly reference packages to reflect on and not be able to
* just pass in package reference at runtime?
*/

/* TODO: also look into whether there's any other alternative to
* gorilla/rpc and divan/gorilla-xmlrpc/xml in case of issues with XML-RPC
* support / implementation in go. Or what can be done to extend them to do
* what we need for a go-based Robot Framework generic remote library server
*
* Full spec for said server:
* https://github.com/robotframework/RemoteInterface
*/

func main() {
log.Fatal("not runnable directly")
}
Loading