Skip to content

Commit

Permalink
chore: modify log prefixes slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed May 23, 2024
1 parent d017874 commit 03ac442
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions packages/gateway-conformance/src/conformance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { expect } from 'aegir/chai'
import { execa } from 'execa'
import { Agent, setGlobalDispatcher } from 'undici'

const logger = prefixLogger('conformance-tests')
const logger = prefixLogger('gateway-conformance')

interface TestConfig {
name: string
Expand Down Expand Up @@ -334,16 +334,21 @@ describe('@helia/verified-fetch - gateway conformance', function () {

after(async () => {
const log = logger.forComponent('after')
try {
await execa('rm', [binaryPath])
log('gateway-conformance binary successfully uninstalled.')
} catch (error) {
log.error(`Error removing "${binaryPath}"`, error)

if (process.env.GATEWAY_CONFORMANCE_BINARY == null) {
try {
await execa('rm', [binaryPath])
log('gateway-conformance binary successfully uninstalled.')
} catch (error) {
log.error(`Error removing "${binaryPath}"`, error)
}
} else {
log('Not removing custom gateway-conformance binary at %s', binaryPath)
}
})

tests.forEach(({ name, spec, skip, run, timeout, successRate: minSuccessRate }) => {
const log = logger.forComponent(name)
const log = logger.forComponent(`output:${name}`)
const expectedSuccessRate = process.env.SUCCESS_RATE != null ? Number.parseFloat(process.env.SUCCESS_RATE) : minSuccessRate

it(`${name} has a success rate of at least ${expectedSuccessRate}%`, async function () {
Expand Down Expand Up @@ -376,7 +381,7 @@ describe('@helia/verified-fetch - gateway conformance', function () {
*/
it('has expected total failures and successes', async function () {
this.timeout(200000)
const log = logger.forComponent('all')
const log = logger.forComponent('output:all')

const { stderr, stdout } = await execa(binaryPath, getConformanceTestArgs('all', [], []), { reject: false, cancelSignal: AbortSignal.timeout(200000) })

Expand Down
4 changes: 2 additions & 2 deletions packages/gateway-conformance/src/fixtures/basic-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ async function callVerifiedFetch (req: IncomingMessage, res: Response, { serverP

// @see https://github.com/ipfs/gateway-conformance/issues/185#issuecomment-2123708150
let fixingGwcAnnoyance = false
if (req.headers.host != null && (req.headers.host === 'localhost' || req.headers.Host === 'localhost')) {
log.trace('set fixingGwcAnnoyance to true for %s', req.url)
if (req.headers.host != null && req.headers.host === 'localhost') {
log.trace('set fixingGwcAnnoyance to true for %s', new URL(req.url, `http://${req.headers.host}`).href)
fixingGwcAnnoyance = true
req.headers.host = `localhost:${serverPort}`
}
Expand Down

0 comments on commit 03ac442

Please sign in to comment.