From 4ac6db006a063f6671af28230f37aef3d109e76b Mon Sep 17 00:00:00 2001 From: Ahmed Elsabbahy Date: Mon, 7 Aug 2023 07:05:52 -0700 Subject: [PATCH] Added: Initial diff support (#827) * Added: Initial diff support * Minor doc fix * Always show diff when string values do not match * switch to go-difflib as it handles single line strings better * Update travis.yaml to not double build PRs * Update dependencies --- .travis.yml | 6 + docs/manual.md | 10 +- go.mod | 20 +-- go.sum | 26 +++ outputs/outputs.go | 31 ++++ testdata/matching_basic.yaml | 16 ++ testdata/matching_basic_failing.yaml | 16 ++ testdata/out_matching_basic.0.documentation | 4 +- testdata/out_matching_basic.0.nagios | 2 +- testdata/out_matching_basic.0.rspecish | 4 +- testdata/out_matching_basic.0.tap | 20 ++- ...out_matching_basic_failing.1.documentation | 162 +++++++++++++++++- .../out_matching_basic_failing.1.rspecish | 85 ++++++++- testdata/out_matching_basic_failing.1.tap | 32 ++-- testdata/out_matching_basic_failing.2.nagios | 2 +- ...ching_transformers_failing.1.documentation | 48 ++++++ ...t_matching_transformers_failing.1.rspecish | 24 +++ 17 files changed, 461 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6409b67c2..7b9a65ec8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,12 @@ osx_image: xcode12.2 services: - docker +# don't build any branch other than master (and prs) when git pushed +branches: + only: + - master + + before_install: - if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then choco install make; fi # bash from macOS is too old to have readarray. Install newer version. diff --git a/docs/manual.md b/docs/manual.md index a5babd205..ab5d85f2b 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -960,7 +960,7 @@ kernel-param: value: {gt: 200} ``` -When a transformed test fails, it will detail the transformers used, the `-o include_raw` option can be used to include the raw, untransformed attribute value: +When a transformed test fails, it will detail the transformers used, the `-o exclude_raw` option can be used to exclude the raw, untransformed attribute value: ``` $ goss v F @@ -974,12 +974,13 @@ to be > 200 the transform chain was [{"to-numeric":{}}] +the raw value was + "128" Total Duration: 0.001s Count: 1, Failed: 1, Skipped: 0 - -$ goss v -o include_raw +$ goss v -o exclude_raw F Failures/Skipped: @@ -991,12 +992,11 @@ to be > 200 the transform chain was [{"to-numeric":{}}] -the raw value was - "128" Total Duration: 0.001s Count: 1, Failed: 1, Skipped: 0 + ``` ### Advanced Matchers diff --git a/go.mod b/go.mod index 3b5ec157e..37eedaed3 100644 --- a/go.mod +++ b/go.mod @@ -15,13 +15,14 @@ require ( github.com/miekg/dns v1.1.55 github.com/moby/sys/mountinfo v0.6.2 github.com/oleiade/reflections v1.0.1 - github.com/onsi/gomega v1.27.8 + github.com/onsi/gomega v1.27.10 github.com/patrickmn/go-cache v2.1.0+incompatible + github.com/pmezard/go-difflib v1.0.0 github.com/prometheus/client_golang v1.16.0 github.com/prometheus/common v0.44.0 github.com/samber/lo v1.38.1 github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.14.4 + github.com/tidwall/gjson v1.15.0 github.com/urfave/cli v1.22.14 gopkg.in/yaml.v2 v2.4.0 gotest.tools/v3 v3.0.3 @@ -45,21 +46,20 @@ require ( github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/procfs v0.11.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect + golang.org/x/crypto v0.12.0 // indirect + golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect - golang.org/x/tools v0.11.0 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect + golang.org/x/tools v0.11.1 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 76d166335..589945cc5 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -52,6 +53,9 @@ github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0/go.mod h1:c1tRKs5Tx7E2+u github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -71,11 +75,17 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oleiade/reflections v1.0.1 h1:D1XO3LVEYroYskEsoSiGItp9RUxG6jWnCVvrqH0HHQM= github.com/oleiade/reflections v1.0.1/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60= github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -91,6 +101,8 @@ github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdO github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -115,6 +127,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.15.0 h1:5n/pM+v3r5ujuNl4YLZLsQ+UE5jlkLVm7jMzT5Mpolw= +github.com/tidwall/gjson v1.15.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -128,8 +142,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw= golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI= +golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -140,6 +158,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -154,6 +174,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -163,12 +185,16 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= +golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/outputs/outputs.go b/outputs/outputs.go index 9aeb72e87..662a75289 100644 --- a/outputs/outputs.go +++ b/outputs/outputs.go @@ -17,6 +17,7 @@ import ( "github.com/goss-org/goss/resource" "github.com/goss-org/goss/util" "github.com/icza/dyno" + "github.com/pmezard/go-difflib/difflib" ) type formatOption struct { @@ -94,6 +95,7 @@ func prettyPrintTestResult(t resource.TestResult, compact bool, includeRaw bool) ss = append(ss, prettyPrint(m.Actual, !compact)) ss = append(ss, m.Message) ss = append(ss, prettyPrint(m.Expected, !compact)) + ss = maybeAddDiff(ss, m.Expected, m.Actual, compact) } if reflect.ValueOf(m.MissingElements).IsValid() && !reflect.ValueOf(m.MissingElements).IsNil() { @@ -115,6 +117,35 @@ func prettyPrintTestResult(t resource.TestResult, compact bool, includeRaw bool) return strings.Join(ss, sep) } +func maybeAddDiff(ss []string, expected, actual any, compact bool) []string { + if compact { + return ss + } + want, ok := expected.(string) + if !ok { + return ss + } + got, ok := actual.(string) + if !ok { + return ss + } + if want == got { + return ss + } + ss = append(ss, "diff") + diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ + A: difflib.SplitLines(want), + B: difflib.SplitLines(got), + FromFile: "test", + FromDate: "", + ToFile: "actual", + ToDate: "", + Context: 1, + }) + ss = append(ss, indentLines(diff)) + return ss +} + func prettyPrint(i interface{}, indent bool) string { // JSON doesn't like non-string keys i = dyno.ConvertMapI2MapS(i) diff --git a/testdata/matching_basic.yaml b/testdata/matching_basic.yaml index edd9ee672..67af512ad 100644 --- a/testdata/matching_basic.yaml +++ b/testdata/matching_basic.yaml @@ -4,6 +4,22 @@ matching: content: 'this is a test' matches: 'this is a test' + basic_string_oneline: + content: | + this is a test1 + matches: | + this is a test1 + + basic_string_multiline: + content: | + this is a test1 + this is a test2 + this is a test3 + matches: | + this is a test1 + this is a test2 + this is a test3 + basic_string_regexp: content: 'this is a test' matches: diff --git a/testdata/matching_basic_failing.yaml b/testdata/matching_basic_failing.yaml index 51a6a4277..1d2351149 100644 --- a/testdata/matching_basic_failing.yaml +++ b/testdata/matching_basic_failing.yaml @@ -4,6 +4,22 @@ matching: content: 'this is a test' matches: 'this is a failing test' + basic_string_oneline: + content: | + this is a test1 + matches: | + this is a test9 + + basic_string_multiline: + content: | + this is a test1 + this is a test2 + this is a test3 + matches: | + this is a test1 + this is a test9 + this is a test3 + basic_string_have_prefix: content: 'foo' matches: diff --git a/testdata/out_matching_basic.0.documentation b/testdata/out_matching_basic.0.documentation index d96a8e279..6b923d5dd 100644 --- a/testdata/out_matching_basic.0.documentation +++ b/testdata/out_matching_basic.0.documentation @@ -4,6 +4,8 @@ Matching: basic_int: matches: matches expectation: 42 Matching: basic_reader: matches: matches expectation: ["foo","/^m.*w$/","!ftw","!/^ERROR:/"] Matching: basic_semver: matches: matches expectation: {"semver-constraint":">=1.2.0"} Matching: basic_string: matches: matches expectation: "this is a test" +Matching: basic_string_multiline: matches: matches expectation: "this is a test1\nthis is a test2\nthis is a test3\n" +Matching: basic_string_oneline: matches: matches expectation: "this is a test1\n" Matching: basic_string_regexp: matches: matches expectation: {"match-regexp":"^this"} Matching: basic_string_skip: matches: skipped Matching: negated_basic_array: matches: matches expectation: {"not":["group1","group2","group2","group4"]} @@ -19,4 +21,4 @@ Failures/Skipped: Matching: basic_string_skip: matches: skipped Total Duration: -Count: 14, Failed: 0, Skipped: 1 +Count: 16, Failed: 0, Skipped: 1 diff --git a/testdata/out_matching_basic.0.nagios b/testdata/out_matching_basic.0.nagios index fc2d28ea6..b727d1a36 100644 --- a/testdata/out_matching_basic.0.nagios +++ b/testdata/out_matching_basic.0.nagios @@ -1 +1 @@ -GOSS OK - Count: 14, Failed: 0, Skipped: 1, Duration: +GOSS OK - Count: 16, Failed: 0, Skipped: 1, Duration: diff --git a/testdata/out_matching_basic.0.rspecish b/testdata/out_matching_basic.0.rspecish index 3d8077bbf..02a906f50 100644 --- a/testdata/out_matching_basic.0.rspecish +++ b/testdata/out_matching_basic.0.rspecish @@ -1,8 +1,8 @@ -.......S...... +.........S...... Failures/Skipped: Matching: basic_string_skip: matches: skipped Total Duration: -Count: 14, Failed: 0, Skipped: 1 +Count: 16, Failed: 0, Skipped: 1 diff --git a/testdata/out_matching_basic.0.tap b/testdata/out_matching_basic.0.tap index 0ab691b7c..4670d80eb 100644 --- a/testdata/out_matching_basic.0.tap +++ b/testdata/out_matching_basic.0.tap @@ -1,15 +1,17 @@ -1..14 +1..16 ok 1 - Matching: basic_array: matches: matches expectation: ["group1","group2"] ok 2 - Matching: basic_array_matchers: matches: matches expectation: {"and":[{"contain-elements":["foo","bar"]},["foo","bar"],{"equal":["foo","bar","moo"]},{"consist-of":["foo",{"have-prefix":"m"},"bar"]},{"contain-element":{"have-prefix":"b"}},{"contain-element":{"have-suffix":"r"}}]} ok 3 - Matching: basic_int: matches: matches expectation: 42 ok 4 - Matching: basic_reader: matches: matches expectation: ["foo","/^m.*w$/","!ftw","!/^ERROR:/"] ok 5 - Matching: basic_semver: matches: matches expectation: {"semver-constraint":">=1.2.0"} ok 6 - Matching: basic_string: matches: matches expectation: "this is a test" -ok 7 - Matching: basic_string_regexp: matches: matches expectation: {"match-regexp":"^this"} -ok 8 - # SKIP Matching: basic_string_skip: matches: skipped -ok 9 - Matching: negated_basic_array: matches: matches expectation: {"not":["group1","group2","group2","group4"]} -ok 10 - Matching: negated_basic_array_matchers: matches: matches expectation: {"and":[{"not":{"contain-elements":["fox","box"]}},{"not":["fox","bax"]},{"not":{"equal":["fox","bax","mox"]}},{"not":{"consist-of":[{"have-suffix":"x"},{"have-prefix":"t"},"box"]}},{"not":{"contain-element":{"have-prefix":"x"}}}]} -ok 11 - Matching: negated_basic_int: matches: matches expectation: {"not":43} -ok 12 - Matching: negated_basic_reader: matches: matches expectation: {"not":{"contain-elements":["fox","/^t.*w$/","!foo","!/^foo/"]}} -ok 13 - Matching: negated_basic_string: matches: matches expectation: {"not":"this is a failing test"} -ok 14 - Matching: negated_basic_string_regexp: matches: matches expectation: {"not":{"match-regexp":"^foo"}} +ok 7 - Matching: basic_string_multiline: matches: matches expectation: "this is a test1\nthis is a test2\nthis is a test3\n" +ok 8 - Matching: basic_string_oneline: matches: matches expectation: "this is a test1\n" +ok 9 - Matching: basic_string_regexp: matches: matches expectation: {"match-regexp":"^this"} +ok 10 - # SKIP Matching: basic_string_skip: matches: skipped +ok 11 - Matching: negated_basic_array: matches: matches expectation: {"not":["group1","group2","group2","group4"]} +ok 12 - Matching: negated_basic_array_matchers: matches: matches expectation: {"and":[{"not":{"contain-elements":["fox","box"]}},{"not":["fox","bax"]},{"not":{"equal":["fox","bax","mox"]}},{"not":{"consist-of":[{"have-suffix":"x"},{"have-prefix":"t"},"box"]}},{"not":{"contain-element":{"have-prefix":"x"}}}]} +ok 13 - Matching: negated_basic_int: matches: matches expectation: {"not":43} +ok 14 - Matching: negated_basic_reader: matches: matches expectation: {"not":{"contain-elements":["fox","/^t.*w$/","!foo","!/^foo/"]}} +ok 15 - Matching: negated_basic_string: matches: matches expectation: {"not":"this is a failing test"} +ok 16 - Matching: negated_basic_string_regexp: matches: matches expectation: {"not":{"match-regexp":"^foo"}} diff --git a/testdata/out_matching_basic_failing.1.documentation b/testdata/out_matching_basic_failing.1.documentation index 3e6406f26..ecbf2b1e2 100644 --- a/testdata/out_matching_basic_failing.1.documentation +++ b/testdata/out_matching_basic_failing.1.documentation @@ -46,26 +46,81 @@ Expected "this is a test" to equal "this is a failing test" +diff + --- test + +++ actual + @@ -1 +1 @@ + -this is a failing test + +this is a test Matching: basic_string_contain_substring: matches: Expected "foo" to contain substring "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo Matching: basic_string_have_prefix: matches: Expected "foo" to have prefix "g" +diff + --- test + +++ actual + @@ -1 +1 @@ + -g + +foo Matching: basic_string_have_suffix: matches: Expected "foo" to have suffix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo +Matching: basic_string_multiline: matches: +Expected + "this is a test1\nthis is a test2\nthis is a test3\n" +to equal + "this is a test1\nthis is a test9\nthis is a test3\n" +diff + --- test + +++ actual + @@ -1,3 +1,3 @@ + this is a test1 + -this is a test9 + +this is a test2 + this is a test3 +Matching: basic_string_oneline: matches: +Expected + "this is a test1\n" +to equal + "this is a test9\n" +diff + --- test + +++ actual + @@ -1,2 +1,2 @@ + -this is a test9 + +this is a test1 + Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^foo + +this is a test Matching: negated_and: matches: Expected 42 @@ -117,21 +172,45 @@ Expected "foo" not to contain substring "oo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -oo + +foo Matching: negatedbasic_string_have_prefix: matches: Expected "foo" not to have prefix "f" +diff + --- test + +++ actual + @@ -1 +1 @@ + -f + +foo Matching: negatedbasic_string_have_suffix: matches: Expected "foo" not to have suffix "o" +diff + --- test + +++ actual + @@ -1 +1 @@ + -o + +foo Matching: negatedbasic_string_regexp: matches: Expected "this is a test" not to match regular expression "^this" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^this + +this is a test Failures/Skipped: @@ -191,30 +270,87 @@ Expected "this is a test" to equal "this is a failing test" +diff + --- test + +++ actual + @@ -1 +1 @@ + -this is a failing test + +this is a test Matching: basic_string_contain_substring: matches: Expected "foo" to contain substring "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo Matching: basic_string_have_prefix: matches: Expected "foo" to have prefix "g" +diff + --- test + +++ actual + @@ -1 +1 @@ + -g + +foo Matching: basic_string_have_suffix: matches: Expected "foo" to have suffix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo + +Matching: basic_string_multiline: matches: +Expected + "this is a test1\nthis is a test2\nthis is a test3\n" +to equal + "this is a test1\nthis is a test9\nthis is a test3\n" +diff + --- test + +++ actual + @@ -1,3 +1,3 @@ + this is a test1 + -this is a test9 + +this is a test2 + this is a test3 + +Matching: basic_string_oneline: matches: +Expected + "this is a test1\n" +to equal + "this is a test9\n" +diff + --- test + +++ actual + @@ -1,2 +1,2 @@ + -this is a test9 + +this is a test1 + Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^foo + +this is a test Matching: negated_and: matches: Expected @@ -276,24 +412,48 @@ Expected "foo" not to contain substring "oo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -oo + +foo Matching: negatedbasic_string_have_prefix: matches: Expected "foo" not to have prefix "f" +diff + --- test + +++ actual + @@ -1 +1 @@ + -f + +foo Matching: negatedbasic_string_have_suffix: matches: Expected "foo" not to have suffix "o" +diff + --- test + +++ actual + @@ -1 +1 @@ + -o + +foo Matching: negatedbasic_string_regexp: matches: Expected "this is a test" not to match regular expression "^this" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^this + +this is a test Total Duration: -Count: 25, Failed: 25, Skipped: 0 +Count: 27, Failed: 27, Skipped: 0 diff --git a/testdata/out_matching_basic_failing.1.rspecish b/testdata/out_matching_basic_failing.1.rspecish index 8618ec70c..e126aec29 100644 --- a/testdata/out_matching_basic_failing.1.rspecish +++ b/testdata/out_matching_basic_failing.1.rspecish @@ -1,4 +1,4 @@ -FFFFFFFFFFFFFFFFFFFFFFFFF +FFFFFFFFFFFFFFFFFFFFFFFFFFF Failures/Skipped: @@ -57,30 +57,87 @@ Expected "this is a test" to equal "this is a failing test" +diff + --- test + +++ actual + @@ -1 +1 @@ + -this is a failing test + +this is a test Matching: basic_string_contain_substring: matches: Expected "foo" to contain substring "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo Matching: basic_string_have_prefix: matches: Expected "foo" to have prefix "g" +diff + --- test + +++ actual + @@ -1 +1 @@ + -g + +foo Matching: basic_string_have_suffix: matches: Expected "foo" to have suffix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +foo + +Matching: basic_string_multiline: matches: +Expected + "this is a test1\nthis is a test2\nthis is a test3\n" +to equal + "this is a test1\nthis is a test9\nthis is a test3\n" +diff + --- test + +++ actual + @@ -1,3 +1,3 @@ + this is a test1 + -this is a test9 + +this is a test2 + this is a test3 + +Matching: basic_string_oneline: matches: +Expected + "this is a test1\n" +to equal + "this is a test9\n" +diff + --- test + +++ actual + @@ -1,2 +1,2 @@ + -this is a test9 + +this is a test1 + Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^foo + +this is a test Matching: negated_and: matches: Expected @@ -142,24 +199,48 @@ Expected "foo" not to contain substring "oo" +diff + --- test + +++ actual + @@ -1 +1 @@ + -oo + +foo Matching: negatedbasic_string_have_prefix: matches: Expected "foo" not to have prefix "f" +diff + --- test + +++ actual + @@ -1 +1 @@ + -f + +foo Matching: negatedbasic_string_have_suffix: matches: Expected "foo" not to have suffix "o" +diff + --- test + +++ actual + @@ -1 +1 @@ + -o + +foo Matching: negatedbasic_string_regexp: matches: Expected "this is a test" not to match regular expression "^this" +diff + --- test + +++ actual + @@ -1 +1 @@ + -^this + +this is a test Total Duration: -Count: 25, Failed: 25, Skipped: 0 +Count: 27, Failed: 27, Skipped: 0 diff --git a/testdata/out_matching_basic_failing.1.tap b/testdata/out_matching_basic_failing.1.tap index 1e7b141ba..9aeefc99f 100644 --- a/testdata/out_matching_basic_failing.1.tap +++ b/testdata/out_matching_basic_failing.1.tap @@ -1,4 +1,4 @@ -1..25 +1..27 not ok 1 - Matching: basic_array: matches: Expected ["group1","group2","group3"] to contain elements ["group1","group2","group2","group4"] the missing elements were ["group2","group4"] not ok 2 - Matching: basic_array_consists_of: matches: Expected ["foo","bar","moo"] to consist of ["fox",{"have-prefix":"t"},"box"] the missing elements were ["fox",{"have-prefix":"t"},"box"] the extra elements were ["foo","bar","moo"] not ok 3 - Matching: basic_array_matchers: matches: Expected ["foo","bar","moo"] to satisfy at least one of these matchers [{"contain-elements":["fox","box"]},{"contain-elements":["fox","bax"]},["fox","bax","mox"],{"consist-of":["fox",{"have-prefix":"t"},"box"]},{"contain-element":{"have-prefix":"x"}},{"contain-element":{"have-suffix":"x"}}] @@ -10,17 +10,19 @@ not ok 8 - Matching: basic_string: matches: Expected "this is a test" to equal " not ok 9 - Matching: basic_string_contain_substring: matches: Expected "foo" to contain substring "x" not ok 10 - Matching: basic_string_have_prefix: matches: Expected "foo" to have prefix "g" not ok 11 - Matching: basic_string_have_suffix: matches: Expected "foo" to have suffix "x" -not ok 12 - Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo" -not ok 13 - Matching: negated_and: matches: Expected 42 not to satisfy all of these matchers [{"eq":42},{"eq":42}] -not ok 14 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements ["group1","group2","group3"] -not ok 15 - Matching: negated_basic_array_consists_of: matches: Expected ["foo","bar","moo"] not to consist of ["foo",{"have-prefix":"m"},"bar"] -not ok 16 - Matching: negated_basic_array_contain_element: matches: Expected ["foo","bar","moo"] not to contain element matching "foo" -not ok 17 - Matching: negated_basic_array_matchers: matches: Expected ["foo","bar","moo"] to satisfy at least one of these matchers [{"not":{"contain-elements":["foo","bar"]}},{"not":{"contain-elements":["foo","bar"]}},{"not":["foo","bar","moo"]},{"not":{"consist-of":["foo",{"have-prefix":"m"},"bar"]}},{"not":{"contain-element":{"have-prefix":"b"}}}] -not ok 18 - Matching: negated_basic_int: matches: Expected 42 not to be numerically eq 42 -not ok 19 - Matching: negated_basic_reader: matches: Error ContainElements matcher expects an array/slice/map. Got: : foo bar moo cow -not ok 20 - Matching: negated_basic_string: matches: Expected "this is a test" not to equal "this is a test" -not ok 21 - Matching: negatedbasic_len: matches: Expected "123" not to have length 3 -not ok 22 - Matching: negatedbasic_string_contain_substring: matches: Expected "foo" not to contain substring "oo" -not ok 23 - Matching: negatedbasic_string_have_prefix: matches: Expected "foo" not to have prefix "f" -not ok 24 - Matching: negatedbasic_string_have_suffix: matches: Expected "foo" not to have suffix "o" -not ok 25 - Matching: negatedbasic_string_regexp: matches: Expected "this is a test" not to match regular expression "^this" +not ok 12 - Matching: basic_string_multiline: matches: Expected "this is a test1\nthis is a test2\nthis is a test3\n" to equal "this is a test1\nthis is a test9\nthis is a test3\n" +not ok 13 - Matching: basic_string_oneline: matches: Expected "this is a test1\n" to equal "this is a test9\n" +not ok 14 - Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo" +not ok 15 - Matching: negated_and: matches: Expected 42 not to satisfy all of these matchers [{"eq":42},{"eq":42}] +not ok 16 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements ["group1","group2","group3"] +not ok 17 - Matching: negated_basic_array_consists_of: matches: Expected ["foo","bar","moo"] not to consist of ["foo",{"have-prefix":"m"},"bar"] +not ok 18 - Matching: negated_basic_array_contain_element: matches: Expected ["foo","bar","moo"] not to contain element matching "foo" +not ok 19 - Matching: negated_basic_array_matchers: matches: Expected ["foo","bar","moo"] to satisfy at least one of these matchers [{"not":{"contain-elements":["foo","bar"]}},{"not":{"contain-elements":["foo","bar"]}},{"not":["foo","bar","moo"]},{"not":{"consist-of":["foo",{"have-prefix":"m"},"bar"]}},{"not":{"contain-element":{"have-prefix":"b"}}}] +not ok 20 - Matching: negated_basic_int: matches: Expected 42 not to be numerically eq 42 +not ok 21 - Matching: negated_basic_reader: matches: Error ContainElements matcher expects an array/slice/map. Got: : foo bar moo cow +not ok 22 - Matching: negated_basic_string: matches: Expected "this is a test" not to equal "this is a test" +not ok 23 - Matching: negatedbasic_len: matches: Expected "123" not to have length 3 +not ok 24 - Matching: negatedbasic_string_contain_substring: matches: Expected "foo" not to contain substring "oo" +not ok 25 - Matching: negatedbasic_string_have_prefix: matches: Expected "foo" not to have prefix "f" +not ok 26 - Matching: negatedbasic_string_have_suffix: matches: Expected "foo" not to have suffix "o" +not ok 27 - Matching: negatedbasic_string_regexp: matches: Expected "this is a test" not to match regular expression "^this" diff --git a/testdata/out_matching_basic_failing.2.nagios b/testdata/out_matching_basic_failing.2.nagios index aa3ddac51..ebb7d7cac 100644 --- a/testdata/out_matching_basic_failing.2.nagios +++ b/testdata/out_matching_basic_failing.2.nagios @@ -1 +1 @@ -GOSS CRITICAL - Count: 25, Failed: 25, Skipped: 0, Duration: +GOSS CRITICAL - Count: 27, Failed: 27, Skipped: 0, Duration: diff --git a/testdata/out_matching_transformers_failing.1.documentation b/testdata/out_matching_transformers_failing.1.documentation index c80967b3d..854c563dd 100644 --- a/testdata/out_matching_transformers_failing.1.documentation +++ b/testdata/out_matching_transformers_failing.1.documentation @@ -60,6 +60,12 @@ Expected "bar" to have prefix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +bar the transform chain was [{"gjson":{"Path":"foo"}}] the raw value was @@ -87,6 +93,12 @@ Expected "cow" to equal "cowx" +diff + --- test + +++ actual + @@ -1 +1 @@ + -cowx + +cow the transform chain was [{"gjson":{"Path":"moo.nested"}}] the raw value was @@ -105,6 +117,12 @@ Expected "128" to equal "129" +diff + --- test + +++ actual + @@ -1 +1 @@ + -129 + +128 the transform chain was [{"to-string":{}}] the raw value was @@ -114,6 +132,12 @@ Expected "cool" to equal "not-cool" +diff + --- test + +++ actual + @@ -1 +1 @@ + -not-cool + +cool Matching: test_reader_using_int_matchers: matches: Expected 40 @@ -219,6 +243,12 @@ Expected "bar" to have prefix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +bar the transform chain was [{"gjson":{"Path":"foo"}}] the raw value was @@ -249,6 +279,12 @@ Expected "cow" to equal "cowx" +diff + --- test + +++ actual + @@ -1 +1 @@ + -cowx + +cow the transform chain was [{"gjson":{"Path":"moo.nested"}}] the raw value was @@ -269,6 +305,12 @@ Expected "128" to equal "129" +diff + --- test + +++ actual + @@ -1 +1 @@ + -129 + +128 the transform chain was [{"to-string":{}}] the raw value was @@ -279,6 +321,12 @@ Expected "cool" to equal "not-cool" +diff + --- test + +++ actual + @@ -1 +1 @@ + -not-cool + +cool Matching: test_reader_using_int_matchers: matches: Expected diff --git a/testdata/out_matching_transformers_failing.1.rspecish b/testdata/out_matching_transformers_failing.1.rspecish index 273492d6b..b3da1b713 100644 --- a/testdata/out_matching_transformers_failing.1.rspecish +++ b/testdata/out_matching_transformers_failing.1.rspecish @@ -71,6 +71,12 @@ Expected "bar" to have prefix "x" +diff + --- test + +++ actual + @@ -1 +1 @@ + -x + +bar the transform chain was [{"gjson":{"Path":"foo"}}] the raw value was @@ -101,6 +107,12 @@ Expected "cow" to equal "cowx" +diff + --- test + +++ actual + @@ -1 +1 @@ + -cowx + +cow the transform chain was [{"gjson":{"Path":"moo.nested"}}] the raw value was @@ -121,6 +133,12 @@ Expected "128" to equal "129" +diff + --- test + +++ actual + @@ -1 +1 @@ + -129 + +128 the transform chain was [{"to-string":{}}] the raw value was @@ -131,6 +149,12 @@ Expected "cool" to equal "not-cool" +diff + --- test + +++ actual + @@ -1 +1 @@ + -not-cool + +cool Matching: test_reader_using_int_matchers: matches: Expected