2018-06-21 01:10:22 +02:00
|
|
|
# Description:
|
|
|
|
# shows integrity tests coverage
|
|
|
|
#
|
|
|
|
# Dependencies:
|
|
|
|
# None
|
|
|
|
#
|
|
|
|
# Configuration:
|
|
|
|
# None
|
|
|
|
#
|
|
|
|
# Commands:
|
|
|
|
# hubot (mostrami la) copertura (dei test)
|
|
|
|
#
|
|
|
|
# Author:
|
|
|
|
# Enrico Fasoli (fazo96)
|
|
|
|
|
|
|
|
moment = require 'moment'
|
|
|
|
path = require 'path'
|
|
|
|
fs = require 'fs'
|
|
|
|
|
|
|
|
module.exports = (robot) ->
|
|
|
|
robot.respond /(?:mostrami la )?(?:copertura|coverage)(?: dei test)?/i, (res) ->
|
2018-06-21 03:30:24 +02:00
|
|
|
url = 'https://maxwell.ydns.eu/asjon/report/coverage'
|
|
|
|
file = 'report/coverage/coverage-summary.json'
|
2018-06-21 01:10:22 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
report = JSON.parse (fs.readFileSync file, 'utf8')
|
|
|
|
catch err
|
|
|
|
if err.code is 'ENOENT'
|
|
|
|
return res.send 'report non disponibile. forse \
|
|
|
|
non รจ ancora stato generato?'
|
|
|
|
else
|
|
|
|
return res.send "errore nel leggere il report:\n#{err}"
|
|
|
|
|
|
|
|
files = []
|
|
|
|
for name, file of report
|
|
|
|
if name isnt "total"
|
|
|
|
files.push "- #{path.basename name} is covered at #{file.lines.pct}%"
|
|
|
|
|
|
|
|
res.send """
|
|
|
|
=== Coverage: #{report.total.lines.pct}%
|
|
|
|
#{files.join '\n'}
|
|
|
|
|
|
|
|
HTML report: #{url}
|
2018-06-21 03:30:24 +02:00
|
|
|
JSON report: #{url}/coverage-summary.json
|
2018-06-21 01:10:22 +02:00
|
|
|
"""
|