Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

31
test/fixtures/process/before-exit.mjs vendored Normal file
View File

@ -0,0 +1,31 @@
import { strictEqual } from 'assert'
function setup() {
const obj = { foo: 'bar' }
process.finalization.registerBeforeExit(obj, shutdown)
}
let shutdownCalled = false
let timeoutFinished = false
function shutdown(obj, event) {
shutdownCalled = true
if (event === 'beforeExit') {
setTimeout(function () {
timeoutFinished = true
strictEqual(obj.foo, 'bar')
process.finalization.unregister(obj)
}, 100)
process.on('beforeExit', function () {
strictEqual(timeoutFinished, true)
})
} else {
throw new Error(`different event, expected beforeExit but got ${event}`)
}
}
setup()
process.on('exit', function () {
strictEqual(shutdownCalled, true)
})

18
test/fixtures/process/close.mjs vendored Normal file
View File

@ -0,0 +1,18 @@
import { strictEqual } from 'assert'
function setup() {
const obj = { foo: 'bar' }
process.finalization.register(obj, shutdown)
}
let shutdownCalled = false
function shutdown(obj) {
shutdownCalled = true
strictEqual(obj.foo, 'bar')
}
setup()
process.on('exit', function () {
strictEqual(shutdownCalled, true)
})

View File

@ -0,0 +1,15 @@
import { isMainThread, Worker } from 'node:worker_threads';
if (isMainThread) {
process.finalization.register({ foo: 'foo' }, () => {
process.stdout.write('shutdown on main thread\n');
});
const worker = new Worker(import.meta.filename);
worker.postMessage('ping');
} else {
process.finalization.register({ foo: 'bar' }, () => {
process.stdout.write('shutdown on worker\n');
});
}

21
test/fixtures/process/gc-not-close.mjs vendored Normal file
View File

@ -0,0 +1,21 @@
import { strictEqual } from 'assert'
function setup() {
let obj = { foo: 'bar' }
process.finalization.register(obj, shutdown)
setImmediate(function () {
obj = undefined
gc()
})
}
let shutdownCalled = false
function shutdown(obj) {
shutdownCalled = true
}
setup()
process.on('exit', function () {
strictEqual(shutdownCalled, false)
})

21
test/fixtures/process/unregister.mjs vendored Normal file
View File

@ -0,0 +1,21 @@
import { strictEqual } from 'assert'
function setup() {
const obj = { foo: 'bar' }
process.finalization.register(obj, shutdown)
setImmediate(function () {
process.finalization.unregister(obj)
process.finalization.unregister(obj) // twice, this should not throw
})
}
let shutdownCalled = false
function shutdown(obj) {
shutdownCalled = true
}
setup()
process.on('exit', function () {
strictEqual(shutdownCalled, false)
})