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

Function fetchCoverage_

build-system/tasks/e2e/index.js:97–134  ·  view source on GitHub ↗

* Fetch aggregated coverage data from server. * @param {string} outDir relative path to coverage files directory. * @return {Promise }

(outDir)

Source from the content-addressed store, hash-verified

95 * @return {Promise<void>}
96 */
97async function fetchCoverage_(outDir) {
98 // Note: We could access the coverage UI directly through the server started
99 // for the e2e tests, but then that coverage data would vanish once that
100 // server instance was closed. This method will persist the coverage data so
101 // it can be accessed separately.
102
103 // Clear out previous coverage data.
104 fs.rmSync(outDir, {recursive: true});
105 fs.mkdirSync(outDir);
106
107 const zipFilename = path.join(outDir, 'coverage.zip');
108 const zipFile = fs.createWriteStream(zipFilename);
109
110 await /** @type {Promise<void>} */ (
111 new Promise((resolve, reject) => {
112 http
113 .get(
114 {
115 host: HOST,
116 port: PORT,
117 path: COV_DOWNLOAD_PATH,
118 },
119 (response) => {
120 response.pipe(zipFile);
121 zipFile.on('finish', () => {
122 zipFile.close();
123 resolve();
124 });
125 }
126 )
127 .on('error', (err) => {
128 fs.unlinkSync(zipFilename);
129 reject(err);
130 });
131 })
132 );
133 execOrDie(`unzip -o ${zipFilename} -d ${outDir}`);
134}
135
136/**
137 * Runs e2e tests on all files under test.

Callers 1

runTests_Function · 0.85

Calls 5

execOrDieFunction · 0.85
resolveFunction · 0.50
onMethod · 0.45
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected