1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/e2e/main.go
Tim Voronov 5620be211c
Next (#214)
* Renamed DOCUMENT to PAGE

* Added PageLoadParams

* Added PageLoadParams

* Renamed LoadPageParams -> PageLoadParams

* Added support for context.Done() (#201)

* Bug/#189 operators precedence (#202)

* Fixed math operators precedence

* Fixed logical operators precedence

* Fixed array operator

* Added support for parentheses to enforce a different operator evaluation order

* Feature/#200 drivers (#209)

* Added new interfaces

* Renamed dynamic to cdp driver

* Renamed drivers

* Added ELEMENT_EXISTS function (#210)

* Renamed back PAGE to DOCUMENT (#211)

* Added Getter and Setter interfaces
2018-12-21 23:14:41 -05:00

112 lines
1.9 KiB
Go

package main
import (
"flag"
"fmt"
"github.com/MontFerret/ferret/e2e/runner"
"github.com/MontFerret/ferret/e2e/server"
"github.com/rs/zerolog"
"os"
"path/filepath"
"regexp"
)
var (
testsDir = flag.String(
"tests",
"./tests",
"root directory with test scripts",
)
pagesDir = flag.String(
"pages",
"./pages",
"root directory with test pages",
)
cdp = flag.String(
"cdp",
"http://0.0.0.0:9222",
"address of remote Chrome instance",
)
filter = flag.String(
"filter",
"",
"regexp expression to filter out tests",
)
)
func main() {
flag.Parse()
logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr})
staticPort := uint64(8080)
static := server.New(server.Settings{
Port: staticPort,
Dir: filepath.Join(*pagesDir, "static"),
})
dynamicPort := uint64(8081)
dynamic := server.New(server.Settings{
Port: dynamicPort,
Dir: filepath.Join(*pagesDir, "dynamic"),
})
var filterR *regexp.Regexp
if *filter != "" {
r, err := regexp.Compile(*filter)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
filterR = r
}
go func() {
if err := static.Start(); err != nil {
logger.Info().Timestamp().Msg("shutting down the static pages server")
}
}()
go func() {
if err := dynamic.Start(); err != nil {
logger.Info().Timestamp().Msg("shutting down the dynamic pages server")
}
}()
dirname := *testsDir
if dirname == "" {
d, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
logger.Fatal().Timestamp().Err(err).Msg("failed to get testsDir")
return
}
dirname = d
}
r := runner.New(logger, runner.Settings{
StaticServerAddress: fmt.Sprintf("http://0.0.0.0:%d", staticPort),
DynamicServerAddress: fmt.Sprintf("http://0.0.0.0:%d", dynamicPort),
CDPAddress: *cdp,
Dir: *testsDir,
Filter: filterR,
})
err := r.Run()
if err != nil {
os.Exit(1)
}
os.Exit(0)
}