-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run time zone tests with Bun (#3680)
- Loading branch information
1 parent
f578327
commit 6f44a16
Showing
256 changed files
with
857 additions
and
349 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Time zone tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: oven-sh/setup-bun@v1 | ||
- run: bun install | ||
- run: bun ./scripts/test/tzOffset.ts | ||
- run: bun ./scripts/test/tzIANA.ts |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export function promiseQueue<Type>( | ||
promises: Array<() => Promise<Type>>, | ||
max: number, | ||
): Promise<Type[]> { | ||
const queue: Array<() => void> = []; | ||
|
||
const all = Promise.all<Type>( | ||
new Array(promises.length).fill(null).map((_, index) => { | ||
const promise = new Promise<void>((resolve) => { | ||
queue[index] = () => { | ||
// Trigger the queue promise | ||
resolve(); | ||
// Return it, so the worker function can wait for | ||
return promise; | ||
}; | ||
}).then(() => promises[index]()); | ||
return promise; | ||
}), | ||
); | ||
|
||
async function next() { | ||
const promise = queue.shift(); | ||
if (!promise) return; | ||
await promise(); | ||
return next(); | ||
} | ||
|
||
// Create the worker functions | ||
Promise.all(new Array(max).fill(null).map(() => next())); | ||
|
||
return all; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { $ } from "bun"; | ||
import { availableParallelism } from "node:os"; | ||
import { promiseQueue } from "./queue"; | ||
|
||
export async function testTimeZone(timeZone: string) { | ||
const { stderr, exitCode } = | ||
await $`TZ=${timeZone} bun test ./src/**/test.ts`.quiet(); | ||
|
||
if (exitCode) { | ||
console.log(stderr.toString()); | ||
console.log(`⛔ Tests for the time zone ${timeZone}`); | ||
process.exit(exitCode); | ||
} | ||
|
||
console.log(`✅ Tests for the time zone ${timeZone}`); | ||
} | ||
|
||
export function testTimeZones(timeZones: string[]) { | ||
return promiseQueue( | ||
timeZones.map((timeZone) => () => testTimeZone(timeZone)), | ||
availableParallelism(), | ||
); | ||
} |
Oops, something went wrong.