MCPcopy Index your code
hub / github.com/nodejs/node / createBuild

Method createBuild

lib/internal/test_runner/test.js:1777–1819  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1775 }
1776
1777 async createBuild() {
1778 const channelContext = {
1779 __proto__: null,
1780 name: this.name,
1781 nesting: this.nesting,
1782 file: this.entryFile,
1783 type: this.reportedType,
1784 };
1785 let publishEnd = () => testChannel.end.publish(channelContext);
1786 let publishError = (err) => testChannel.error.publish({ __proto__: null, ...channelContext, error: err });
1787
1788 try {
1789 const { ctx, args } = this.getRunArgs();
1790
1791 // Wrap the suite function with runStores if the channel has subscribers.
1792 // The wrapped function is what gets passed to runInAsyncScope, ensuring that
1793 // the suite runs within both the runStores context (for AsyncLocalStorage/bindStore)
1794 // AND the AsyncResource scope. It's critical that runStores wraps the function,
1795 // not the runInAsyncScope call itself, to maintain AsyncLocalStorage bindings.
1796 let suiteFn = this.fn;
1797 if (testChannel.start.hasSubscribers) {
1798 const baseFn = this.fn;
1799 suiteFn = (...fnArgs) => testChannel.start.runStores(channelContext, () => {
1800 publishEnd = AsyncResource.bind(publishEnd);
1801 publishError = AsyncResource.bind(publishError);
1802 return ReflectApply(baseFn, this, fnArgs);
1803 });
1804 }
1805
1806 const runArgs = [suiteFn, ctx];
1807 ArrayPrototypePushApply(runArgs, args);
1808
1809 await ReflectApply(this.runInAsyncScope, this, runArgs);
1810 } catch (err) {
1811 if (testChannel.error.hasSubscribers) {
1812 publishError(err);
1813 }
1814 this.fail(new ERR_TEST_FAILURE(err, kTestCodeFailure));
1815 }
1816
1817 this.#publishEnd = publishEnd;
1818 this.buildPhaseFinished = true;
1819 }
1820
1821 #publishEnd = null;
1822

Callers 1

constructorMethod · 0.95

Calls 4

getRunArgsMethod · 0.95
runStoresMethod · 0.45
bindMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected