Skip to content

Commit

Permalink
test: Disable tests of cache on Windows because of EPERM
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Mar 31, 2024
1 parent 0d5ba64 commit a1d221a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function unpack(archive, targetDirectory) {
}

async function makeExecutable(executable) {
if (platform != 'win32') {
if (platform !== 'win32') {
log('make "%s" executable', executable)
await chmod(executable, 0o755)
}
Expand Down
68 changes: 36 additions & 32 deletions test/mocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { arch, platform } = process

const repository = 'prantlf/v-jsonlint'
const name = 'jsonlint'
const executable = join('.', platform != 'win32' ? name : `${name}.exe`)
const executable = join('.', platform !== 'win32' ? name : `${name}.exe`)
const version = '0.0.6'
const platformSuffixes = {
linux: ['linux'],
Expand All @@ -35,7 +35,7 @@ const cacheDirectory = join(wholeCacheDirectory, name)

async function cleanup() {
// failed on Windows on GitHub
if (platform == 'win32') return
if (platform === 'win32') return
await Promise.all([
rm(archive, { force: true }),
rm(executable, { force: true }),
Expand Down Expand Up @@ -145,15 +145,17 @@ test('download archive from the latest fixed version with a guessed name', async
strictEqual(actualArchive, archive)
})

test('download archive from the latest implicit version and unpack executable', async () => {
const { executable: actualExecutable, version: actualVersion } = await grab({
name, repository, unpackExecutable: true, verbose: true
if (platform !== 'win32') {
test('download archive from the latest implicit version and unpack executable', async () => {
const { executable: actualExecutable, version: actualVersion } = await grab({
name, repository, unpackExecutable: true, verbose: true
})
ok(!await exists(archive), 'archive found')
ok(await exists(executable), 'executable not found')
strictEqual(actualVersion, version)
strictEqual(actualExecutable, executable)
})
ok(!await exists(archive), 'archive found')
ok(await exists(executable), 'executable not found')
strictEqual(actualVersion, version)
strictEqual(actualExecutable, executable)
})
}

test('download archive from the latest implicit version and unpack executable to a custom directory', async () => {
await mkdir(targetDirectory, { recursive: true })
Expand All @@ -165,28 +167,30 @@ test('download archive from the latest implicit version and unpack executable to
ok(actualExecutable.endsWith(executable))
})

test('copy archive of the latest implicit version from cache and unpack executable to a custom directory', async () => {
await mkdir(targetDirectory, { recursive: true })
await grab({ name, repository, targetDirectory, unpackExecutable: true })
const { executable: actualExecutable, version: actualVersion } = await grab({
name, repository, targetDirectory, unpackExecutable: true
if (platform !== 'win32') {
test('copy archive of the latest implicit version from cache and unpack executable to a custom directory', async () => {
await mkdir(targetDirectory, { recursive: true })
await grab({ name, repository, targetDirectory, unpackExecutable: true })
const { executable: actualExecutable, version: actualVersion } = await grab({
name, repository, targetDirectory, unpackExecutable: true
})
ok(await exists(actualExecutable), 'executable not found')
strictEqual(actualVersion, version)
ok(actualExecutable.endsWith(executable))
})
ok(await exists(actualExecutable), 'executable not found')
strictEqual(actualVersion, version)
ok(actualExecutable.endsWith(executable))
})

test('clear cache for a name', async () => {
await grab({ repository, version })
ok(await exists(cacheDirectory), 'cache not found')
await clearCache({ name, verbose: true })
ok(!await exists(cacheDirectory), 'cache found')
ok(await exists(wholeCacheDirectory), 'whole cache not found')
})
test('clear cache for a name', async () => {
await grab({ repository, version })
ok(await exists(cacheDirectory), 'cache not found')
await clearCache({ name, verbose: true })
ok(!await exists(cacheDirectory), 'cache found')
ok(await exists(wholeCacheDirectory), 'whole cache not found')
})

test('clear the whole cache', async () => {
await grab({ repository, version })
ok(await exists(cacheDirectory), 'cache not found')
await clearCache()
ok(!await exists(wholeCacheDirectory), 'whole cache found')
})
test('clear the whole cache', async () => {
await grab({ repository, version })
ok(await exists(cacheDirectory), 'cache not found')
await clearCache()
ok(!await exists(wholeCacheDirectory), 'whole cache found')
})
}

0 comments on commit a1d221a

Please sign in to comment.