mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
fix the test by checking the CI variable in the real main, not in the test, and dying if we see the CI variable
This commit is contained in:
parent
32ddf2a6bd
commit
2602355e2b
|
|
@ -16,6 +16,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
|
|
@ -40,9 +41,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var samAddr = flag.String("samaddr", "127.0.0.1:7656", "Address to connect to the I2P SAMv3 API")
|
var samAddr = flag.String("samaddr", "127.0.0.1:7656", "Address to connect to the I2P SAMv3 API")
|
||||||
|
var _, skip = os.LookupEnv("CI")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := setup.ParseFlags(true)
|
cfg := setup.ParseFlags(true)
|
||||||
|
if skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
configErrors := &config.ConfigErrors{}
|
configErrors := &config.ConfigErrors{}
|
||||||
cfg.Verify(configErrors)
|
cfg.Verify(configErrors)
|
||||||
|
|
|
||||||
|
|
@ -14,43 +14,39 @@ import (
|
||||||
// Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html
|
// Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html
|
||||||
// Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc
|
// Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc
|
||||||
func TestMain(t *testing.T) {
|
func TestMain(t *testing.T) {
|
||||||
if _, ex := os.LookupEnv("CI"); ex {
|
var (
|
||||||
t.Skip("skipping test, as no TOR/I2P client is available")
|
args []string
|
||||||
} else {
|
)
|
||||||
t.Log("running locally, continuing with tests")
|
|
||||||
var (
|
|
||||||
args []string
|
|
||||||
)
|
|
||||||
|
|
||||||
for _, arg := range os.Args {
|
for _, arg := range os.Args {
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(arg, "DEVEL"):
|
case strings.HasPrefix(arg, "DEVEL"):
|
||||||
case strings.HasPrefix(arg, "-test"):
|
case strings.HasPrefix(arg, "-test"):
|
||||||
default:
|
default:
|
||||||
args = append(args, arg)
|
args = append(args, arg)
|
||||||
}
|
|
||||||
}
|
|
||||||
// only run the tests if there are args to be passed
|
|
||||||
if len(args) <= 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
waitCh := make(chan int, 1)
|
|
||||||
os.Args = args
|
|
||||||
go func() {
|
|
||||||
main()
|
|
||||||
close(waitCh)
|
|
||||||
}()
|
|
||||||
|
|
||||||
signalCh := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP)
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-signalCh:
|
|
||||||
return
|
|
||||||
case <-waitCh:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// only run the tests if there are args to be passed
|
||||||
|
if len(args) <= 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Log(args)
|
||||||
|
|
||||||
|
waitCh := make(chan int, 1)
|
||||||
|
os.Args = args
|
||||||
|
go func() {
|
||||||
|
main()
|
||||||
|
close(waitCh)
|
||||||
|
}()
|
||||||
|
|
||||||
|
signalCh := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-signalCh:
|
||||||
|
return
|
||||||
|
case <-waitCh:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
|
|
@ -38,9 +39,13 @@ import (
|
||||||
"github.com/matrix-org/dendrite/userapi"
|
"github.com/matrix-org/dendrite/userapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _, skip = os.LookupEnv("CI")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := setup.ParseFlags(true)
|
cfg := setup.ParseFlags(true)
|
||||||
|
if skip {
|
||||||
|
return
|
||||||
|
}
|
||||||
configErrors := &config.ConfigErrors{}
|
configErrors := &config.ConfigErrors{}
|
||||||
cfg.Verify(configErrors)
|
cfg.Verify(configErrors)
|
||||||
if len(*configErrors) > 0 {
|
if len(*configErrors) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -14,42 +14,39 @@ import (
|
||||||
// Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html
|
// Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html
|
||||||
// Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc
|
// Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc
|
||||||
func TestMain(t *testing.T) {
|
func TestMain(t *testing.T) {
|
||||||
if _, ex := os.LookupEnv("CI"); ex {
|
var (
|
||||||
t.Skip("skipping test, as no TOR/I2P client is available")
|
args []string
|
||||||
} else {
|
)
|
||||||
t.Log("running locally, continuing with tests")
|
|
||||||
var (
|
|
||||||
args []string
|
|
||||||
)
|
|
||||||
|
|
||||||
for _, arg := range os.Args {
|
for _, arg := range os.Args {
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(arg, "DEVEL"):
|
case strings.HasPrefix(arg, "DEVEL"):
|
||||||
case strings.HasPrefix(arg, "-test"):
|
case strings.HasPrefix(arg, "-test"):
|
||||||
default:
|
default:
|
||||||
args = append(args, arg)
|
args = append(args, arg)
|
||||||
}
|
|
||||||
}
|
|
||||||
// only run the tests if there are args to be passed
|
|
||||||
if len(args) <= 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
waitCh := make(chan int, 1)
|
|
||||||
os.Args = args
|
|
||||||
go func() {
|
|
||||||
main()
|
|
||||||
close(waitCh)
|
|
||||||
}()
|
|
||||||
|
|
||||||
signalCh := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP)
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-signalCh:
|
|
||||||
return
|
|
||||||
case <-waitCh:
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only run the tests if there are args to be passed
|
||||||
|
if len(args) <= 1 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.Log(args)
|
||||||
|
|
||||||
|
waitCh := make(chan int, 1)
|
||||||
|
os.Args = args
|
||||||
|
go func() {
|
||||||
|
main()
|
||||||
|
close(waitCh)
|
||||||
|
}()
|
||||||
|
|
||||||
|
signalCh := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-signalCh:
|
||||||
|
return
|
||||||
|
case <-waitCh:
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue