feat: pass export tests

This commit is contained in:
Myriad-Dreamin 2025-06-29 13:13:51 +08:00
parent 93bb281ab3
commit 30186140dd
9 changed files with 32 additions and 20 deletions

View file

@ -340,8 +340,8 @@ struct TaggedMemoryEvent {
pub struct CompileServerOpts<F: CompilerFeat, Ext> {
/// The compilation handler.
pub handler: Arc<dyn CompileHandler<F, Ext>>,
/// Whether to enable file system watching.
pub enable_watch: bool,
/// Whether to ignoring the first fs sync event.
pub ignore_first_sync: bool,
/// Specifies the current export target.
pub export_target: ExportTarget,
}
@ -350,7 +350,7 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: 'static> Default for CompileS
fn default() -> Self {
Self {
handler: Arc::new(std::marker::PhantomData),
enable_watch: false,
ignore_first_sync: false,
export_target: ExportTarget::Paged,
}
}
@ -364,8 +364,8 @@ pub struct ProjectCompiler<F: CompilerFeat, Ext> {
export_target: ExportTarget,
/// Channel for sending interrupts to the compiler actor.
dep_tx: mpsc::UnboundedSender<NotifyMessage>,
/// Whether to enable file system watching.
pub enable_watch: bool,
/// Whether to ignore the first sync event.
pub ignore_first_sync: bool,
/// The current logical tick.
logical_tick: usize,
@ -389,7 +389,7 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: Default + 'static> ProjectCom
dep_tx: mpsc::UnboundedSender<NotifyMessage>,
CompileServerOpts {
handler,
enable_watch,
ignore_first_sync,
export_target,
}: CompileServerOpts<F, Ext>,
) -> Self {
@ -402,13 +402,13 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: Default + 'static> ProjectCom
Self {
handler,
dep_tx,
enable_watch,
export_target,
logical_tick: 1,
dirty_shadow_logical_tick: 0,
estimated_shadow_files: Default::default(),
ignore_first_sync,
primary,
deps: Default::default(),
@ -657,7 +657,7 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: Default + 'static> ProjectCom
// Apply file system changes.
let dirty_tick = &mut self.dirty_shadow_logical_tick;
let (changes, event) = event.split();
let (changes, watched, event) = event.split_with_is_sync();
let changes = std::iter::repeat_n(changes, 1 + self.dedicates.len());
let proj = std::iter::once(&mut self.primary).chain(self.dedicates.iter_mut());
@ -681,7 +681,7 @@ impl<F: CompilerFeat + Send + Sync + 'static, Ext: Default + 'static> ProjectCom
verse.vfs_changed()
});
if vfs_changed {
if vfs_changed && (!self.ignore_first_sync || !watched) {
proj.reason.see(reason_by_fs());
}
}

View file

@ -186,7 +186,7 @@ impl<F: FnMut(FilesystemEvent) + Send + Sync> NotifyActor<F> {
}
ActorEvent::Message(Some(SyncDependency(paths))) => {
if let Some(changeset) = self.update_watches(paths.as_ref()) {
(self.interrupted_by_events)(FilesystemEvent::Update(changeset));
(self.interrupted_by_events)(FilesystemEvent::Update(changeset, true));
}
}
ActorEvent::NotifyEvent(event) => {
@ -343,7 +343,7 @@ impl<F: FnMut(FilesystemEvent) + Send + Sync> NotifyActor<F> {
// Send file updates.
if !changeset.is_empty() {
(self.interrupted_by_events)(FilesystemEvent::Update(changeset));
(self.interrupted_by_events)(FilesystemEvent::Update(changeset, false));
}
}
@ -494,7 +494,7 @@ impl<F: FnMut(FilesystemEvent) + Send + Sync> NotifyActor<F> {
let mut changeset = FileChangeSet::default();
changeset.inserts.push((event.path, payload));
(self.interrupted_by_events)(FilesystemEvent::Update(changeset));
(self.interrupted_by_events)(FilesystemEvent::Update(changeset, false));
}
}
};

View file

@ -41,7 +41,7 @@ pub struct UpstreamUpdateEvent {
#[derive(Debug)]
pub enum FilesystemEvent {
/// Update file system files according to the given changeset
Update(FileChangeSet),
Update(FileChangeSet, /* is_sync */ bool),
/// See [`UpstreamUpdateEvent`]
UpstreamUpdate {
/// New changeset produced by invalidation
@ -60,7 +60,19 @@ impl FilesystemEvent {
changeset,
upstream_event,
} => (changeset, upstream_event),
FilesystemEvent::Update(changeset) => (changeset, None),
FilesystemEvent::Update(changeset, ..) => (changeset, None),
}
}
/// Splits the filesystem event into a changeset and an optional upstream
/// event.
pub fn split_with_is_sync(self) -> (FileChangeSet, bool, Option<UpstreamUpdateEvent>) {
match self {
FilesystemEvent::UpstreamUpdate {
changeset,
upstream_event,
} => (changeset, false, upstream_event),
FilesystemEvent::Update(changeset, is_sync) => (changeset, is_sync, None),
}
}
}

View file

@ -209,7 +209,7 @@ impl ServerState {
CompileServerOpts {
handler: compile_handle,
export_target: config.export_target,
enable_watch: true,
ignore_first_sync: true,
},
);

View file

@ -472,7 +472,7 @@ where
CompileServerOpts {
handler: compile_handle,
export_target: opts.export_target,
enable_watch: true,
ignore_first_sync: true,
},
);

View file

@ -14,7 +14,7 @@ else
exit 1
fi
(cd ../.. && docker build --network="host" -t myriaddreamin/tinymist:0.13.14 .)
# (cd ../.. && docker build --network="host" -t myriaddreamin/tinymist:0.13.14 .)
docker build --network="host" -t myriaddreamin/tinymist-nvim:0.13.14 .
docker run --network="host" --rm -it \
-v $PWD/../../tests/workspaces:/home/runner/dev/workspaces \

View file

@ -26,6 +26,6 @@ describe('Export', function()
vim.cmd.sleep('300m')
-- there *must not be* a pdf file created, because we only export on save
local pdf_path = fixtures.project.some_existing_file:gsub('%.typ$', '.pdf')
assert.is_false(vim.loop.fs_stat(pdf_path), 'PDF file should not be created without saving because exportPdf = onType')
assert.is.same(nil, vim.uv.fs_stat(pdf_path), 'PDF file should not be created without saving because exportPdf = onSave')
end)
end)

View file

@ -17,7 +17,7 @@ def run_tests(test_files=None):
test_files = []
for root, _, files in os.walk(os.path.dirname(__file__)):
test_files.extend(
os.path.join(root, f) for f in files if f.endswith("export_spec.lua")
os.path.join(root, f) for f in files if f.endswith("spec.lua")
)
test_files = " ".join(test_files)

View file

@ -26,6 +26,6 @@ describe('Export', function()
vim.cmd.sleep('300m')
-- there *must not be* a pdf file created, because we only export on save
local pdf_path = fixtures.project.some_existing_file:gsub('%.typ$', '.pdf')
assert.is_false(vim.loop.fs_stat(pdf_path), 'PDF file should not be created without saving because exportPdf = never')
assert.is.same(nil, vim.uv.fs_stat(pdf_path), 'PDF file should not be created without saving because exportPdf = never')
end)
end)