fix memleaks ci pipeline

This commit is contained in:
Mark Silverwood 2023-01-05 13:14:41 +00:00
parent 5d6453a363
commit 6e79b95162
5 changed files with 27 additions and 9 deletions

View File

@ -205,6 +205,7 @@ jobs:
environment:
NO_SANDBOX: "true"
TESTS_REPORT_FILE: "test-results/memleaks/results.xml"
RUNNING_ON_CI: "true"
steps:
- checkout-with-deps
- attach_workspace:
@ -216,6 +217,8 @@ jobs:
- run: scripts/run-memleaks-tests.sh
- store_test_results:
path: test-results/
- store_artifacts:
path: tests/e2e/memleaks/.logs/
coverage:
executor: node16-browsers-executor

3
.gitignore vendored
View File

@ -34,3 +34,6 @@ debug.html
# graphics tests out data
/tests/e2e/graphics/.gendata/
tests/e2e/coverage/.gendata
# memleak log output
tests/e2e/memleaks/.logs/

View File

@ -2,7 +2,14 @@
set -e
echo "Preparing"
npm run build
# npm run build
echo "Memleaks tests"
node ./tests/e2e/memleaks/runner.js ./dist/lightweight-charts.standalone.development.js
if [[ ! -z "$RUNNING_ON_CI" ]]; then
echo "Running on CI, therefore logging mem leaks output to artifact file"
rm -rf tests/e2e/memleaks/.logs
mkdir tests/e2e/memleaks/.logs
node ./tests/e2e/memleaks/runner.js ./dist/lightweight-charts.standalone.development.js > ./tests/e2e/memleaks/.logs/memleaks.txt
else
node ./tests/e2e/memleaks/runner.js ./dist/lightweight-charts.standalone.development.js
fi

View File

@ -4,7 +4,7 @@ import { expect } from 'chai';
import { describe, it } from 'mocha';
import { getClassNames } from './helpers/get-all-class-names';
import { getTestCases, TestCase } from './helpers/get-test-cases';
import { getTestCases } from './helpers/get-test-cases';
const serverAddressVarName = 'SERVER_ADDRESS';
const serverURL: string = process.env[serverAddressVarName] || '';
@ -26,9 +26,7 @@ describe('Memleaks tests', function(): void {
// this tests are unstable sometimes.
this.retries(0);
const testCases = getTestCases().filter((testCase: TestCase) => {
return testCase.name === 'simple';
});
const testCases = getTestCases();
it('number of test cases', () => {
// we need to have at least 1 test to check it
@ -42,7 +40,7 @@ describe('Memleaks tests', function(): void {
for (const testCase of testCases) {
it(testCase.name, async () => {
console.log(`Running test: ${testCase.name}`);
console.log(`\n\tRunning test: ${testCase.name}`);
if (classNames.size < 1) {
// async function that we will only call if we don't already have values
const names = await getClassNames();
@ -62,7 +60,7 @@ describe('Memleaks tests', function(): void {
const expectToFail = scenario.expectFail === true;
const allowedLeaks = scenario.allowedLeaks ?? [];
if (expectToFail) {
console.log(`!! This test is expected to fail.`);
console.log(`\t!! This test is expected to fail.`);
}
console.log('');
@ -76,6 +74,9 @@ describe('Memleaks tests', function(): void {
!allowedLeaks.includes(node.name)) ||
node.retainedSize > 1_000_000
) {
if (!expectToFail) {
console.log(`LEAK FOUND! Name of constructor: ${node.name} Retained Size: ${node.retainedSize}`);
}
return true; // This is considered to be a leak.
}
return false;

View File

@ -6,7 +6,11 @@
/** @type {import('@memlab/core/dist/lib/Types').IScenario} */
const scenario = {
allowedLeaks: ['FormattedLabelsCache'],
allowedLeaks: [
'FormattedLabelsCache',
'CrosshairPriceAxisView', // <- We should check and maybe fix this?
'PriceAxisViewRenderer', // <- (part of the same leak above)
],
setup: async function(page) {
await page.addScriptTag({
url: 'library.js',