@@ -2,7 +2,7 @@ import { symlinkSync } from 'node:fs';
22import path from 'node:path' ;
33import { expect , rs , test } from 'rstack/test' ;
44import { discoverFmtPaths } from '../../src/fmt/discoverPaths.ts' ;
5- import { loadNativeBinding } from '../../src/native/index.ts' ;
5+ import * as nativeBinding from '../../src/native/index.ts' ;
66import { withTempProject , writeProjectFile } from './helpers.ts' ;
77
88const relativePaths = ( rootPath : string , files : string [ ] ) : string [ ] =>
@@ -166,40 +166,21 @@ test('keeps valid nested gitignore rules around normalized and malformed lines',
166166 } ) ;
167167} ) ;
168168
169- test . sequential ( 'propagates errors while loading a nested gitignore' , async ( ) => {
169+ test ( 'propagates native binding errors while loading a nested gitignore' , async ( ) => {
170170 await withTempProject ( async ( rootPath ) => {
171171 writeProjectFile ( rootPath , 'src/.gitignore' , '*.js\n' ) ;
172172 writeProjectFile ( rootPath , 'src/index.js' ) ;
173- const nativeError = new Error ( 'Failed to add nested gitignore source ' ) ;
174- const addSource = rs
175- . spyOn ( loadNativeBinding ( ) . GitIgnoreMatcher . prototype , 'addSource ' )
173+ const nativeError = new Error ( 'Failed to load native binding ' ) ;
174+ const loadNativeBinding = rs
175+ . spyOn ( nativeBinding , 'loadNativeBinding ' )
176176 . mockImplementation ( ( ) => {
177177 throw nativeError ;
178178 } ) ;
179179
180180 try {
181181 await expect ( discoverFmtPaths ( { cwd : rootPath } ) ) . rejects . toBe ( nativeError ) ;
182182 } finally {
183- addSource . mockRestore ( ) ;
184- }
185- } ) ;
186- } ) ;
187-
188- test . sequential ( 'propagates errors from batched native gitignore matching' , async ( ) => {
189- await withTempProject ( async ( rootPath ) => {
190- writeProjectFile ( rootPath , '.gitignore' , '*.js\n' ) ;
191- writeProjectFile ( rootPath , 'index.js' ) ;
192- const nativeError = new Error ( 'Failed to match gitignore entries' ) ;
193- const matchBatch = rs
194- . spyOn ( loadNativeBinding ( ) . GitIgnoreMatcher . prototype , 'isIgnoredBatchMask' )
195- . mockImplementation ( ( ) => {
196- throw nativeError ;
197- } ) ;
198-
199- try {
200- await expect ( discoverFmtPaths ( { cwd : rootPath } ) ) . rejects . toBe ( nativeError ) ;
201- } finally {
202- matchBatch . mockRestore ( ) ;
183+ loadNativeBinding . mockRestore ( ) ;
203184 }
204185 } ) ;
205186} ) ;
0 commit comments