Skip to content

Commit

Permalink
build: restrict coverage filter and guard against division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Aug 13, 2023
1 parent cf58c6f commit 874a610
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 29 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/scripts/run_tests_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ main() {
# For each package, extract coverage values from the respective coverage report:
pkg=`echo $package | sed -E 's/^.*stdlib\///'`

make test-javascript-cov TESTS_FILTER=".*/${pkg}/.*"
make test-javascript-cov TESTS_FILTER=".*/${pkg}/test/.*"

if [ ! -f reports/coverage/lcov-report/${pkg}/lib/index.html ]; then
# Reports for packages with no dependencies are stored in the `lcov-report` directory
Expand All @@ -171,7 +171,7 @@ main() {
coverage_path="reports/coverage/lcov-report/${pkg}/lib/index.html"
top_level_report=false
fi
pkg_cov_values=($(cat $coverage_path | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{print $1/$2}'))
pkg_cov_values=($(cat $coverage_path | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{if ($2 != 0) print $1/$2; else print 1}'))
pkg_statements_cov=${pkg_cov_values[0]}
pkg_branches_cov=${pkg_cov_values[1]}
pkg_functions_cov=${pkg_cov_values[2]}
Expand All @@ -190,7 +190,7 @@ main() {
old_functions_cov=0
old_lines_cov=0
else
old_cov_values=($(echo "$old_cov_report" | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{print $1/$2}'))
old_cov_values=($(echo "$old_cov_report" | grep "fraction" | grep -oP '\d+/\d+' | awk -F'/' '{if ($2 != 0) print $1/$2; else print 1}'))
old_statements_cov=${old_cov_values[0]}
old_branches_cov=${old_cov_values[1]}
old_functions_cov=${old_cov_values[2]}
Expand All @@ -204,8 +204,8 @@ main() {

pkg_cov="| $pkg_statements_cov_fraction <br> $cov_change_statements | $pkg_branches_cov_fraction <br> $cov_change_branches | $pkg_functions_cov_fraction <br> $cov_change_functions | $pkg_lines_cov_fraction <br> $cov_change_lines |"

pkg_url="https://coverage.stdlib.io/${pkg}"
pkg_link="<a href='"$pkg_url"'>$pkg</a>"
pkg_url="https://coverage.stdlib.io/${pkg}/lib/index.html"
pkg_link="<a href="$pkg_url">$pkg</a>"
coverage="$coverage\n| $pkg_link $pkg_cov"

# Copy coverage report of the package to artifacts directory:
Expand All @@ -214,7 +214,7 @@ main() {
else
mkdir -p "artifacts/${pkg}/lib/" && cp -r "reports/coverage/lcov-report/${pkg}/lib"/* "artifacts/${pkg}/lib/"
fi

# Cleanup coverage reports for next package:
rm -rf reports/coverage/lcov-report/*
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ var create = require( './../lib/cache.js' );

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof create, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof checklimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var info = require( './fixtures/info.json' );

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof factory, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var flatten = require( './../lib/flatten.js' );

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof flatten, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var lastPage = require( './../lib/lastpage.js' );

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof lastPage, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof ratelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function setup() {

// TESTS //

tape( 'the main export is a function', function test( t ) {
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof updatelimit, 'function', 'main export is a function' );
t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var RE_CLIP_PATH_CLOSE = /<\/clip-path>/g;
*
* - **WARNING**: this function is ad-hoc, undoubtedly not comprehensive, and will inevitably have to be updated as additional issues arise.
*
*
* @private
* @param {string} html - HTML to process
* @returns {string} output HTML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

'use strict';

/*
/**
* Regular expression to match a relative require/import literal.
*
* ## Examples
Expand Down Expand Up @@ -72,7 +72,6 @@
* - `)`
* - end of capture (1)
*
*
* @private
* @constant
* @type {RegExp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ var fopts = {
*
* - Needless to say, the articulation of field paths makes considerable assumptions regarding program summary structure. As such, this algorithm should not be considered sufficiently general purpose and most likely would need to be refashioned should upstream changes be made in terms of result layout.
*
*
* @private
* @param {Object} state - accumulator state
* @param {Object} engine - accumulator engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var FLOAT64_HIGH_WORD_ABS_MASK = require( './../lib' ); // eslint-disable-line i

// TESTS //

tape( 'the main export is a number', function test( t ) {
tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT64_HIGH_WORD_ABS_MASK, 'number', 'main export is a number' );
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var FLOAT64_HIGH_WORD_EXPONENT_MASK = require( './../lib' );

// TESTS //

tape( 'the main export is a number', function test( t ) {
tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT64_HIGH_WORD_EXPONENT_MASK, 'number', 'main export is a number' );
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var FLOAT64_HIGH_WORD_SIGN_MASK = require( './../lib' ); // eslint-disable-line

// TESTS //

tape( 'the main export is a number', function test( t ) {
tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT64_HIGH_WORD_SIGN_MASK, 'number', 'main export is a number' );
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var FLOAT64_HIGH_WORD_SIGNIFICAND_MASK = require( './../lib' );

// TESTS //

tape( 'the main export is a number', function test( t ) {
tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT64_HIGH_WORD_SIGNIFICAND_MASK, 'number', 'main export is a number' );
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var FLOAT64_SMALLEST_SUBNORMAL = require( './../lib' );

// TESTS //

tape( 'the main export is a number', function test( t ) {
tape( 'main export is a number', function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof FLOAT64_SMALLEST_SUBNORMAL, 'number', 'main export is a number' );
t.end();
Expand Down

0 comments on commit 874a610

Please sign in to comment.