MCPcopy
hub / github.com/ampproject/amphtml / getUnitTestsToRun

Function getUnitTestsToRun

build-system/tasks/runtime-test/helpers-unit.js:145–178  ·  view source on GitHub ↗

* Computes the list of unit tests to run under difference scenarios * @return {Array |void}

()

Source from the content-addressed store, hash-verified

143 * @return {Array<string>|void}
144 */
145function getUnitTestsToRun() {
146 log(green('INFO:'), 'Determining which unit tests to run...');
147
148 if (isLargeRefactor()) {
149 log(
150 green('INFO:'),
151 'Skipping tests on local changes because this is a large refactor.'
152 );
153 return;
154 }
155
156 const tests = unitTestsToRun();
157 if (tests.length == 0) {
158 log(
159 green('INFO:'),
160 'No unit tests were directly affected by local changes.'
161 );
162 return;
163 }
164 if (isCiBuild() && tests.length > TEST_FILE_COUNT_THRESHOLD) {
165 log(
166 green('INFO:'),
167 'Several tests were affected by local changes. Running all tests below.'
168 );
169 return;
170 }
171
172 log(green('INFO:'), 'Running the following unit tests:');
173 tests.forEach((test) => {
174 log(cyan(test));
175 });
176
177 return tests;
178}
179
180/**
181 * Extracts the list of unit tests to run based on the changes in the local

Callers 1

unitFunction · 0.85

Calls 7

greenFunction · 0.85
isLargeRefactorFunction · 0.85
unitTestsToRunFunction · 0.85
isCiBuildFunction · 0.85
cyanFunction · 0.85
logFunction · 0.50
forEachMethod · 0.45

Tested by

no test coverage detected