Skip to content

Commit 5f40814

Browse files
authored
test: enable jsr and integration test suites (google#1087)
* test: enable jsr and integration test suites * ci: move jsr test to fast group
1 parent 3419ab6 commit 5f40814

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

.github/workflows/test.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ jobs:
3838
checks:
3939
needs: build
4040
runs-on: ubuntu-latest
41-
env:
42-
FORCE_COLOR: 3
4341
steps:
4442
- uses: actions/checkout@v4
4543
with:
@@ -71,6 +69,13 @@ jobs:
7169
- name: Circular
7270
run: npm run test:circular
7371

72+
- name: Bundles
73+
run: npm run test:it
74+
timeout-minutes: 1
75+
76+
- name: JSR dry-run
77+
run: npm run test:jsr
78+
7479
test:
7580
needs: build
7681
runs-on: ubuntu-latest

src/cli.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
import { installDeps, parseDeps } from './deps.js'
3333
import { startRepl } from './repl.js'
3434
import { randomId, bufToString } from './util.js'
35-
import { createRequire } from './vendor.js'
35+
import { createRequire, type minimist } from './vendor.js'
3636

3737
const EXT = '.mjs'
3838

@@ -78,7 +78,7 @@ export function printUsage() {
7878
}
7979

8080
// prettier-ignore
81-
export const argv = parseArgv(process.argv.slice(2), {
81+
export const argv: minimist.ParsedArgs = parseArgv(process.argv.slice(2), {
8282
string: ['shell', 'prefix', 'postfix', 'eval', 'cwd', 'ext', 'registry', 'env'],
8383
boolean: ['version', 'help', 'quiet', 'verbose', 'install', 'repl', 'experimental', 'prefer-local'],
8484
alias: { e: 'eval', i: 'install', v: 'version', h: 'help', l: 'prefer-local', 'env-file': 'env' },
@@ -87,7 +87,7 @@ export const argv = parseArgv(process.argv.slice(2), {
8787
camelCase: true,
8888
})
8989

90-
export async function main() {
90+
export async function main(): Promise<void> {
9191
await import('./globals.js')
9292
argv.ext = normalizeExt(argv.ext)
9393
if (argv.cwd) $.cwd = argv.cwd
@@ -205,7 +205,7 @@ async function readScriptFromHttp(remote: string): Promise<string> {
205205
return res.text()
206206
}
207207

208-
export function injectGlobalRequire(origin: string) {
208+
export function injectGlobalRequire(origin: string): void {
209209
const __filename = path.resolve(origin)
210210
const __dirname = path.dirname(__filename)
211211
const require = createRequire(origin)

src/core.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
451451
}
452452

453453
// Getters
454-
get id() {
454+
get id(): string {
455455
return this._id
456456
}
457457

@@ -617,7 +617,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
617617
}
618618

619619
// Async iterator API
620-
async *[Symbol.asyncIterator]() {
620+
async *[Symbol.asyncIterator](): AsyncIterator<string> {
621621
let last: string | undefined
622622
const getLines = (chunk: Buffer | string) => {
623623
const lines = ((last || '') + bufToString(chunk)).split('\n')
@@ -918,7 +918,7 @@ export function resolveDefaults(
918918
defs: Options = defaults,
919919
prefix: string = ENV_PREFIX,
920920
env = process.env
921-
) {
921+
): Options {
922922
const allowed = new Set([
923923
'cwd',
924924
'preferLocal',

src/error.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const formatExitMessage = (
185185
signal: NodeJS.Signals | null,
186186
stderr: string,
187187
from: string
188-
) => {
188+
): string => {
189189
let message = `exit code: ${code}`
190190
if (code != 0 || signal != null) {
191191
message = `${stderr || '\n'} at ${from}`
@@ -203,7 +203,7 @@ export const formatExitMessage = (
203203
export const formatErrorMessage = (
204204
err: NodeJS.ErrnoException,
205205
from: string
206-
) => {
206+
): string => {
207207
return (
208208
`${err.message}\n` +
209209
` errno: ${err.errno} (${getErrnoMessage(err.errno)})\n` +
@@ -212,11 +212,11 @@ export const formatErrorMessage = (
212212
)
213213
}
214214

215-
export function getCallerLocation(err = new Error('zx error')) {
215+
export function getCallerLocation(err = new Error('zx error')): string {
216216
return getCallerLocationFromString(err.stack)
217217
}
218218

219-
export function getCallerLocationFromString(stackString = 'unknown') {
219+
export function getCallerLocationFromString(stackString = 'unknown'): string {
220220
return (
221221
stackString
222222
.split(/^\s*(at\s)?/m)

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export {
2929
glob as globby,
3030
} from './vendor.js'
3131

32-
export const VERSION = fs.readJsonSync(
32+
export const VERSION: string = fs.readJsonSync(
3333
new URL('../package.json', import.meta.url)
3434
).version
35-
export const version = VERSION
35+
export const version: string = VERSION
3636

3737
export {
3838
type Duration,

test/it/build-jsr.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ describe('jsr artifact', () => {
4545
})
4646
after(() => fs.remove(tmp))
4747

48-
it('publish --dry-run --allow-dirty`', async () => {
48+
it('publish --dry-run`', async () => {
4949
await t$`node scripts/build-jsr.mjs`
50-
await t$({ quiet: false })`jsr publish --dry-run --allow-dirty`
50+
await t$({ quiet: false })`jsr publish --dry-run`
5151
})
5252
})

0 commit comments

Comments
 (0)