Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/test/native.mts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { SEA_VERSION } from '../../src/sea/version.mts'

import type { SpawnSyncOptions } from 'node:child_process'
import { spawnSync } from 'node:child_process'
import { createHash } from 'node:crypto'
Expand All @@ -8,7 +10,6 @@ import process from 'node:process'
import { isMainModule } from '../lib/is-main-module.mts'
import type { ScriptMeta } from '../lib/run-main.mts'
import { runMain } from '../lib/run-main.mts'
import { SEA_VERSION } from '../../src/sea/version.mts'
import { assertSnapshotDependenciesCurrent } from '../refresh/snapshots/dependencies.mts'
import {
persistNativeSigningReceipt,
Expand Down Expand Up @@ -73,10 +74,10 @@ async function verifyArtifact(
const manifest = JSON.parse(manifestText) as NativeManifest
if (
manifest.application?.name !== packageInfo.name ||
manifest.application?.version !== packageInfo.version
manifest.application?.version !== SEA_VERSION
) {
throw new Error(
`Native manifest is for ${manifest.application?.name}@${manifest.application?.version}; expected ${packageInfo.name}@${packageInfo.version}`,
`Native manifest is for ${manifest.application?.name}@${manifest.application?.version}; expected ${packageInfo.name}@${SEA_VERSION}`,
)
}
if (manifest.target?.triple !== TRIPLE) {
Expand Down
1 change: 1 addition & 0 deletions src/commands/manifest/cmd-manifest-cdxgen.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('socket manifest cdxgen', async () => {
'`socket manifest cdxgen`',
)
},
{ timeout: 60_000 },
)

it.skipIf(process.platform === 'win32')(
Expand Down
9 changes: 6 additions & 3 deletions src/utils/glob.mts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ export async function globWithGitIgnore(
]
: [...ignores, ...cliMinimatchIgnores].map(stripTrailingSlash),
...additionalOptions,
// fast-glob's uniqueness set retains every match before the streaming
// filter runs. Filtered scans deduplicate only supported paths below.
unique: filter ? false : additionalOptions.unique,
// Skip dirs the running user cannot read instead of aborting on the first
// `EACCES`. Pinned after `...additionalOptions` so a caller's options bag
// cannot flip it off; it is a safety invariant, not a tunable.
Expand Down Expand Up @@ -483,7 +486,7 @@ export async function globWithGitIgnore(
// optional caller filter drops non-matches before they accumulate. On the slow
// path each surviving entry is also re-checked against its gitignore ancestor
// chain, which carries the full negation support fast-glob lacks.
const results: string[] = []
const results = new Set<string>()
const stream = fastGlob.globStream(
patterns as string[],
globOptions,
Expand All @@ -502,9 +505,9 @@ export async function globWithGitIgnore(
if (filter && !filter(p)) {
continue
}
results.push(p)
results.add(p)
}
return results
return [...results]
}

export async function globWorkspace(
Expand Down
40 changes: 39 additions & 1 deletion src/utils/glob.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import os from 'node:os'
import path from 'node:path'

import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import fastGlob from 'fast-glob'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

import { normalizePath } from '@socketsecurity/registry/lib/path'

Expand Down Expand Up @@ -170,6 +171,43 @@ describe('glob utilities', () => {
])
})

it('disables fast-glob uniqueness when filtering', async () => {
mockTestFs({ [`${mockFixturePath}/package.json`]: '{}' })
const globStreamSpy = vi.spyOn(fastGlob, 'globStream')

try {
await globWithGitIgnore(['**/*'], {
cwd: mockFixturePath,
filter: filterJsonFiles,
})

expect(globStreamSpy).toHaveBeenLastCalledWith(
['**/*'],
expect.objectContaining({ unique: false }),
)
} finally {
globStreamSpy.mockRestore()
}
})

it('deduplicates overlapping matches after filtering', async () => {
mockTestFs({
[`${mockFixturePath}/package.json`]: '{}',
[`${mockFixturePath}/src/package.json`]: '{}',
[`${mockFixturePath}/src/readme.md`]: '',
})

const results = await globWithGitIgnore(['**/*.json', 'src/**/*'], {
cwd: mockFixturePath,
filter: filterJsonFiles,
})

expect(results.map(normalizePath).sort()).toEqual([
`${mockFixturePath}/package.json`,
`${mockFixturePath}/src/package.json`,
])
})

it('should skip directories ignored via trailing-slash patterns', async () => {
// fast-glob silently drops `ignore` entries that end in `/`, so
// the pattern produced for `dist/` (`**/dist/`) used to do
Expand Down
8 changes: 6 additions & 2 deletions test/release-workflow.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,13 @@ describe('v1 release workflow contract', () => {
const manifest = JSON.parse(
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
) as { publishConfig?: { tag?: string }; version?: string }
// The stable v1 lane and the 2.1 prerelease lane both write this version.
const releasePolicy = JSON.parse(
readFileSync(new URL('../.config/release.json', import.meta.url), 'utf8'),
) as { identifier: string; versionHint: string }
expect(manifest.version).toMatch(/^(?:1\.\d+\.\d+|2\.1\.0-rc\.\d+)$/u)
expect(manifest.publishConfig?.tag).toBe('rc-2.1.0')
expect(manifest.publishConfig?.tag).toBe(
`${releasePolicy.identifier}-${releasePolicy.versionHint}`,
)
expect(workflow.on.workflow_dispatch.inputs['release-major']?.default).toBe(
'1',
)
Expand Down
Loading