From 8e471b0eebd56deca9cd439fb8313cfc2a7b0276 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Thu, 18 Jun 2020 23:54:02 -0400 Subject: [PATCH 01/96] Adding command line flags (still need to cleanup some of the code) --- go.mod | 14 +++ go.sum | 334 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.go | 82 ++++++++++++-- 3 files changed, 420 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 12bf86d..9ad266d 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,17 @@ module go-test-report go 1.13 + +require ( + github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/mitchellh/mapstructure v1.3.2 // indirect + github.com/pelletier/go-toml v1.8.0 // indirect + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.1 // indirect + github.com/spf13/cobra v1.0.0 + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.7.0 // indirect + golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect + gopkg.in/ini.v1 v1.57.0 // indirect +) diff --git a/go.sum b/go.sum index e69de29..c825573 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,334 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYGN7GeoRg= +github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= +github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 h1:ogLJMz+qpzav7lGMh10LMvAkM/fAoGlaiiHYiFYdm80= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww= +gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/main.go b/main.go index a8e35a5..3a1687b 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bufio" "encoding/json" "fmt" + "github.com/spf13/cobra" "html/template" "io/ioutil" "os" @@ -42,17 +43,78 @@ type TestGroupData struct { TestResults []*TestStatus } +type cmdFlags struct { + titleFlag string + sizeFlag string + groupSize int8 +} + func main() { + flags := cmdFlags{} + + rootCmd := &cobra.Command{ + Use: "go-test-report", + Long: "Captures go test output and parses it into a single self-contained html file.", + Run: func(cmd *cobra.Command, args []string) { + // start timer + // -- do stuff + // end timer + }, + } + versionCmd := &cobra.Command{ + Use: "version", + Short: "Prints the version number of go-test-report", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(fmt.Sprintf("go-test-report v%s", "0.9")) + }, + } + rootCmd.AddCommand(versionCmd) + rootCmd.PersistentFlags().StringVar(&flags.titleFlag, + "title", + "go-test-report", + "the title text shown in the test report") + rootCmd.PersistentFlags().StringVar(&flags.sizeFlag, + "size", + "24", + "the size of the clickable indicator for test result groups") + rootCmd.PersistentFlags().Int8Var(&flags.groupSize, + "groupSize", + 0, + "the number of tests per test group") + + //TestResultGroupIndicatorWidth + + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } + +} + +func foobar() { + var err error var allTests = map[string]*TestStatus{} // read from stdin and parse "go test" results stdin := os.Stdin + stat, err := os.Stdin.Stat() + if err != nil { + panic(err) + } + if (stat.Mode() & os.ModeCharDevice) == 0 { + fmt.Println("data is being piped to stdin") + } else { + fmt.Println("show help") + os.Exit(0) + } + defer func() { - if err := stdin.Close(); err != nil { + if err = stdin.Close(); err != nil { panic(err) } }() stdinScanner := bufio.NewScanner(stdin) + for stdinScanner.Scan() { stdinScanner.Text() lineInput := stdinScanner.Bytes() @@ -102,7 +164,7 @@ func main() { panic(err) } - templateData := TemplateData{ + tmplData := TemplateData{ ReportTitle: "go-test-report", TestResultGroupIndicatorWidth: "24px", TestResultGroupIndicatorHeight: "24px", @@ -117,15 +179,15 @@ func main() { tgId := 0 for _, status := range allTests { - if len(templateData.TestResults) == tgId { - templateData.TestResults = append(templateData.TestResults, &TestGroupData{}) + if len(tmplData.TestResults) == tgId { + tmplData.TestResults = append(tmplData.TestResults, &TestGroupData{}) } - templateData.TestResults[tgId].TestResults = append(templateData.TestResults[tgId].TestResults, status) + tmplData.TestResults[tgId].TestResults = append(tmplData.TestResults[tgId].TestResults, status) if !status.Passed { - templateData.TestResults[tgId].FailureIndicator = "failed" - templateData.NumOfTestFailed += 1 + tmplData.TestResults[tgId].FailureIndicator = "failed" + tmplData.NumOfTestFailed += 1 } else { - templateData.NumOfTestPassed += 1 + tmplData.NumOfTestPassed += 1 } tgCounter += 1 if tgCounter == numOfTestsPerGroup { @@ -133,7 +195,7 @@ func main() { tgId += 1 } } - templateData.NumOfTests = templateData.NumOfTestPassed + templateData.NumOfTestFailed - err = tpl.Execute(w, templateData) + tmplData.NumOfTests = tmplData.NumOfTestPassed + tmplData.NumOfTestFailed + err = tpl.Execute(w, tmplData) } } From 983d71130e6a58f3f097c40db2efac3de58127df Mon Sep 17 00:00:00 2001 From: Samuel A Date: Fri, 19 Jun 2020 00:17:28 -0400 Subject: [PATCH 02/96] adds error message for missing pipe --- main.go | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index 3a1687b..cb46811 100644 --- a/main.go +++ b/main.go @@ -50,24 +50,25 @@ type cmdFlags struct { } func main() { + stdin := os.Stdin flags := cmdFlags{} - + versionCmd := &cobra.Command{ + Use: "version", + Short: "Prints the version number of go-test-report", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(fmt.Sprintf("go-test-report v%s", "0.9")) + }, + } rootCmd := &cobra.Command{ Use: "go-test-report", - Long: "Captures go test output and parses it into a single self-contained html file.", + Long: "Captures go test output via stdin and parses it into a single self-contained html file.", Run: func(cmd *cobra.Command, args []string) { // start timer // -- do stuff + foobar(stdin) // end timer }, } - versionCmd := &cobra.Command{ - Use: "version", - Short: "Prints the version number of go-test-report", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(fmt.Sprintf("go-test-report v%s", "0.9")) - }, - } rootCmd.AddCommand(versionCmd) rootCmd.PersistentFlags().StringVar(&flags.titleFlag, "title", @@ -82,31 +83,33 @@ func main() { 0, "the number of tests per test group") - //TestResultGroupIndicatorWidth + stat, err := os.Stdin.Stat() + if err != nil { + panic(err) + } + if (stat.Mode() & os.ModeCharDevice) == 0 { + fmt.Println("data is being piped to stdin") + } else { + if err := rootCmd.Help(); err != nil { + panic(err) + } + fmt.Println("ERROR: missing ≪ stdin ≫ pipe") + os.Exit(1) + } + if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } - } -func foobar() { +func foobar(stdin *os.File) { var err error var allTests = map[string]*TestStatus{} // read from stdin and parse "go test" results - stdin := os.Stdin - stat, err := os.Stdin.Stat() - if err != nil { - panic(err) - } - if (stat.Mode() & os.ModeCharDevice) == 0 { - fmt.Println("data is being piped to stdin") - } else { - fmt.Println("show help") - os.Exit(0) - } + defer func() { if err = stdin.Close(); err != nil { From c91d60d486448694ad81d5d62168c8f57663f78e Mon Sep 17 00:00:00 2001 From: Samuel A Date: Fri, 19 Jun 2020 22:20:43 -0400 Subject: [PATCH 03/96] Adds unit test for the go side of the code --- go.mod | 3 + go.sum | 11 +++ main.go | 193 +++++++++++++++++++++++++++------------------------ main_test.go | 61 ++++++++++++++++ 4 files changed, 179 insertions(+), 89 deletions(-) create mode 100644 main_test.go diff --git a/go.mod b/go.mod index 9ad266d..5436164 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,9 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.7.0 // indirect + github.com/stretchr/objx v0.2.0 // indirect + github.com/stretchr/testify v1.6.1 golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect gopkg.in/ini.v1 v1.57.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) diff --git a/go.sum b/go.sum index c825573..058c35b 100644 --- a/go.sum +++ b/go.sum @@ -35,6 +35,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= @@ -141,6 +142,7 @@ github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMF github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -186,9 +188,14 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -327,6 +334,10 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/main.go b/main.go index cb46811..57a1672 100644 --- a/main.go +++ b/main.go @@ -10,99 +10,52 @@ import ( "os" ) -type goTestOutputRow struct { - Time string - TestName string `json:"Test"` - Action string - Package string - Elapsed float64 - Output string -} - -type TestStatus struct { - TestName string - Package string - ElapsedTime float64 - Output []string - Passed bool -} - -type TemplateData struct { - TestResultGroupIndicatorWidth string - TestResultGroupIndicatorHeight string - TestResults []*TestGroupData - NumOfTestPassed int - NumOfTestFailed int - NumOfTests int - ReportTitle string - JsCode template.JS -} - -type TestGroupData struct { - FailureIndicator string - TestResults []*TestStatus -} - -type cmdFlags struct { - titleFlag string - sizeFlag string - groupSize int8 -} - -func main() { - stdin := os.Stdin - flags := cmdFlags{} - versionCmd := &cobra.Command{ - Use: "version", - Short: "Prints the version number of go-test-report", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(fmt.Sprintf("go-test-report v%s", "0.9")) - }, - } - rootCmd := &cobra.Command{ - Use: "go-test-report", - Long: "Captures go test output via stdin and parses it into a single self-contained html file.", - Run: func(cmd *cobra.Command, args []string) { - // start timer - // -- do stuff - foobar(stdin) - // end timer - }, +type ( + goTestOutputRow struct { + Time string + TestName string `json:"Test"` + Action string + Package string + Elapsed float64 + Output string } - rootCmd.AddCommand(versionCmd) - rootCmd.PersistentFlags().StringVar(&flags.titleFlag, - "title", - "go-test-report", - "the title text shown in the test report") - rootCmd.PersistentFlags().StringVar(&flags.sizeFlag, - "size", - "24", - "the size of the clickable indicator for test result groups") - rootCmd.PersistentFlags().Int8Var(&flags.groupSize, - "groupSize", - 0, - "the number of tests per test group") - stat, err := os.Stdin.Stat() - if err != nil { - panic(err) + TestStatus struct { + TestName string + Package string + ElapsedTime float64 + Output []string + Passed bool } - if (stat.Mode() & os.ModeCharDevice) == 0 { - fmt.Println("data is being piped to stdin") - } else { - if err := rootCmd.Help(); err != nil { - panic(err) - } - fmt.Println("ERROR: missing ≪ stdin ≫ pipe") - os.Exit(1) + + TemplateData struct { + TestResultGroupIndicatorWidth string + TestResultGroupIndicatorHeight string + TestResults []*TestGroupData + NumOfTestPassed int + NumOfTestFailed int + NumOfTests int + ReportTitle string + JsCode template.JS } + TestGroupData struct { + FailureIndicator string + TestResults []*TestStatus + } - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) + cmdFlags struct { + titleFlag string + sizeFlag string + groupSize int8 + outputFlag string } -} +) + +var ( + stdin = os.Stdin + version = "0.9" +) func foobar(stdin *os.File) { var err error @@ -110,14 +63,12 @@ func foobar(stdin *os.File) { // read from stdin and parse "go test" results - defer func() { if err = stdin.Close(); err != nil { panic(err) } }() stdinScanner := bufio.NewScanner(stdin) - for stdinScanner.Scan() { stdinScanner.Text() lineInput := stdinScanner.Bytes() @@ -146,7 +97,6 @@ func foobar(stdin *os.File) { testStatus.Output = append(testStatus.Output, goTestOutputRow.Output) } } - if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { panic(err) } else { @@ -202,3 +152,68 @@ func foobar(stdin *os.File) { err = tpl.Execute(w, tmplData) } } + +func newRootCommand() (*cobra.Command, *cmdFlags) { + flags := &cmdFlags{} + rootCmd := &cobra.Command{ + Use: "go-test-report", + Long: "Captures go test output via stdin and parses it into a single self-contained html file.", + Run: func(cmd *cobra.Command, args []string) { + // start timer + // -- do stuff + foobar(stdin) + // end timer + }, + } + versionCmd := &cobra.Command{ + Use: "version", + Short: "Prints the version number of go-test-report", + Run: func(cmd *cobra.Command, args []string) { + msg := fmt.Sprintf("go-test-report v%s", version) + if _, err := fmt.Fprintln(cmd.OutOrStdout(), msg); err != nil { + panic(err) + } + }, + } + rootCmd.AddCommand(versionCmd) + rootCmd.PersistentFlags().StringVar(&flags.titleFlag, + "title", + "go-test-report", + "the title text shown in the test report") + rootCmd.PersistentFlags().StringVar(&flags.sizeFlag, + "size", + "24", + "the size of the clickable indicator for test result groups") + rootCmd.PersistentFlags().Int8Var(&flags.groupSize, + "groupSize", + 0, + "the number of tests per test group") + rootCmd.PersistentFlags().StringVarP(&flags.outputFlag, + "output", + "o", + "test_report.html", + "the HTML output file") + + return rootCmd, flags +} + +func main() { + rootCmd, _ := newRootCommand() + stat, err := os.Stdin.Stat() + if err != nil { + panic(err) + } + if (stat.Mode() & os.ModeCharDevice) == 0 { + fmt.Println("data is being piped to stdin") + } else { + if err := rootCmd.Help(); err != nil { + panic(err) + } + fmt.Println("ERROR: missing ≪ stdin ≫ pipe") + os.Exit(1) + } + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..49affd3 --- /dev/null +++ b/main_test.go @@ -0,0 +1,61 @@ +package main + +import ( + "bytes" + "fmt" + "github.com/stretchr/testify/assert" + "io/ioutil" + "testing" +) + +func TestVersionCommand(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"version"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal(fmt.Sprintf("go-test-report v%s\n", version), string(output)) +} + +func TestVersionHelp(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, flags := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--title", "Sample Test Report"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("Sample Test Report", flags.titleFlag) + assertions.Empty(output) +} + +/* +func Foobar(t *testing.T) { + assertions := assert.New(t) + b := bytes.NewBufferString("") + rootCmd.SetOut(b) + rootCmd.SetArgs([]string{"--title", "foobar"}) + assertions.Nil(rootCmd.Execute()) + + foo, err := ioutil.ReadAll(b) + assertions.Nil(err) + fmt.Println(err) + + //fmt.Println(output) + //fmt.Println(string(output)) + + fmt.Println(string(foo)) + fmt.Println(flags) + + //fmt.Println(output.Flush()) + //fmt.Println(foobar.Size()) + //fmt.Println(foobar.Flush()) + assertions.True(true) +} +*/ \ No newline at end of file From 1abcbb08fb885d71984eb5c65144a00fdb07f48e Mon Sep 17 00:00:00 2001 From: Samuel A Date: Fri, 19 Jun 2020 23:31:58 -0400 Subject: [PATCH 04/96] adds go test in dockerfile --- Dockerfile | 1 + main_test.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index baf5ef4..b6cb2a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,3 +15,4 @@ ADD . . RUN npm install RUN npm fund RUN npm run test +RUN go test -v diff --git a/main_test.go b/main_test.go index 49affd3..065015e 100644 --- a/main_test.go +++ b/main_test.go @@ -21,7 +21,7 @@ func TestVersionCommand(t *testing.T) { assertions.Equal(fmt.Sprintf("go-test-report v%s\n", version), string(output)) } -func TestVersionHelp(t *testing.T) { +func TestTitleFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") rootCmd, flags := newRootCommand() @@ -35,6 +35,17 @@ func TestVersionHelp(t *testing.T) { assertions.Empty(output) } +func TestTitleFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--title"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) +} + /* func Foobar(t *testing.T) { assertions := assert.New(t) From 2964a55151e87d9886c62c34d70305e0276ab043 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Fri, 19 Jun 2020 23:32:26 -0400 Subject: [PATCH 05/96] some code refactoring and adds more test --- main.go | 60 ++++++++++++++++++++++++++++++++++++++---------- main_test.go | 64 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 89 insertions(+), 35 deletions(-) diff --git a/main.go b/main.go index 57a1672..243d01f 100644 --- a/main.go +++ b/main.go @@ -3,13 +3,18 @@ package main import ( "bufio" "encoding/json" + "errors" "fmt" "github.com/spf13/cobra" "html/template" "io/ioutil" "os" + "strconv" + "strings" ) +var version = "0.9" + type ( goTestOutputRow struct { Time string @@ -52,11 +57,6 @@ type ( } ) -var ( - stdin = os.Stdin - version = "0.9" -) - func foobar(stdin *os.File) { var err error var allTests = map[string]*TestStatus{} @@ -153,26 +153,62 @@ func foobar(stdin *os.File) { } } -func newRootCommand() (*cobra.Command, *cmdFlags) { +func parseSizeFlag(tmplData *TemplateData, flags *cmdFlags) error { + flags.sizeFlag = strings.ToLower(flags.sizeFlag) + if !strings.Contains(flags.sizeFlag, "x") { + if val, err := strconv.Atoi(flags.sizeFlag); err != nil { + return err + } else { + tmplData.TestResultGroupIndicatorWidth = fmt.Sprintf("%dpx", val) + tmplData.TestResultGroupIndicatorHeight = fmt.Sprintf("%dpx", val) + return nil + } + } + if strings.Count(flags.sizeFlag, "x") > 1 { + return errors.New(`malformed size value; only one x is allowed if specifying with and height`) + } else { + a := strings.Split(flags.sizeFlag, "x") + if val, err := strconv.Atoi(a[0]); err != nil { + return err + } else { + tmplData.TestResultGroupIndicatorWidth = fmt.Sprintf("%dpx", val) + + } + if val, err := strconv.Atoi(a[1]); err != nil { + return err + } else { + tmplData.TestResultGroupIndicatorHeight = fmt.Sprintf("%dpx", val) + } + return nil + } +} + +func newRootCommand() (*cobra.Command, *cmdFlags, *TemplateData) { flags := &cmdFlags{} + tmplData := &TemplateData{} rootCmd := &cobra.Command{ Use: "go-test-report", Long: "Captures go test output via stdin and parses it into a single self-contained html file.", - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { // start timer // -- do stuff - foobar(stdin) + if err := parseSizeFlag(tmplData, flags); err != nil { + return err + } + //foobar(stdin) // end timer + return nil }, } versionCmd := &cobra.Command{ Use: "version", Short: "Prints the version number of go-test-report", - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { msg := fmt.Sprintf("go-test-report v%s", version) if _, err := fmt.Fprintln(cmd.OutOrStdout(), msg); err != nil { - panic(err) + return err } + return nil }, } rootCmd.AddCommand(versionCmd) @@ -194,11 +230,11 @@ func newRootCommand() (*cobra.Command, *cmdFlags) { "test_report.html", "the HTML output file") - return rootCmd, flags + return rootCmd, flags, tmplData } func main() { - rootCmd, _ := newRootCommand() + rootCmd, _, _ := newRootCommand() stat, err := os.Stdin.Stat() if err != nil { panic(err) diff --git a/main_test.go b/main_test.go index 065015e..9f74e49 100644 --- a/main_test.go +++ b/main_test.go @@ -11,7 +11,7 @@ import ( func TestVersionCommand(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _ := newRootCommand() + rootCmd, _, _ := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"version"}) rootCmdErr := rootCmd.Execute() @@ -24,7 +24,7 @@ func TestVersionCommand(t *testing.T) { func TestTitleFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, flags := newRootCommand() + rootCmd, flags, _ := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--title", "Sample Test Report"}) rootCmdErr := rootCmd.Execute() @@ -38,7 +38,7 @@ func TestTitleFlag(t *testing.T) { func TestTitleFlagIfMissingValue(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _ := newRootCommand() + rootCmd, _, _ := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--title"}) rootCmdErr := rootCmd.Execute() @@ -46,27 +46,45 @@ func TestTitleFlagIfMissingValue(t *testing.T) { assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) } -/* -func Foobar(t *testing.T) { +func TestSizeFlag(t *testing.T) { assertions := assert.New(t) - b := bytes.NewBufferString("") - rootCmd.SetOut(b) - rootCmd.SetArgs([]string{"--title", "foobar"}) - assertions.Nil(rootCmd.Execute()) - - foo, err := ioutil.ReadAll(b) - assertions.Nil(err) - fmt.Println(err) - - //fmt.Println(output) - //fmt.Println(string(output)) + buffer := bytes.NewBufferString("") + rootCmd, flags, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--size", "24"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("24", flags.sizeFlag) + assertions.Empty(output) +} - fmt.Println(string(foo)) - fmt.Println(flags) +func TestSizeFlagWithFullDimensions(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, flags, tmplData := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--size", "24x16"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("24x16", flags.sizeFlag) + assertions.Equal("24px", tmplData.TestResultGroupIndicatorWidth) + assertions.Equal("16px", tmplData.TestResultGroupIndicatorHeight) + assertions.Empty(output) +} - //fmt.Println(output.Flush()) - //fmt.Println(foobar.Size()) - //fmt.Println(foobar.Flush()) - assertions.True(true) +/* +func TestSizeFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--title"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) } -*/ \ No newline at end of file +*/ From db122243f7ea58932070b9133085adb2c8d37f24 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Fri, 19 Jun 2020 23:51:19 -0400 Subject: [PATCH 06/96] adds support for running go test in the CI docker file. --- Dockerfile | 6 +++++- main_test.go | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index b6cb2a0..76199a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ -FROM alpine +#FROM alpine +FROM golang:1.14-alpine + +# installs GCC, libc-dev, etc +RUN apk add build-base # makes working with alpine-linux a little easier RUN apk add --no-cache shadow diff --git a/main_test.go b/main_test.go index 9f74e49..2180350 100644 --- a/main_test.go +++ b/main_test.go @@ -76,15 +76,13 @@ func TestSizeFlagWithFullDimensions(t *testing.T) { assertions.Empty(output) } -/* func TestSizeFlagIfMissingValue(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _ := newRootCommand() + rootCmd, _, _ := newRootCommand() rootCmd.SetOut(buffer) - rootCmd.SetArgs([]string{"--title"}) + rootCmd.SetArgs([]string{"--size"}) rootCmdErr := rootCmd.Execute() assertions.NotNil(rootCmdErr) - assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --size`) } -*/ From d4720102219cc944b60d8576aed66d998ddeef38 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 00:00:39 -0400 Subject: [PATCH 07/96] adds a default to the groupSize flag --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 243d01f..ed59f04 100644 --- a/main.go +++ b/main.go @@ -52,7 +52,7 @@ type ( cmdFlags struct { titleFlag string sizeFlag string - groupSize int8 + groupSize int outputFlag string } ) @@ -220,10 +220,10 @@ func newRootCommand() (*cobra.Command, *cmdFlags, *TemplateData) { "size", "24", "the size of the clickable indicator for test result groups") - rootCmd.PersistentFlags().Int8Var(&flags.groupSize, + rootCmd.PersistentFlags().IntVar(&flags.groupSize, "groupSize", - 0, - "the number of tests per test group") + 10, + "the number of tests per test group indicator") rootCmd.PersistentFlags().StringVarP(&flags.outputFlag, "output", "o", From 72e4c9d8a9ff6b5f6e77607367ccf02f1b9f5517 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 01:51:13 -0400 Subject: [PATCH 08/96] adds test for groupSize --- main.go | 35 +++++++++++++++++++++-------------- main_test.go | 31 ++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/main.go b/main.go index ed59f04..c80bd37 100644 --- a/main.go +++ b/main.go @@ -183,7 +183,23 @@ func parseSizeFlag(tmplData *TemplateData, flags *cmdFlags) error { } } -func newRootCommand() (*cobra.Command, *cmdFlags, *TemplateData) { +func checkIfStdinIsPiped(rootCmd *cobra.Command) error { + stat, err := os.Stdin.Stat() + if err != nil { + return err + } + if (stat.Mode() & os.ModeCharDevice) == 0 { + fmt.Println("data is being piped to stdin") + } else { + if err := rootCmd.Help(); err != nil { + return err + } + return errors.New("ERROR: missing ≪ stdin ≫ pipe") + } + return nil +} + +func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { flags := &cmdFlags{} tmplData := &TemplateData{} rootCmd := &cobra.Command{ @@ -230,26 +246,17 @@ func newRootCommand() (*cobra.Command, *cmdFlags, *TemplateData) { "test_report.html", "the HTML output file") - return rootCmd, flags, tmplData + return rootCmd, tmplData, flags } func main() { rootCmd, _, _ := newRootCommand() - stat, err := os.Stdin.Stat() - if err != nil { - panic(err) - } - if (stat.Mode() & os.ModeCharDevice) == 0 { - fmt.Println("data is being piped to stdin") - } else { - if err := rootCmd.Help(); err != nil { - panic(err) - } - fmt.Println("ERROR: missing ≪ stdin ≫ pipe") + if err := checkIfStdinIsPiped(rootCmd); err != nil { + fmt.Println(err.Error()) os.Exit(1) } if err := rootCmd.Execute(); err != nil { - fmt.Println(err) + fmt.Println(err.Error()) os.Exit(1) } } diff --git a/main_test.go b/main_test.go index 2180350..5c7dcb2 100644 --- a/main_test.go +++ b/main_test.go @@ -24,7 +24,7 @@ func TestVersionCommand(t *testing.T) { func TestTitleFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, flags, _ := newRootCommand() + rootCmd, _, flags := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--title", "Sample Test Report"}) rootCmdErr := rootCmd.Execute() @@ -49,7 +49,7 @@ func TestTitleFlagIfMissingValue(t *testing.T) { func TestSizeFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, flags, _ := newRootCommand() + rootCmd, _, flags := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--size", "24"}) rootCmdErr := rootCmd.Execute() @@ -63,7 +63,7 @@ func TestSizeFlag(t *testing.T) { func TestSizeFlagWithFullDimensions(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, flags, tmplData := newRootCommand() + rootCmd, tmplData, flags := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--size", "24x16"}) rootCmdErr := rootCmd.Execute() @@ -86,3 +86,28 @@ func TestSizeFlagIfMissingValue(t *testing.T) { assertions.NotNil(rootCmdErr) assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --size`) } + +func TestGroupSizeFlag(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _, flags := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--groupSize", "32"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal(32, flags.groupSize) + assertions.Empty(output) +} + +func TestGroupSizeFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--groupSize"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --groupSize`) +} From 67ea39b702a5cc24c569b77b754c91608d2ceaa0 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 01:57:18 -0400 Subject: [PATCH 09/96] some minor test updates --- main.go | 6 ++++-- main_test.go | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index c80bd37..c161f5d 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ type ( NumOfTests int ReportTitle string JsCode template.JS + numOfTestsPerGroup int } TestGroupData struct { @@ -126,8 +127,8 @@ func foobar(stdin *os.File) { TestResults: []*TestGroupData{}, NumOfTests: 0, JsCode: template.JS(jsCode), + numOfTestsPerGroup: 20, } - numOfTestsPerGroup := 20 tgCounter := 0 tgId := 0 @@ -143,7 +144,7 @@ func foobar(stdin *os.File) { tmplData.NumOfTestPassed += 1 } tgCounter += 1 - if tgCounter == numOfTestsPerGroup { + if tgCounter == tmplData.numOfTestsPerGroup { tgCounter = 0 tgId += 1 } @@ -211,6 +212,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { if err := parseSizeFlag(tmplData, flags); err != nil { return err } + tmplData.numOfTestsPerGroup = flags.groupSize //foobar(stdin) // end timer return nil diff --git a/main_test.go b/main_test.go index 5c7dcb2..c3eccb3 100644 --- a/main_test.go +++ b/main_test.go @@ -49,7 +49,7 @@ func TestTitleFlagIfMissingValue(t *testing.T) { func TestSizeFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _, flags := newRootCommand() + rootCmd, tmplData, flags := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--size", "24"}) rootCmdErr := rootCmd.Execute() @@ -57,6 +57,8 @@ func TestSizeFlag(t *testing.T) { output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("24", flags.sizeFlag) + assertions.Equal("24px", tmplData.TestResultGroupIndicatorWidth) + assertions.Equal("24px", tmplData.TestResultGroupIndicatorHeight) assertions.Empty(output) } @@ -90,14 +92,14 @@ func TestSizeFlagIfMissingValue(t *testing.T) { func TestGroupSizeFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _, flags := newRootCommand() + rootCmd, tmplData, _ := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--groupSize", "32"}) rootCmdErr := rootCmd.Execute() assertions.Nil(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) - assertions.Equal(32, flags.groupSize) + assertions.Equal(32, tmplData.numOfTestsPerGroup) assertions.Empty(output) } From 9b42ab98c9e08f5897082dff9c781e8bb2c2d4cc Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 02:14:22 -0400 Subject: [PATCH 10/96] more refactorings and updated test --- main.go | 33 ++++++++++++++++++++------------- main_test.go | 4 ++-- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index c161f5d..acbd0a6 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ type ( ReportTitle string JsCode template.JS numOfTestsPerGroup int + OutputFilename string } TestGroupData struct { @@ -58,7 +59,7 @@ type ( } ) -func foobar(stdin *os.File) { +func foobar(stdin *os.File, tmplData *TemplateData) { var err error var allTests = map[string]*TestStatus{} @@ -118,17 +119,20 @@ func foobar(stdin *os.File) { panic(err) } - tmplData := TemplateData{ - ReportTitle: "go-test-report", - TestResultGroupIndicatorWidth: "24px", - TestResultGroupIndicatorHeight: "24px", - NumOfTestPassed: 0, - NumOfTestFailed: 0, - TestResults: []*TestGroupData{}, - NumOfTests: 0, - JsCode: template.JS(jsCode), - numOfTestsPerGroup: 20, - } + //tmplData := TemplateData{ + // ReportTitle: "go-test-report", + // TestResultGroupIndicatorWidth: "24px", + // TestResultGroupIndicatorHeight: "24px", + // NumOfTestPassed: 0, + // NumOfTestFailed: 0, + // TestResults: []*TestGroupData{}, + // NumOfTests: 0, + // JsCode: template.JS(jsCode), + // numOfTestsPerGroup: 20, + //} + tmplData.NumOfTestPassed = 0 + tmplData.NumOfTestFailed = 0 + tmplData.JsCode = template.JS(jsCode) tgCounter := 0 tgId := 0 @@ -202,7 +206,9 @@ func checkIfStdinIsPiped(rootCmd *cobra.Command) error { func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { flags := &cmdFlags{} - tmplData := &TemplateData{} + tmplData := &TemplateData{ + OutputFilename: "test_report.html", + } rootCmd := &cobra.Command{ Use: "go-test-report", Long: "Captures go test output via stdin and parses it into a single self-contained html file.", @@ -213,6 +219,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { return err } tmplData.numOfTestsPerGroup = flags.groupSize + tmplData.ReportTitle = flags.titleFlag //foobar(stdin) // end timer return nil diff --git a/main_test.go b/main_test.go index c3eccb3..e2450d7 100644 --- a/main_test.go +++ b/main_test.go @@ -24,14 +24,14 @@ func TestVersionCommand(t *testing.T) { func TestTitleFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") - rootCmd, _, flags := newRootCommand() + rootCmd, tmplData, _ := newRootCommand() rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--title", "Sample Test Report"}) rootCmdErr := rootCmd.Execute() assertions.Nil(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) - assertions.Equal("Sample Test Report", flags.titleFlag) + assertions.Equal("Sample Test Report", tmplData.ReportTitle) assertions.Empty(output) } From 029b0fcc676393088a844b8b34fd6256d499e736 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 23:54:29 -0400 Subject: [PATCH 11/96] updated tests and added more tests --- main.go | 7 +++---- main_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index acbd0a6..7ebcc67 100644 --- a/main.go +++ b/main.go @@ -102,7 +102,7 @@ func foobar(stdin *os.File, tmplData *TemplateData) { if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { panic(err) } else { - testReportHTMLTemplateFile, _ := os.Create("test_report.html") + testReportHTMLTemplateFile, _ := os.Create(tmplData.OutputFilename) w := bufio.NewWriter(testReportHTMLTemplateFile) defer func() { if err := w.Flush(); err != nil { @@ -206,9 +206,7 @@ func checkIfStdinIsPiped(rootCmd *cobra.Command) error { func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { flags := &cmdFlags{} - tmplData := &TemplateData{ - OutputFilename: "test_report.html", - } + tmplData := &TemplateData{} rootCmd := &cobra.Command{ Use: "go-test-report", Long: "Captures go test output via stdin and parses it into a single self-contained html file.", @@ -220,6 +218,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { } tmplData.numOfTestsPerGroup = flags.groupSize tmplData.ReportTitle = flags.titleFlag + tmplData.OutputFilename = flags.outputFlag //foobar(stdin) // end timer return nil diff --git a/main_test.go b/main_test.go index e2450d7..74ea091 100644 --- a/main_test.go +++ b/main_test.go @@ -113,3 +113,53 @@ func TestGroupSizeFlagIfMissingValue(t *testing.T) { assertions.NotNil(rootCmdErr) assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --groupSize`) } + +func TestGroupOutputFlag(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, tmplData, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--output", "test_file.html"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("test_file.html", tmplData.OutputFilename) + assertions.Empty(output) +} + +func TestGroupOutputShorthandFlag(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, tmplData, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"-o", "test_file_shorthand.html"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("test_file_shorthand.html", tmplData.OutputFilename) + assertions.Empty(output) +} + +func TestGroupOutputFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"--output"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --output`) +} + +func TestGroupOutputShorthandFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"-o"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: 'o' in -o`) +} From 6bda24842257b1e900c2c65f103fe0976c921efd Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sat, 20 Jun 2020 23:59:25 -0400 Subject: [PATCH 12/96] adds shorthand flag for the title flag --- main.go | 3 ++- main_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7ebcc67..b9fe3c0 100644 --- a/main.go +++ b/main.go @@ -236,8 +236,9 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { }, } rootCmd.AddCommand(versionCmd) - rootCmd.PersistentFlags().StringVar(&flags.titleFlag, + rootCmd.PersistentFlags().StringVarP(&flags.titleFlag, "title", + "t", "go-test-report", "the title text shown in the test report") rootCmd.PersistentFlags().StringVar(&flags.sizeFlag, diff --git a/main_test.go b/main_test.go index 74ea091..881f089 100644 --- a/main_test.go +++ b/main_test.go @@ -35,6 +35,20 @@ func TestTitleFlag(t *testing.T) { assertions.Empty(output) } +func TestTitleShorthandFlag(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, tmplData, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"-t", "Sample Test Report 2"}) + rootCmdErr := rootCmd.Execute() + assertions.Nil(rootCmdErr) + output, readErr := ioutil.ReadAll(buffer) + assertions.Nil(readErr) + assertions.Equal("Sample Test Report 2", tmplData.ReportTitle) + assertions.Empty(output) +} + func TestTitleFlagIfMissingValue(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") @@ -46,6 +60,17 @@ func TestTitleFlagIfMissingValue(t *testing.T) { assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) } +func TestTitleShorthandFlagIfMissingValue(t *testing.T) { + assertions := assert.New(t) + buffer := bytes.NewBufferString("") + rootCmd, _, _ := newRootCommand() + rootCmd.SetOut(buffer) + rootCmd.SetArgs([]string{"-t"}) + rootCmdErr := rootCmd.Execute() + assertions.NotNil(rootCmdErr) + assertions.Equal(rootCmdErr.Error(), `flag needs an argument: 't' in -t`) +} + func TestSizeFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") From 4e3da711ccba9dd5e59b923b6969e0507742829c Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sun, 21 Jun 2020 00:06:24 -0400 Subject: [PATCH 13/96] removed shortand tests --- main.go | 3 ++- main_test.go | 50 -------------------------------------------------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/main.go b/main.go index b9fe3c0..0423644 100644 --- a/main.go +++ b/main.go @@ -241,8 +241,9 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { "t", "go-test-report", "the title text shown in the test report") - rootCmd.PersistentFlags().StringVar(&flags.sizeFlag, + rootCmd.PersistentFlags().StringVarP(&flags.sizeFlag, "size", + "s", "24", "the size of the clickable indicator for test result groups") rootCmd.PersistentFlags().IntVar(&flags.groupSize, diff --git a/main_test.go b/main_test.go index 881f089..9763b9f 100644 --- a/main_test.go +++ b/main_test.go @@ -35,20 +35,6 @@ func TestTitleFlag(t *testing.T) { assertions.Empty(output) } -func TestTitleShorthandFlag(t *testing.T) { - assertions := assert.New(t) - buffer := bytes.NewBufferString("") - rootCmd, tmplData, _ := newRootCommand() - rootCmd.SetOut(buffer) - rootCmd.SetArgs([]string{"-t", "Sample Test Report 2"}) - rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) - output, readErr := ioutil.ReadAll(buffer) - assertions.Nil(readErr) - assertions.Equal("Sample Test Report 2", tmplData.ReportTitle) - assertions.Empty(output) -} - func TestTitleFlagIfMissingValue(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") @@ -60,17 +46,6 @@ func TestTitleFlagIfMissingValue(t *testing.T) { assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --title`) } -func TestTitleShorthandFlagIfMissingValue(t *testing.T) { - assertions := assert.New(t) - buffer := bytes.NewBufferString("") - rootCmd, _, _ := newRootCommand() - rootCmd.SetOut(buffer) - rootCmd.SetArgs([]string{"-t"}) - rootCmdErr := rootCmd.Execute() - assertions.NotNil(rootCmdErr) - assertions.Equal(rootCmdErr.Error(), `flag needs an argument: 't' in -t`) -} - func TestSizeFlag(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") @@ -153,20 +128,6 @@ func TestGroupOutputFlag(t *testing.T) { assertions.Empty(output) } -func TestGroupOutputShorthandFlag(t *testing.T) { - assertions := assert.New(t) - buffer := bytes.NewBufferString("") - rootCmd, tmplData, _ := newRootCommand() - rootCmd.SetOut(buffer) - rootCmd.SetArgs([]string{"-o", "test_file_shorthand.html"}) - rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) - output, readErr := ioutil.ReadAll(buffer) - assertions.Nil(readErr) - assertions.Equal("test_file_shorthand.html", tmplData.OutputFilename) - assertions.Empty(output) -} - func TestGroupOutputFlagIfMissingValue(t *testing.T) { assertions := assert.New(t) buffer := bytes.NewBufferString("") @@ -177,14 +138,3 @@ func TestGroupOutputFlagIfMissingValue(t *testing.T) { assertions.NotNil(rootCmdErr) assertions.Equal(rootCmdErr.Error(), `flag needs an argument: --output`) } - -func TestGroupOutputShorthandFlagIfMissingValue(t *testing.T) { - assertions := assert.New(t) - buffer := bytes.NewBufferString("") - rootCmd, _, _ := newRootCommand() - rootCmd.SetOut(buffer) - rootCmd.SetArgs([]string{"-o"}) - rootCmdErr := rootCmd.Execute() - assertions.NotNil(rootCmdErr) - assertions.Equal(rootCmdErr.Error(), `flag needs an argument: 'o' in -o`) -} From 952431b5be42ef7de5641a5ee4d95da3486847c5 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sun, 21 Jun 2020 00:32:05 -0400 Subject: [PATCH 14/96] moved the stdin checker into the main processing block --- main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 0423644..016f8fd 100644 --- a/main.go +++ b/main.go @@ -59,7 +59,12 @@ type ( } ) -func foobar(stdin *os.File, tmplData *TemplateData) { +func foobar(stdin *os.File, tmplData *TemplateData, cmd *cobra.Command) { + if err := checkIfStdinIsPiped(cmd); err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } + var err error var allTests = map[string]*TestStatus{} @@ -261,10 +266,6 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { func main() { rootCmd, _, _ := newRootCommand() - if err := checkIfStdinIsPiped(rootCmd); err != nil { - fmt.Println(err.Error()) - os.Exit(1) - } if err := rootCmd.Execute(); err != nil { fmt.Println(err.Error()) os.Exit(1) From ab892c7d3a424a73d49a6532398d6ebd35b86332 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sun, 21 Jun 2020 11:53:54 -0400 Subject: [PATCH 15/96] updates to documentation and test --- docs/README.md | 20 +++++++++++++++++++- main.go | 20 +++++++++++++------- main_test.go | 10 +++++----- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/docs/README.md b/docs/README.md index 858c2f1..6a7f7b3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,7 +18,7 @@ $ brew install go-test-report To use go-test-report with the default settings. ```shell script -$ go test -json | go-test-report +$ go test -v -json | go-test-report ``` The aforementioned command, outputs an HTML file in the same location. @@ -33,5 +33,23 @@ go-test-report.html Additional configuration options are available via command line flags. ``` +Captures go test output via stdin and parses it into a single self-contained html file. + +Usage: + go-test-report [flags] + go-test-report [command] + +Available Commands: + help Help about any command + version Prints the version number of go-test-report + +Flags: + --groupSize int the number of tests per test group indicator (default 10) + -h, --help help for go-test-report + -o, --output string the HTML output file (default "test_report.html") + -s, --size string the size of the clickable indicator for test result groups (default "24") + -t, --title string the title text shown in the test report (default "go-test-report") + +Use "go-test-report [command] --help" for more information about a command. ``` \ No newline at end of file diff --git a/main.go b/main.go index 016f8fd..bb7d344 100644 --- a/main.go +++ b/main.go @@ -59,10 +59,12 @@ type ( } ) -func foobar(stdin *os.File, tmplData *TemplateData, cmd *cobra.Command) { +func foobar(tmplData *TemplateData, cmd *cobra.Command) error { + stdin := os.Stdin if err := checkIfStdinIsPiped(cmd); err != nil { - fmt.Println(err.Error()) - os.Exit(1) + //fmt.Println(err.Error()) + //os.Exit(1) + return err } var err error @@ -105,7 +107,7 @@ func foobar(stdin *os.File, tmplData *TemplateData, cmd *cobra.Command) { } } if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { - panic(err) + return err } else { testReportHTMLTemplateFile, _ := os.Create(tmplData.OutputFilename) w := bufio.NewWriter(testReportHTMLTemplateFile) @@ -121,7 +123,7 @@ func foobar(stdin *os.File, tmplData *TemplateData, cmd *cobra.Command) { // read Javascript test code jsCode, err := ioutil.ReadFile("test_report.js") if err != nil { - panic(err) + return err } //tmplData := TemplateData{ @@ -161,6 +163,7 @@ func foobar(stdin *os.File, tmplData *TemplateData, cmd *cobra.Command) { tmplData.NumOfTests = tmplData.NumOfTestPassed + tmplData.NumOfTestFailed err = tpl.Execute(w, tmplData) } + return nil } func parseSizeFlag(tmplData *TemplateData, flags *cmdFlags) error { @@ -199,14 +202,13 @@ func checkIfStdinIsPiped(rootCmd *cobra.Command) error { return err } if (stat.Mode() & os.ModeCharDevice) == 0 { - fmt.Println("data is being piped to stdin") + return nil } else { if err := rootCmd.Help(); err != nil { return err } return errors.New("ERROR: missing ≪ stdin ≫ pipe") } - return nil } func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { @@ -224,6 +226,10 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { tmplData.numOfTestsPerGroup = flags.groupSize tmplData.ReportTitle = flags.titleFlag tmplData.OutputFilename = flags.outputFlag + + //foobarStatus := foobar(tmplData, cmd) + _ = foobar(tmplData, cmd) + //foobar(stdin) // end timer return nil diff --git a/main_test.go b/main_test.go index 9763b9f..4ad41aa 100644 --- a/main_test.go +++ b/main_test.go @@ -32,7 +32,7 @@ func TestTitleFlag(t *testing.T) { output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("Sample Test Report", tmplData.ReportTitle) - assertions.Empty(output) + assertions.NotEmpty(output) } func TestTitleFlagIfMissingValue(t *testing.T) { @@ -59,7 +59,7 @@ func TestSizeFlag(t *testing.T) { assertions.Equal("24", flags.sizeFlag) assertions.Equal("24px", tmplData.TestResultGroupIndicatorWidth) assertions.Equal("24px", tmplData.TestResultGroupIndicatorHeight) - assertions.Empty(output) + assertions.NotEmpty(output) } func TestSizeFlagWithFullDimensions(t *testing.T) { @@ -75,7 +75,7 @@ func TestSizeFlagWithFullDimensions(t *testing.T) { assertions.Equal("24x16", flags.sizeFlag) assertions.Equal("24px", tmplData.TestResultGroupIndicatorWidth) assertions.Equal("16px", tmplData.TestResultGroupIndicatorHeight) - assertions.Empty(output) + assertions.NotEmpty(output) } func TestSizeFlagIfMissingValue(t *testing.T) { @@ -100,7 +100,7 @@ func TestGroupSizeFlag(t *testing.T) { output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal(32, tmplData.numOfTestsPerGroup) - assertions.Empty(output) + assertions.NotEmpty(output) } func TestGroupSizeFlagIfMissingValue(t *testing.T) { @@ -125,7 +125,7 @@ func TestGroupOutputFlag(t *testing.T) { output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("test_file.html", tmplData.OutputFilename) - assertions.Empty(output) + assertions.NotEmpty(output) } func TestGroupOutputFlagIfMissingValue(t *testing.T) { From 761bda5a7b622a804d1de155300e4c18dfbc9151 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sun, 21 Jun 2020 12:18:01 -0400 Subject: [PATCH 16/96] added minor code-refactoring and fixing some broken test --- main.go | 10 ++++------ main_test.go | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index bb7d344..44dddff 100644 --- a/main.go +++ b/main.go @@ -59,7 +59,7 @@ type ( } ) -func foobar(tmplData *TemplateData, cmd *cobra.Command) error { +func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { stdin := os.Stdin if err := checkIfStdinIsPiped(cmd); err != nil { //fmt.Println(err.Error()) @@ -226,11 +226,9 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { tmplData.numOfTestsPerGroup = flags.groupSize tmplData.ReportTitle = flags.titleFlag tmplData.OutputFilename = flags.outputFlag - - //foobarStatus := foobar(tmplData, cmd) - _ = foobar(tmplData, cmd) - - //foobar(stdin) + if err := generateTestReport(tmplData, cmd); err != nil { + return err + } // end timer return nil }, diff --git a/main_test.go b/main_test.go index 4ad41aa..1b4d177 100644 --- a/main_test.go +++ b/main_test.go @@ -28,7 +28,7 @@ func TestTitleFlag(t *testing.T) { rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--title", "Sample Test Report"}) rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) + assertions.Error(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("Sample Test Report", tmplData.ReportTitle) @@ -53,7 +53,7 @@ func TestSizeFlag(t *testing.T) { rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--size", "24"}) rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) + assertions.Error(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("24", flags.sizeFlag) @@ -69,7 +69,7 @@ func TestSizeFlagWithFullDimensions(t *testing.T) { rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--size", "24x16"}) rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) + assertions.Error(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("24x16", flags.sizeFlag) @@ -96,7 +96,7 @@ func TestGroupSizeFlag(t *testing.T) { rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--groupSize", "32"}) rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) + assertions.Error(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal(32, tmplData.numOfTestsPerGroup) @@ -121,7 +121,7 @@ func TestGroupOutputFlag(t *testing.T) { rootCmd.SetOut(buffer) rootCmd.SetArgs([]string{"--output", "test_file.html"}) rootCmdErr := rootCmd.Execute() - assertions.Nil(rootCmdErr) + assertions.Error(rootCmdErr) output, readErr := ioutil.ReadAll(buffer) assertions.Nil(readErr) assertions.Equal("test_file.html", tmplData.OutputFilename) From d4cdf35707ed8aa33bd2c2ba34362dbcbd7a0c52 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 22 Jun 2020 00:55:32 -0400 Subject: [PATCH 17/96] adds a short hand for the --groupSize flag --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 44dddff..e5feab3 100644 --- a/main.go +++ b/main.go @@ -255,8 +255,9 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { "s", "24", "the size of the clickable indicator for test result groups") - rootCmd.PersistentFlags().IntVar(&flags.groupSize, + rootCmd.PersistentFlags().IntVarP(&flags.groupSize, "groupSize", + "g", 10, "the number of tests per test group indicator") rootCmd.PersistentFlags().StringVarP(&flags.outputFlag, From dcaacb709a0decec243e24a132a4d6343342ce88 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Sun, 5 Jul 2020 00:43:38 -0500 Subject: [PATCH 18/96] adds AST parsing code to retrieve the filenames associated with test function names --- main.go | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index e5feab3..5bab00c 100644 --- a/main.go +++ b/main.go @@ -2,13 +2,20 @@ package main import ( "bufio" + "bytes" "encoding/json" "errors" "fmt" "github.com/spf13/cobra" + "go/ast" + "go/parser" + "go/token" "html/template" + "io" "io/ioutil" + "log" "os" + "os/exec" "strconv" "strings" ) @@ -269,10 +276,146 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { return rootCmd, tmplData, flags } +func pipeEchoCmdToShellCmd(echoCmd *exec.Cmd, shellCmd *exec.Cmd) { + var err error + rPipe, wPipe := io.Pipe() + echoCmd.Stdout = wPipe + shellCmd.Stdin = rPipe + stdoutPipe, err := shellCmd.StdoutPipe() + if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } + stderrPipe, err := shellCmd.StderrPipe() + if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } + errorCheck(echoCmd.Start()) + errorCheck(shellCmd.Start()) + errorCheck(echoCmd.Wait()) + errorCheck(wPipe.Close()) + scanStdOutErrWithPipeToConsole(&stdoutPipe, &stderrPipe, true) + errorCheck(shellCmd.Wait()) +} + +func scanStdOutErrWithPipeToConsole(stdout *io.ReadCloser, stderr *io.ReadCloser, useColor bool) { + stdoutScanner := bufio.NewScanner(*stdout) + stdoutScanner.Split(bufio.ScanLines) + for stdoutScanner.Scan() { + m := stdoutScanner.Text() + fmt.Println(m) + } + stderrScanner := bufio.NewScanner(*stderr) + stderrScanner.Split(bufio.ScanLines) + for stderrScanner.Scan() { + fmt.Println(stderrScanner.Text()) + } +} + +func errorCheck(err error) { + if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } +} + +type ( + GoListJsonModule struct { + Path string + Dir string + Main bool + } + + GoListJson struct { + Dir string + ImportPath string + Name string + GoFiles []string + TestGoFiles []string + Module GoListJsonModule + } +) + +type FunctionDetail struct { + FunctionName string + Line int + Col int +} +type TestFileDetail struct { + FileName string + Functions []FunctionDetail +} + +func getPackageDetails(paths []string) error { + var out bytes.Buffer + paths = append([]string{"list"}, paths...) + cmd := exec.Command("go", paths...) + cmd.Stdin = strings.NewReader("") + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + log.Fatal(err) + } + goListOutput := strings.Split(strings.TrimSpace(out.String()), "\n") + for _, packageName := range goListOutput { + cmd = exec.Command("go", "list", "-json", packageName) + out.Reset() + cmd.Stdin = strings.NewReader("") + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + log.Fatal(err) + } + goListJson := &GoListJson{} + if err := json.Unmarshal(out.Bytes(), goListJson); err != nil { + return err + } + testFileDetails := map[string]TestFileDetail{} + for _, file := range goListJson.TestGoFiles { + sourceFilePath := fmt.Sprintf("%s/%s", goListJson.Dir, file) + fileSet := token.NewFileSet() + f, err := parser.ParseFile(fileSet, sourceFilePath, nil, 0) + if err != nil { + return err + } + testFileDetail := TestFileDetail{} + ast.Inspect(f, func(n ast.Node) bool { + switch x := n.(type) { + case *ast.FuncDecl: + fileSetPos := fileSet.Position(n.Pos()) + folders := strings.Split(fileSetPos.String(), "/") + fileNameWithPos := folders[len(folders)-1] + fileDetails := strings.Split(fileNameWithPos, ":") + lineNum, _ := strconv.Atoi(fileDetails[1]) + colNum, _ := strconv.Atoi(fileDetails[2]) + testFileDetail.FileName = fileDetails[0] + testFileDetail.Functions = append(testFileDetail.Functions, FunctionDetail{ + FunctionName: x.Name.Name, + Line: lineNum, + Col: colNum, + }) + testFileDetails[sourceFilePath] = testFileDetail + } + return true + }) + o, _ := json.Marshal(testFileDetails) + fmt.Println(string(o)) + } + } + return nil +} + func main() { rootCmd, _, _ := newRootCommand() if err := rootCmd.Execute(); err != nil { fmt.Println(err.Error()) os.Exit(1) } -} + /* + if err := getPackageDetails([]string{"./..."}); err != nil { + fmt.Println(err) + os.Exit(1) + } + */ +} \ No newline at end of file From 5453286e56a552a1df09021692a93488e80ea72e Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 02:18:41 -0500 Subject: [PATCH 19/96] added initial code to map test names to their associated go test files. --- main.go | 306 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 167 insertions(+), 139 deletions(-) diff --git a/main.go b/main.go index 5bab00c..62a605a 100644 --- a/main.go +++ b/main.go @@ -10,10 +10,9 @@ import ( "go/ast" "go/parser" "go/token" + "go/types" "html/template" - "io" "io/ioutil" - "log" "os" "os/exec" "strconv" @@ -33,11 +32,12 @@ type ( } TestStatus struct { - TestName string - Package string - ElapsedTime float64 - Output []string - Passed bool + TestName string + Package string + ElapsedTime float64 + Output []string + Passed bool + TestFileName string } TemplateData struct { @@ -76,6 +76,7 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { var err error var allTests = map[string]*TestStatus{} + var allPackageNames = map[string]*types.Nil{} // read from stdin and parse "go test" results @@ -110,9 +111,14 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { } testStatus.ElapsedTime = goTestOutputRow.Elapsed } + allPackageNames[goTestOutputRow.Package] = nil testStatus.Output = append(testStatus.Output, goTestOutputRow.Output) } } + testFileDetailByPackage, err := getPackageDetails(allPackageNames) + if err != nil { + return nil + } if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { return err } else { @@ -170,9 +176,117 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { tmplData.NumOfTests = tmplData.NumOfTestPassed + tmplData.NumOfTestFailed err = tpl.Execute(w, tmplData) } + + for _, testGroup := range tmplData.TestResults { + for _, result := range testGroup.TestResults { + //fmt.Println(result.TestName) + fmt.Println(testFileDetailByPackage[result.Package][result.TestName]) + } + } + + //for _, testGroup := range tmplData.TestResults { + // for _, testResult := range testGroup.TestResults { + // fmt.Println(testFileDetailByPackage[testResult.Package]) + // } + //} + //for packageName := range testFileDetailByPackage { + // //fmt.Println(m[s].FileName) + // //fmt.Println(packageName) + // for testFilePath := range testFileDetailByPackage[packageName] { + // //fmt.Println(testFilePath) + // //fmt.Println(testFileDetailByPackage[packageName][testFilePath].FileName) + // for _, functionInfo := range testFileDetailByPackage[packageName][testFilePath].Functions { + // fmt.Println(functionInfo) + // + // } + // } + // fmt.Println("----") + //} + //o, _ := json.Marshal(testFileDetailByPackage) + //fmt.Println(string(o)) + //fmt.Println(testNamesByPackage) return nil } +type ( + GoListJsonModule struct { + Path string + Dir string + Main bool + } + + GoListJson struct { + Dir string + ImportPath string + Name string + GoFiles []string + TestGoFiles []string + Module GoListJsonModule + } +) + +type FunctionDetail struct { + Line int + Col int +} + +type TestFileDetail struct { + FileName string + FunctionDetail FunctionDetail +} + +type TestFileDetailsByPackage map[string]map[string]*TestFileDetail + +func getPackageDetails(allPackageNames map[string]*types.Nil) (TestFileDetailsByPackage, error) { + var out bytes.Buffer + var cmd *exec.Cmd + testFileDetailByPackage := TestFileDetailsByPackage{} + for packageName := range allPackageNames { + cmd = exec.Command("go", "list", "-json", packageName) + fmt.Println(packageName) + out.Reset() + cmd.Stdin = strings.NewReader("") + cmd.Stdout = &out + err := cmd.Run() + if err != nil { + return nil, err + } + goListJson := &GoListJson{} + if err := json.Unmarshal(out.Bytes(), goListJson); err != nil { + return nil, err + } + testFileDetailByPackage[packageName] = map[string]*TestFileDetail{} + for _, file := range goListJson.TestGoFiles { + sourceFilePath := fmt.Sprintf("%s/%s", goListJson.Dir, file) + fileSet := token.NewFileSet() + f, err := parser.ParseFile(fileSet, sourceFilePath, nil, 0) + if err != nil { + return nil, err + } + ast.Inspect(f, func(n ast.Node) bool { + switch x := n.(type) { + case *ast.FuncDecl: + testFileDetail := &TestFileDetail{} + fileSetPos := fileSet.Position(n.Pos()) + folders := strings.Split(fileSetPos.String(), "/") + fileNameWithPos := folders[len(folders)-1] + fileDetails := strings.Split(fileNameWithPos, ":") + lineNum, _ := strconv.Atoi(fileDetails[1]) + colNum, _ := strconv.Atoi(fileDetails[2]) + testFileDetail.FileName = fileDetails[0] + testFileDetail.FunctionDetail = FunctionDetail{ + Line: lineNum, + Col: colNum, + } + testFileDetailByPackage[packageName][x.Name.Name] = testFileDetail + } + return true + }) + } + } + return testFileDetailByPackage, nil +} + func parseSizeFlag(tmplData *TemplateData, flags *cmdFlags) error { flags.sizeFlag = strings.ToLower(flags.sizeFlag) if !strings.Contains(flags.sizeFlag, "x") { @@ -276,136 +390,6 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { return rootCmd, tmplData, flags } -func pipeEchoCmdToShellCmd(echoCmd *exec.Cmd, shellCmd *exec.Cmd) { - var err error - rPipe, wPipe := io.Pipe() - echoCmd.Stdout = wPipe - shellCmd.Stdin = rPipe - stdoutPipe, err := shellCmd.StdoutPipe() - if err != nil { - fmt.Println(err.Error()) - os.Exit(1) - } - stderrPipe, err := shellCmd.StderrPipe() - if err != nil { - fmt.Println(err.Error()) - os.Exit(1) - } - errorCheck(echoCmd.Start()) - errorCheck(shellCmd.Start()) - errorCheck(echoCmd.Wait()) - errorCheck(wPipe.Close()) - scanStdOutErrWithPipeToConsole(&stdoutPipe, &stderrPipe, true) - errorCheck(shellCmd.Wait()) -} - -func scanStdOutErrWithPipeToConsole(stdout *io.ReadCloser, stderr *io.ReadCloser, useColor bool) { - stdoutScanner := bufio.NewScanner(*stdout) - stdoutScanner.Split(bufio.ScanLines) - for stdoutScanner.Scan() { - m := stdoutScanner.Text() - fmt.Println(m) - } - stderrScanner := bufio.NewScanner(*stderr) - stderrScanner.Split(bufio.ScanLines) - for stderrScanner.Scan() { - fmt.Println(stderrScanner.Text()) - } -} - -func errorCheck(err error) { - if err != nil { - fmt.Println(err.Error()) - os.Exit(1) - } -} - -type ( - GoListJsonModule struct { - Path string - Dir string - Main bool - } - - GoListJson struct { - Dir string - ImportPath string - Name string - GoFiles []string - TestGoFiles []string - Module GoListJsonModule - } -) - -type FunctionDetail struct { - FunctionName string - Line int - Col int -} -type TestFileDetail struct { - FileName string - Functions []FunctionDetail -} - -func getPackageDetails(paths []string) error { - var out bytes.Buffer - paths = append([]string{"list"}, paths...) - cmd := exec.Command("go", paths...) - cmd.Stdin = strings.NewReader("") - cmd.Stdout = &out - err := cmd.Run() - if err != nil { - log.Fatal(err) - } - goListOutput := strings.Split(strings.TrimSpace(out.String()), "\n") - for _, packageName := range goListOutput { - cmd = exec.Command("go", "list", "-json", packageName) - out.Reset() - cmd.Stdin = strings.NewReader("") - cmd.Stdout = &out - err := cmd.Run() - if err != nil { - log.Fatal(err) - } - goListJson := &GoListJson{} - if err := json.Unmarshal(out.Bytes(), goListJson); err != nil { - return err - } - testFileDetails := map[string]TestFileDetail{} - for _, file := range goListJson.TestGoFiles { - sourceFilePath := fmt.Sprintf("%s/%s", goListJson.Dir, file) - fileSet := token.NewFileSet() - f, err := parser.ParseFile(fileSet, sourceFilePath, nil, 0) - if err != nil { - return err - } - testFileDetail := TestFileDetail{} - ast.Inspect(f, func(n ast.Node) bool { - switch x := n.(type) { - case *ast.FuncDecl: - fileSetPos := fileSet.Position(n.Pos()) - folders := strings.Split(fileSetPos.String(), "/") - fileNameWithPos := folders[len(folders)-1] - fileDetails := strings.Split(fileNameWithPos, ":") - lineNum, _ := strconv.Atoi(fileDetails[1]) - colNum, _ := strconv.Atoi(fileDetails[2]) - testFileDetail.FileName = fileDetails[0] - testFileDetail.Functions = append(testFileDetail.Functions, FunctionDetail{ - FunctionName: x.Name.Name, - Line: lineNum, - Col: colNum, - }) - testFileDetails[sourceFilePath] = testFileDetail - } - return true - }) - o, _ := json.Marshal(testFileDetails) - fmt.Println(string(o)) - } - } - return nil -} - func main() { rootCmd, _, _ := newRootCommand() if err := rootCmd.Execute(); err != nil { @@ -417,5 +401,49 @@ func main() { fmt.Println(err) os.Exit(1) } - */ -} \ No newline at end of file + */ +} + +//func pipeEchoCmdToShellCmd(echoCmd *exec.Cmd, shellCmd *exec.Cmd) { +// var err error +// rPipe, wPipe := io.Pipe() +// echoCmd.Stdout = wPipe +// shellCmd.Stdin = rPipe +// stdoutPipe, err := shellCmd.StdoutPipe() +// if err != nil { +// fmt.Println(err.Error()) +// os.Exit(1) +// } +// stderrPipe, err := shellCmd.StderrPipe() +// if err != nil { +// fmt.Println(err.Error()) +// os.Exit(1) +// } +// errorCheck(echoCmd.Start()) +// errorCheck(shellCmd.Start()) +// errorCheck(echoCmd.Wait()) +// errorCheck(wPipe.Close()) +// scanStdOutErrWithPipeToConsole(&stdoutPipe, &stderrPipe, true) +// errorCheck(shellCmd.Wait()) +//} + +//func scanStdOutErrWithPipeToConsole(stdout *io.ReadCloser, stderr *io.ReadCloser, useColor bool) { +// stdoutScanner := bufio.NewScanner(*stdout) +// stdoutScanner.Split(bufio.ScanLines) +// for stdoutScanner.Scan() { +// m := stdoutScanner.Text() +// fmt.Println(m) +// } +// stderrScanner := bufio.NewScanner(*stderr) +// stderrScanner.Split(bufio.ScanLines) +// for stderrScanner.Scan() { +// fmt.Println(stderrScanner.Text()) +// } +//} + +//func errorCheck(err error) { +// if err != nil { +// fmt.Println(err.Error()) +// os.Exit(1) +// } +//} From df18e738e03357c4a86e3dc3129c1c8caa7a452b Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 11:01:10 -0500 Subject: [PATCH 20/96] Adds the test file with line and col position information --- main.go | 35 ++++++++++++++++++++++------------- test_report.js | 4 +++- test_report.test.js | 32 ++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/main.go b/main.go index 62a605a..af05800 100644 --- a/main.go +++ b/main.go @@ -32,12 +32,13 @@ type ( } TestStatus struct { - TestName string - Package string - ElapsedTime float64 - Output []string - Passed bool - TestFileName string + TestName string + Package string + ElapsedTime float64 + Output []string + Passed bool + TestFileName string + TestFunctionDetail FunctionDetail } TemplateData struct { @@ -115,10 +116,12 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { testStatus.Output = append(testStatus.Output, goTestOutputRow.Output) } } + testFileDetailByPackage, err := getPackageDetails(allPackageNames) if err != nil { return nil } + if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { return err } else { @@ -160,6 +163,13 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { if len(tmplData.TestResults) == tgId { tmplData.TestResults = append(tmplData.TestResults, &TestGroupData{}) } + + testFileInfo := testFileDetailByPackage[status.Package][status.TestName] + if testFileInfo != nil { + status.TestFileName = testFileInfo.FileName + status.TestFunctionDetail = testFileInfo.FunctionDetail + } + tmplData.TestResults[tgId].TestResults = append(tmplData.TestResults[tgId].TestResults, status) if !status.Passed { tmplData.TestResults[tgId].FailureIndicator = "failed" @@ -177,12 +187,12 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { err = tpl.Execute(w, tmplData) } - for _, testGroup := range tmplData.TestResults { - for _, result := range testGroup.TestResults { - //fmt.Println(result.TestName) - fmt.Println(testFileDetailByPackage[result.Package][result.TestName]) - } - } + //for _, testGroup := range tmplData.TestResults { + // for _, result := range testGroup.TestResults { + // //fmt.Println(result.TestName) + // fmt.Println(testFileDetailByPackage[result.Package][result.TestName]) + // } + //} //for _, testGroup := range tmplData.TestResults { // for _, testResult := range testGroup.TestResults { @@ -243,7 +253,6 @@ func getPackageDetails(allPackageNames map[string]*types.Nil) (TestFileDetailsBy testFileDetailByPackage := TestFileDetailsByPackage{} for packageName := range allPackageNames { cmd = exec.Command("go", "list", "-json", packageName) - fmt.Println(packageName) out.Reset() cmd.Stdin = strings.NewReader("") cmd.Stdout = &out diff --git a/test_report.js b/test_report.js index 622e961..84100e7 100644 --- a/test_report.js +++ b/test_report.js @@ -139,7 +139,9 @@ window.GoTestReport = function (elements) { packageNameDiv.innerHTML = `Package: ${testStatus.Package}` const testFileNameDiv = document.createElement('div') testFileNameDiv.classList.add('filename') - testFileNameDiv.innerHTML = `Filename: ` + testFileNameDiv.innerHTML = `Filename: ${testStatus.TestFileName}   ` + testFileNameDiv.innerHTML += `Line: ${testStatus.TestFunctionDetail.Line} ` + testFileNameDiv.innerHTML += `Col: ${testStatus.TestFunctionDetail.Col}` testDetailDiv.insertAdjacentElement('beforeend', packageNameDiv) testDetailDiv.insertAdjacentElement('beforeend', testFileNameDiv) diff --git a/test_report.test.js b/test_report.test.js index c1c2706..9157240 100644 --- a/test_report.test.js +++ b/test_report.test.js @@ -13,7 +13,12 @@ const mockData = [ "test output A 1\n", "test output A 2\n", "test output A 3\n", - ] + ], + TestFileName: "test_test.go", + TestFunctionDetail: { + Line: 1, + Col: 10, + }, }] }, { "TestResults": [{ @@ -24,7 +29,12 @@ const mockData = [ "test output B 1\n", "test output B 2\n", "test output B 3\n", - ] + ], + TestFileName: "test_test_1.go", + TestFunctionDetail: { + Line: 20, + Col: 1, + }, }, { TestName: "my_sample_test 3", Package: "test/package 3", @@ -33,7 +43,12 @@ const mockData = [ "test output C 1\n", "test output C 2\n", "test output C 3\n", - ] + ], + TestFileName: "test_test_2.go", + TestFunctionDetail: { + Line: 33, + Col: 7, + }, }] }, { "TestResults": [{ @@ -44,7 +59,12 @@ const mockData = [ "test output D 1\n", "test output D 2\n", "test output D 3\n", - ] + ], + TestFileName: "test_test_3.go", + TestFunctionDetail: { + Line: 101, + Col: 9, + }, }] }] @@ -127,7 +147,7 @@ test('test testGroupListHandler using [test group: 0]', () => { const packageElem = testDetailElem.querySelector('.package') expect(packageElem.innerHTML).toBe(`Package: test/package 1`) const filenameElem = testDetailElem.querySelector('.filename') - expect(filenameElem.innerHTML).toBe(`Filename: `) + expect(filenameElem.innerHTML).toBe(`Filename: test_test.go   Line: 1 Col: 10`) }) test('test testGroupListHandler using [test group: 1]', () => { @@ -141,5 +161,5 @@ test('test testGroupListHandler using [test group: 1]', () => { const packageElem = testDetailElem.querySelector('.package') expect(packageElem.innerHTML).toBe(`Package: test/package 4`) const filenameElem = testDetailElem.querySelector('.filename') - expect(filenameElem.innerHTML).toBe(`Filename: `) + expect(filenameElem.innerHTML).toBe(`Filename: test_test_3.go   Line: 101 Col: 9`) }) \ No newline at end of file From 2aecebb2842cdda57293b9d2fb8f7e2cef39c1e7 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 11:18:34 -0500 Subject: [PATCH 21/96] code cleanup --- main.go | 155 ++++++++++++-------------------------------------------- 1 file changed, 31 insertions(+), 124 deletions(-) diff --git a/main.go b/main.go index af05800..30cf0a6 100644 --- a/main.go +++ b/main.go @@ -65,13 +65,38 @@ type ( groupSize int outputFlag string } + + GoListJsonModule struct { + Path string + Dir string + Main bool + } + + GoListJson struct { + Dir string + ImportPath string + Name string + GoFiles []string + TestGoFiles []string + Module GoListJsonModule + } + + FunctionDetail struct { + Line int + Col int + } + + TestFileDetail struct { + FileName string + FunctionDetail FunctionDetail + } + + TestFileDetailsByPackage map[string]map[string]*TestFileDetail ) func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { stdin := os.Stdin if err := checkIfStdinIsPiped(cmd); err != nil { - //fmt.Println(err.Error()) - //os.Exit(1) return err } @@ -80,7 +105,6 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { var allPackageNames = map[string]*types.Nil{} // read from stdin and parse "go test" results - defer func() { if err = stdin.Close(); err != nil { panic(err) @@ -92,7 +116,7 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { lineInput := stdinScanner.Bytes() goTestOutputRow := &goTestOutputRow{} if err := json.Unmarshal(lineInput, goTestOutputRow); err != nil { - fmt.Println(err) + return err } if goTestOutputRow.TestName != "" { var testStatus *TestStatus @@ -117,6 +141,7 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { } } + // used to the location of test functions in test go files by package and test function name. testFileDetailByPackage, err := getPackageDetails(allPackageNames) if err != nil { return nil @@ -129,7 +154,7 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { w := bufio.NewWriter(testReportHTMLTemplateFile) defer func() { if err := w.Flush(); err != nil { - fmt.Println(err) + panic(err) } if err := testReportHTMLTemplateFile.Close(); err != nil { panic(err) @@ -142,17 +167,6 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { return err } - //tmplData := TemplateData{ - // ReportTitle: "go-test-report", - // TestResultGroupIndicatorWidth: "24px", - // TestResultGroupIndicatorHeight: "24px", - // NumOfTestPassed: 0, - // NumOfTestFailed: 0, - // TestResults: []*TestGroupData{}, - // NumOfTests: 0, - // JsCode: template.JS(jsCode), - // numOfTestsPerGroup: 20, - //} tmplData.NumOfTestPassed = 0 tmplData.NumOfTestFailed = 0 tmplData.JsCode = template.JS(jsCode) @@ -164,6 +178,7 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { tmplData.TestResults = append(tmplData.TestResults, &TestGroupData{}) } + // add file info(name and position; line and col) associated with the test function testFileInfo := testFileDetailByPackage[status.Package][status.TestName] if testFileInfo != nil { status.TestFileName = testFileInfo.FileName @@ -186,67 +201,9 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { tmplData.NumOfTests = tmplData.NumOfTestPassed + tmplData.NumOfTestFailed err = tpl.Execute(w, tmplData) } - - //for _, testGroup := range tmplData.TestResults { - // for _, result := range testGroup.TestResults { - // //fmt.Println(result.TestName) - // fmt.Println(testFileDetailByPackage[result.Package][result.TestName]) - // } - //} - - //for _, testGroup := range tmplData.TestResults { - // for _, testResult := range testGroup.TestResults { - // fmt.Println(testFileDetailByPackage[testResult.Package]) - // } - //} - //for packageName := range testFileDetailByPackage { - // //fmt.Println(m[s].FileName) - // //fmt.Println(packageName) - // for testFilePath := range testFileDetailByPackage[packageName] { - // //fmt.Println(testFilePath) - // //fmt.Println(testFileDetailByPackage[packageName][testFilePath].FileName) - // for _, functionInfo := range testFileDetailByPackage[packageName][testFilePath].Functions { - // fmt.Println(functionInfo) - // - // } - // } - // fmt.Println("----") - //} - //o, _ := json.Marshal(testFileDetailByPackage) - //fmt.Println(string(o)) - //fmt.Println(testNamesByPackage) return nil } -type ( - GoListJsonModule struct { - Path string - Dir string - Main bool - } - - GoListJson struct { - Dir string - ImportPath string - Name string - GoFiles []string - TestGoFiles []string - Module GoListJsonModule - } -) - -type FunctionDetail struct { - Line int - Col int -} - -type TestFileDetail struct { - FileName string - FunctionDetail FunctionDetail -} - -type TestFileDetailsByPackage map[string]map[string]*TestFileDetail - func getPackageDetails(allPackageNames map[string]*types.Nil) (TestFileDetailsByPackage, error) { var out bytes.Buffer var cmd *exec.Cmd @@ -405,54 +362,4 @@ func main() { fmt.Println(err.Error()) os.Exit(1) } - /* - if err := getPackageDetails([]string{"./..."}); err != nil { - fmt.Println(err) - os.Exit(1) - } - */ } - -//func pipeEchoCmdToShellCmd(echoCmd *exec.Cmd, shellCmd *exec.Cmd) { -// var err error -// rPipe, wPipe := io.Pipe() -// echoCmd.Stdout = wPipe -// shellCmd.Stdin = rPipe -// stdoutPipe, err := shellCmd.StdoutPipe() -// if err != nil { -// fmt.Println(err.Error()) -// os.Exit(1) -// } -// stderrPipe, err := shellCmd.StderrPipe() -// if err != nil { -// fmt.Println(err.Error()) -// os.Exit(1) -// } -// errorCheck(echoCmd.Start()) -// errorCheck(shellCmd.Start()) -// errorCheck(echoCmd.Wait()) -// errorCheck(wPipe.Close()) -// scanStdOutErrWithPipeToConsole(&stdoutPipe, &stderrPipe, true) -// errorCheck(shellCmd.Wait()) -//} - -//func scanStdOutErrWithPipeToConsole(stdout *io.ReadCloser, stderr *io.ReadCloser, useColor bool) { -// stdoutScanner := bufio.NewScanner(*stdout) -// stdoutScanner.Split(bufio.ScanLines) -// for stdoutScanner.Scan() { -// m := stdoutScanner.Text() -// fmt.Println(m) -// } -// stderrScanner := bufio.NewScanner(*stderr) -// stderrScanner.Split(bufio.ScanLines) -// for stderrScanner.Scan() { -// fmt.Println(stderrScanner.Text()) -// } -//} - -//func errorCheck(err error) { -// if err != nil { -// fmt.Println(err.Error()) -// os.Exit(1) -// } -//} From f2cc568108ca8a4d49b8491584ed567f6b173001 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 14:52:32 -0500 Subject: [PATCH 22/96] added embedded assets into the binary --- embed_assets/main.go | 54 +++++++++++++++++++ .../test_report.html.template | 0 test_report.js => embed_assets/test_report.js | 0 main.go | 16 ++++-- package.json | 2 +- test_report.test.js | 2 +- 6 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 embed_assets/main.go rename test_report.html.template => embed_assets/test_report.html.template (100%) rename test_report.js => embed_assets/test_report.js (100%) diff --git a/embed_assets/main.go b/embed_assets/main.go new file mode 100644 index 0000000..9ea231a --- /dev/null +++ b/embed_assets/main.go @@ -0,0 +1,54 @@ +package main + +import ( + "bufio" + "encoding/hex" + "fmt" + "io/ioutil" + "os" +) + +var htmlTemplate []byte +var jsCode []byte + +func init() { + htmlTemplate, _ = ioutil.ReadFile("test_report.html.template") + jsCode, _ = ioutil.ReadFile("test_report.js") +} + +func main() { + outputFile1, _ := os.Create("../embedded_assets.go") + writer := bufio.NewWriter(outputFile1) + defer func() { + if err := writer.Flush(); err != nil { + panic(err) + } + if err := outputFile1.Close(); err != nil { + panic(err) + } + }() + dst := make([]byte, hex.EncodedLen(len(htmlTemplate))) + hex.Encode(dst, htmlTemplate) + _, _ = writer.WriteString(fmt.Sprintf("package main\n\nvar testReportHtmlTemplateSize = %d\nvar testReportHtmlTemplate = `%s`", len(htmlTemplate), string(dst))) + dst = make([]byte, hex.EncodedLen(len(jsCode))) + hex.Encode(dst, jsCode) + _, _ = writer.WriteString(fmt.Sprintf("\n\nvar testReportJsCodeSize = %d\nvar testReportJsCode = `%s`", len(jsCode), string(dst))) +} + +func TestReportHtmlTemplate() ([]byte, error) { + dst := make([]byte, hex.DecodedLen(len(htmlTemplate))) + if _, err := hex.Decode(dst, htmlTemplate); err != nil { + return nil, err + } else { + return dst, err + } +} + +func TestReportJsCode() ([]byte, error) { + dst := make([]byte, hex.DecodedLen(len(jsCode))) + if _, err := hex.Decode(dst, jsCode); err != nil { + return nil, err + } else { + return dst, err + } +} \ No newline at end of file diff --git a/test_report.html.template b/embed_assets/test_report.html.template similarity index 100% rename from test_report.html.template rename to embed_assets/test_report.html.template diff --git a/test_report.js b/embed_assets/test_report.js similarity index 100% rename from test_report.js rename to embed_assets/test_report.js diff --git a/main.go b/main.go index 30cf0a6..ab22c6f 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "bufio" "bytes" + "encoding/hex" "encoding/json" "errors" "fmt" @@ -12,7 +13,6 @@ import ( "go/token" "go/types" "html/template" - "io/ioutil" "os" "os/exec" "strconv" @@ -147,7 +147,13 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { return nil } - if tpl, err := template.ParseFiles("test_report.html.template"); err != nil { + // read the html template from embedded asset go file + tpl := template.New("test_report.html.template") + testReportHtmlTemplateStr, err := hex.DecodeString(testReportHtmlTemplate) + if err != nil { + return err + } + if tpl, err := tpl.Parse(string(testReportHtmlTemplateStr)); err != nil { return err } else { testReportHTMLTemplateFile, _ := os.Create(tmplData.OutputFilename) @@ -161,15 +167,15 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { } }() - // read Javascript test code - jsCode, err := ioutil.ReadFile("test_report.js") + // read Javascript code from embedded asset go file + testReportJsCodeStr, err := hex.DecodeString(testReportJsCode) if err != nil { return err } tmplData.NumOfTestPassed = 0 tmplData.NumOfTestFailed = 0 - tmplData.JsCode = template.JS(jsCode) + tmplData.JsCode = template.JS(testReportJsCodeStr) tgCounter := 0 tgId := 0 diff --git a/package.json b/package.json index deebc32..84d341d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "go-test-report", "version": "0.9.0", "description": "UI for go-test-report", - "main": "test_report.js", + "main": "embed_assets/test_report.js", "scripts": { "test": "jest" }, diff --git a/test_report.test.js b/test_report.test.js index 9157240..548a3f3 100644 --- a/test_report.test.js +++ b/test_report.test.js @@ -1,5 +1,5 @@ const expect = require('@jest/globals').expect -require('./test_report.js') +require('./embed_assets/test_report.js') /** * @property {Array.} TestResults From 23ca87afde72f7a498f80fdf36e8f7a4671774b5 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 14:58:31 -0500 Subject: [PATCH 23/96] updated dockerfile to fix broken build --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 76199a6..dd6b1f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,4 +19,10 @@ ADD . . RUN npm install RUN npm fund RUN npm run test + +WORKDIR /home/dockeruser/embed_assets +RUN go build +RUN ./embed_assets + +WORKDIR /home/dockeruser RUN go test -v From 2774577ffa87c60ca39cc63c02435c31c7dda11d Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 21:44:40 -0500 Subject: [PATCH 24/96] removed unnecessary generated code --- embed_assets/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embed_assets/main.go b/embed_assets/main.go index 9ea231a..40d490b 100644 --- a/embed_assets/main.go +++ b/embed_assets/main.go @@ -29,10 +29,10 @@ func main() { }() dst := make([]byte, hex.EncodedLen(len(htmlTemplate))) hex.Encode(dst, htmlTemplate) - _, _ = writer.WriteString(fmt.Sprintf("package main\n\nvar testReportHtmlTemplateSize = %d\nvar testReportHtmlTemplate = `%s`", len(htmlTemplate), string(dst))) + _, _ = writer.WriteString(fmt.Sprintf("package main\n\nvar testReportHtmlTemplate = `%s`", string(dst))) dst = make([]byte, hex.EncodedLen(len(jsCode))) hex.Encode(dst, jsCode) - _, _ = writer.WriteString(fmt.Sprintf("\n\nvar testReportJsCodeSize = %d\nvar testReportJsCode = `%s`", len(jsCode), string(dst))) + _, _ = writer.WriteString(fmt.Sprintf("\n\nvar testReportJsCode = `%s`", string(dst))) } func TestReportHtmlTemplate() ([]byte, error) { From 3de66dfbc7bc12336555cfe4882db9a322e23217 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 22:19:09 -0500 Subject: [PATCH 25/96] added verbose flag --- main.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index ab22c6f..f0ee601 100644 --- a/main.go +++ b/main.go @@ -64,6 +64,7 @@ type ( sizeFlag string groupSize int outputFlag string + verbose bool } GoListJsonModule struct { @@ -94,7 +95,7 @@ type ( TestFileDetailsByPackage map[string]map[string]*TestFileDetail ) -func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { +func generateTestReport(flags *cmdFlags, tmplData *TemplateData, cmd *cobra.Command) error { stdin := os.Stdin if err := checkIfStdinIsPiped(cmd); err != nil { return err @@ -114,6 +115,12 @@ func generateTestReport(tmplData *TemplateData, cmd *cobra.Command) error { for stdinScanner.Scan() { stdinScanner.Text() lineInput := stdinScanner.Bytes() + if flags.verbose { + newline := []byte("\n") + if _, err := cmd.OutOrStdout().Write(append(lineInput, newline[0])); err != nil { + return err + } + } goTestOutputRow := &goTestOutputRow{} if err := json.Unmarshal(lineInput, goTestOutputRow); err != nil { return err @@ -297,9 +304,6 @@ func checkIfStdinIsPiped(rootCmd *cobra.Command) error { if (stat.Mode() & os.ModeCharDevice) == 0 { return nil } else { - if err := rootCmd.Help(); err != nil { - return err - } return errors.New("ERROR: missing ≪ stdin ≫ pipe") } } @@ -319,8 +323,8 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { tmplData.numOfTestsPerGroup = flags.groupSize tmplData.ReportTitle = flags.titleFlag tmplData.OutputFilename = flags.outputFlag - if err := generateTestReport(tmplData, cmd); err != nil { - return err + if err := generateTestReport(flags, tmplData, cmd); err != nil { + return errors.New(err.Error() + "\n") } // end timer return nil @@ -358,6 +362,11 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { "o", "test_report.html", "the HTML output file") + rootCmd.PersistentFlags().BoolVarP(&flags.verbose, + "verbose", + "v", + false, + "while processing, show the complete output from go test ") return rootCmd, tmplData, flags } @@ -365,7 +374,6 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { func main() { rootCmd, _, _ := newRootCommand() if err := rootCmd.Execute(); err != nil { - fmt.Println(err.Error()) os.Exit(1) } } From 8686697cb86e56177ee8fad5aa155254bc2a86b8 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 22:19:31 -0500 Subject: [PATCH 26/96] add total time at the end of process --- main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f0ee601..cff3354 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( "os/exec" "strconv" "strings" + "time" ) var version = "0.9" @@ -315,8 +316,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { Use: "go-test-report", Long: "Captures go test output via stdin and parses it into a single self-contained html file.", RunE: func(cmd *cobra.Command, args []string) error { - // start timer - // -- do stuff + startTime := time.Now() if err := parseSizeFlag(tmplData, flags); err != nil { return err } @@ -326,7 +326,11 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { if err := generateTestReport(flags, tmplData, cmd); err != nil { return errors.New(err.Error() + "\n") } - // end timer + elapsedTime := time.Since(startTime) + elapsedTimeMsg := []byte(fmt.Sprintf("\n[go-test-report] finished in %s\n", elapsedTime)) + if _, err := cmd.OutOrStdout().Write(elapsedTimeMsg); err != nil { + return err + } return nil }, } From 8248f656acb1d34f0c1f43512a87e343db63d193 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 22:22:32 -0500 Subject: [PATCH 27/96] removed unneeded code --- embed_assets/main.go | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/embed_assets/main.go b/embed_assets/main.go index 40d490b..70ffab7 100644 --- a/embed_assets/main.go +++ b/embed_assets/main.go @@ -33,22 +33,4 @@ func main() { dst = make([]byte, hex.EncodedLen(len(jsCode))) hex.Encode(dst, jsCode) _, _ = writer.WriteString(fmt.Sprintf("\n\nvar testReportJsCode = `%s`", string(dst))) -} - -func TestReportHtmlTemplate() ([]byte, error) { - dst := make([]byte, hex.DecodedLen(len(htmlTemplate))) - if _, err := hex.Decode(dst, htmlTemplate); err != nil { - return nil, err - } else { - return dst, err - } -} - -func TestReportJsCode() ([]byte, error) { - dst := make([]byte, hex.DecodedLen(len(jsCode))) - if _, err := hex.Decode(dst, jsCode); err != nil { - return nil, err - } else { - return dst, err - } } \ No newline at end of file From 4510ff30dc108401570106bc9eb79f510e1fb478 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 23:16:32 -0500 Subject: [PATCH 28/96] updated readme --- docs/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 1495b67..8606d28 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,8 +34,6 @@ go-test-report.html Additional configuration options are available via command line flags. ``` -Captures go test output via stdin and parses it into a single self-contained html file. - Usage: go-test-report [flags] go-test-report [command] @@ -45,12 +43,12 @@ Available Commands: version Prints the version number of go-test-report Flags: - --groupSize int the number of tests per test group indicator (default 10) + -g, --groupSize int the number of tests per test group indicator (default 10) -h, --help help for go-test-report -o, --output string the HTML output file (default "test_report.html") -s, --size string the size of the clickable indicator for test result groups (default "24") -t, --title string the title text shown in the test report (default "go-test-report") + -v, --verbose while processing, show the complete output from go test Use "go-test-report [command] --help" for more information about a command. - -Additional configuration options are available via command line flags. \ No newline at end of file +``` \ No newline at end of file From 5195125cdc5808adb85920fbbb249bd03b43be30 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Mon, 6 Jul 2020 23:16:57 -0500 Subject: [PATCH 29/96] adds a build script for mac, linux and windows builds --- build_release.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 build_release.sh diff --git a/build_release.sh b/build_release.sh new file mode 100755 index 0000000..89ce221 --- /dev/null +++ b/build_release.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Building..." +echo "Linux 64bit" +GOOS=linux GOARCH=amd64 go build -o release_builds/linux-amd64/ + +echo "Darwin (MacOS) 64bit" +GOOS=darwin GOARCH=amd64 go build -o release_builds/darwin-amd64/ + +echo "Windows 32bit" +GOOS=windows GOARCH=386 go build -o release_builds/windows-386/ + +echo "Windows 64bit" +GOOS=windows GOARCH=amd64 go build -o release_builds/windows-amd64/ + +echo "...Done!" \ No newline at end of file From e272d016b31a430f16750de5561d21a1c6790abe Mon Sep 17 00:00:00 2001 From: Samuel A Date: Tue, 7 Jul 2020 00:58:37 -0500 Subject: [PATCH 30/96] updates release build file to create the destination folders before performing builds. --- build_release.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build_release.sh b/build_release.sh index 89ce221..08ff517 100755 --- a/build_release.sh +++ b/build_release.sh @@ -1,6 +1,12 @@ #!/bin/sh echo "Building..." + +mkdir -p release_builds/linux-amd64/ +mkdir -p release_builds/darwin-amd64/ +mkdir -p release_builds/windows-i386/ +mkdir -p release_builds/windows-amd64/ + echo "Linux 64bit" GOOS=linux GOARCH=amd64 go build -o release_builds/linux-amd64/ @@ -8,7 +14,7 @@ echo "Darwin (MacOS) 64bit" GOOS=darwin GOARCH=amd64 go build -o release_builds/darwin-amd64/ echo "Windows 32bit" -GOOS=windows GOARCH=386 go build -o release_builds/windows-386/ +GOOS=windows GOARCH=386 go build -o release_builds/windows-i386/ echo "Windows 64bit" GOOS=windows GOARCH=amd64 go build -o release_builds/windows-amd64/ From e13543ba7d152dd4b6f801bfa12fd5c785329656 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Tue, 7 Jul 2020 00:59:26 -0500 Subject: [PATCH 31/96] added a little more clarity to the -groupSize usage description --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index cff3354..1408147 100644 --- a/main.go +++ b/main.go @@ -327,7 +327,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { return errors.New(err.Error() + "\n") } elapsedTime := time.Since(startTime) - elapsedTimeMsg := []byte(fmt.Sprintf("\n[go-test-report] finished in %s\n", elapsedTime)) + elapsedTimeMsg := []byte(fmt.Sprintf("[go-test-report] finished in %s\n", elapsedTime)) if _, err := cmd.OutOrStdout().Write(elapsedTimeMsg); err != nil { return err } @@ -355,7 +355,7 @@ func newRootCommand() (*cobra.Command, *TemplateData, *cmdFlags) { "size", "s", "24", - "the size of the clickable indicator for test result groups") + "the size (in pixels) of the clickable indicator for test result groups") rootCmd.PersistentFlags().IntVarP(&flags.groupSize, "groupSize", "g", From cf989cb750cbff66b69134aed90136bdbe525aa6 Mon Sep 17 00:00:00 2001 From: Samuel A Date: Tue, 7 Jul 2020 01:07:51 -0500 Subject: [PATCH 32/96] updates template to support change the html window title in addition to the title on the page --- embed_assets/test_report.html.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embed_assets/test_report.html.template b/embed_assets/test_report.html.template index 7f61c3b..86e0bdd 100644 --- a/embed_assets/test_report.html.template +++ b/embed_assets/test_report.html.template @@ -2,7 +2,7 @@ - go-test-report + {{.ReportTitle}}