feat(watchers): add Rust-powered watcher backend with runtime fallback and cross-platform test coverage
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartwatch from '../ts/index.js';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartrx from '@push.rocks/smartrx';
|
||||
|
||||
import * as fs from 'fs';
|
||||
@@ -52,7 +51,7 @@ tap.test('STRESS: rapid file modifications', async () => {
|
||||
const testFile = path.join(TEST_DIR, 'stress-rapid.txt');
|
||||
|
||||
// Create initial file
|
||||
await smartfile.memory.toFs('initial', testFile);
|
||||
await fs.promises.writeFile(testFile, 'initial');
|
||||
await delay(200);
|
||||
|
||||
const changeObservable = await testSmartwatch.getObservableFor('change');
|
||||
@@ -62,7 +61,7 @@ tap.test('STRESS: rapid file modifications', async () => {
|
||||
const eventCollector = collectEvents(changeObservable, 3000);
|
||||
|
||||
for (let i = 0; i < RAPID_CHANGES; i++) {
|
||||
await smartfile.memory.toFs(`content ${i}`, testFile);
|
||||
await fs.promises.writeFile(testFile, `content ${i}`);
|
||||
await delay(10); // 10ms between writes
|
||||
}
|
||||
|
||||
@@ -87,7 +86,7 @@ tap.test('STRESS: many files created rapidly', async () => {
|
||||
for (let i = 0; i < FILE_COUNT; i++) {
|
||||
const file = path.join(TEST_DIR, `stress-many-${i}.txt`);
|
||||
files.push(file);
|
||||
await smartfile.memory.toFs(`content ${i}`, file);
|
||||
await fs.promises.writeFile(file, `content ${i}`);
|
||||
await delay(20); // 20ms between creates
|
||||
}
|
||||
|
||||
@@ -116,7 +115,7 @@ tap.test('STRESS: interleaved add/change/delete operations', async () => {
|
||||
|
||||
// Create initial files
|
||||
for (const file of testFiles) {
|
||||
await smartfile.memory.toFs('initial', file);
|
||||
await fs.promises.writeFile(file, 'initial');
|
||||
}
|
||||
await delay(300);
|
||||
|
||||
@@ -129,13 +128,13 @@ tap.test('STRESS: interleaved add/change/delete operations', async () => {
|
||||
const unlinkEvents = collectEvents(unlinkObservable, 3000);
|
||||
|
||||
// Interleaved operations
|
||||
await smartfile.memory.toFs('changed 1', testFiles[0]); // change
|
||||
await fs.promises.writeFile(testFiles[0], 'changed 1'); // change
|
||||
await delay(50);
|
||||
await fs.promises.unlink(testFiles[1]); // delete
|
||||
await delay(50);
|
||||
await smartfile.memory.toFs('recreated 1', testFiles[1]); // add (recreate)
|
||||
await fs.promises.writeFile(testFiles[1], 'recreated 1'); // add (recreate)
|
||||
await delay(50);
|
||||
await smartfile.memory.toFs('changed 2', testFiles[2]); // change
|
||||
await fs.promises.writeFile(testFiles[2], 'changed 2'); // change
|
||||
await delay(50);
|
||||
|
||||
const [adds, changes, unlinks] = await Promise.all([addEvents, changeEvents, unlinkEvents]);
|
||||
|
||||
Reference in New Issue
Block a user