MCPcopy Create free account
hub / github.com/dataform-co/dataform / run

Method run

testing/test.ts:48–103  ·  view source on GitHub ↗
(ctx: IRunContext)

Source from the content-addressed store, hash-verified

46 constructor(public readonly options: ITestOptions, private readonly fn: () => any) {}
47
48 public async run(ctx: IRunContext) {
49 const path = [...ctx.path, this.options.name];
50 if (!path.join(" > ").match(ctx.testNameMatcher)) {
51 return;
52 }
53 const retries = this.options.retries || 0;
54 let lastResult: IRunResult;
55 for (let i = 0; i <= retries; i++) {
56 let timer: NodeJS.Timer;
57 const timeout = this.options.timeout || Test.DEFAULT_TIMEOUT_MILLIS;
58 const result: IRunResult = {
59 path,
60 outcome: "failed"
61 };
62 try {
63 await Promise.race([
64 (async () => {
65 const hookCtx = {
66 ...ctx,
67 path
68 };
69 for (const beforeEach of ctx.beforeEaches) {
70 await beforeEach.run(hookCtx);
71 }
72 try {
73 // Run the test.
74 await this.fn();
75 } finally {
76 // Always run the after eaches.
77 for (const afterEach of ctx.afterEaches) {
78 await afterEach.run(hookCtx);
79 }
80 }
81 })(),
82 new Promise((_, reject) => {
83 timer = setTimeout(() => {
84 result.outcome = "timeout";
85 reject(new Error(`Timed out (${timeout}ms).`));
86 }, timeout);
87 })
88 ]);
89 result.outcome = "passed";
90 } catch (e) {
91 result.err = e;
92 } finally {
93 clearTimeout(timer);
94 }
95
96 lastResult = result;
97 if (result.outcome === "passed") {
98 break;
99 }
100 }
101
102 ctx.results.push(lastResult);
103 }
104}

Callers 2

bigquery.spec.tsFile · 0.45
runMainInVmFunction · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected