import json import subprocess from test_est_native_export import ROOT, fixture def test_missing_index_preserves_original_but_blocks_modified_export(tmp_path): source = tmp_path / "source.estx" fixture(source) script = """const fs=require('fs'),m=require('./tools/est-test/import-estx.cjs'), e=require('./tools/est-test/export-estx.cjs'),a=require('./tools/est-test/archive.cjs'); const files=m.unzip(fs.readFileSync(process.argv[1]));files.delete('estmaindat.idx'); const original=a.pack(files),p=m.importEstx(original),unchanged=e.exportEstx(p).equals(original); p.tables.EstMainDat[0].GN=3;let error='';try{e.exportEstx(p)}catch(err){error=err.message} process.stdout.write(JSON.stringify({unchanged,error}));""" result = json.loads(subprocess.check_output(["node", "-e", script, str(source)], cwd=ROOT)) assert result["unchanged"] assert "인덱스 파일이 없어" in result["error"]