Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/llvm-cov/html/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html><head><meta name='viewport' content='width=device-width,initial-scale=1'><meta charset='UTF-8'><link rel='stylesheet' type='text/css' href='style.css'><script src='control.js'></script></head><body><h2>Coverage Report</h2><h4>Created: 2026-04-30 05:51</h4><p>Click <a href='http://clang.llvm.org/docs/SourceBasedCodeCoverage.html#interpreting-reports'>here</a> for information about interpreting this report.</p><div class='centered'><table><tr><td class='column-entry-bold'>Filename</td><td class='column-entry-bold'>Function Coverage</td><td class='column-entry-bold'>Line Coverage</td><td class='column-entry-bold'>Region Coverage</td><td class='column-entry-bold'>Branch Coverage</td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/bin/mathml2text.rs.html'>bin/mathml2text.rs</a></pre></td><td class='column-entry-red'><pre> 0.00% (0/3)</pre></td><td class='column-entry-red'><pre> 0.00% (0/60)</pre></td><td class='column-entry-red'><pre> 0.00% (0/129)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/braille.rs.html'>braille.rs</a></pre></td><td class='column-entry-yellow'><pre> 89.63% (147/164)</pre></td><td class='column-entry-yellow'><pre> 84.01% (1608/1914)</pre></td><td class='column-entry-yellow'><pre> 81.11% (2955/3643)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/canonicalize.rs.html'>canonicalize.rs</a></pre></td><td class='column-entry-yellow'><pre> 97.40% (300/308)</pre></td><td class='column-entry-yellow'><pre> 94.43% (4747/5027)</pre></td><td class='column-entry-yellow'><pre> 93.14% (6712/7206)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/chemistry.rs.html'>chemistry.rs</a></pre></td><td class='column-entry-yellow'><pre> 98.68% (149/151)</pre></td><td class='column-entry-yellow'><pre> 94.93% (2453/2584)</pre></td><td class='column-entry-yellow'><pre> 90.78% (2933/3231)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/definitions.rs.html'>definitions.rs</a></pre></td><td class='column-entry-red'><pre> 61.90% (26/42)</pre></td><td class='column-entry-yellow'><pre> 86.97% (207/238)</pre></td><td class='column-entry-yellow'><pre> 82.48% (433/525)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/infer_intent.rs.html'>infer_intent.rs</a></pre></td><td class='column-entry-yellow'><pre> 91.94% (57/62)</pre></td><td class='column-entry-yellow'><pre> 87.67% (654/746)</pre></td><td class='column-entry-red'><pre> 79.38% (916/1154)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/interface.rs.html'>interface.rs</a></pre></td><td class='column-entry-red'><pre> 76.03% (92/121)</pre></td><td class='column-entry-red'><pre> 73.62% (681/925)</pre></td><td class='column-entry-red'><pre> 72.60% (1224/1686)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/lib.rs.html'>lib.rs</a></pre></td><td class='column-entry-yellow'><pre> 85.71% (6/7)</pre></td><td class='column-entry-red'><pre> 78.00% (39/50)</pre></td><td class='column-entry-yellow'><pre> 85.06% (74/87)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/main.rs.html'>main.rs</a></pre></td><td class='column-entry-red'><pre> 0.00% (0/3)</pre></td><td class='column-entry-red'><pre> 0.00% (0/108)</pre></td><td class='column-entry-red'><pre> 0.00% (0/209)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/navigate.rs.html'>navigate.rs</a></pre></td><td class='column-entry-yellow'><pre> 93.96% (140/149)</pre></td><td class='column-entry-yellow'><pre> 87.98% (1881/2138)</pre></td><td class='column-entry-yellow'><pre> 86.18% (2826/3279)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/prefs.rs.html'>prefs.rs</a></pre></td><td class='column-entry-yellow'><pre> 83.33% (65/78)</pre></td><td class='column-entry-red'><pre> 79.12% (610/771)</pre></td><td class='column-entry-red'><pre> 79.49% (1601/2014)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/pretty_print.rs.html'>pretty_print.rs</a></pre></td><td class='column-entry-yellow'><pre> 89.74% (35/39)</pre></td><td class='column-entry-red'><pre> 70.12% (298/425)</pre></td><td class='column-entry-red'><pre> 71.20% (576/809)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/shim_filesystem.rs.html'>shim_filesystem.rs</a></pre></td><td class='column-entry-green'><pre> 100.00% (7/7)</pre></td><td class='column-entry-yellow'><pre> 81.69% (58/71)</pre></td><td class='column-entry-red'><pre> 75.86% (110/145)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/speech.rs.html'>speech.rs</a></pre></td><td class='column-entry-red'><pre> 67.33% (136/202)</pre></td><td class='column-entry-red'><pre> 76.21% (1371/1799)</pre></td><td class='column-entry-red'><pre> 74.80% (2662/3559)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/tts.rs.html'>tts.rs</a></pre></td><td class='column-entry-red'><pre> 73.17% (30/41)</pre></td><td class='column-entry-red'><pre> 68.86% (272/395)</pre></td><td class='column-entry-red'><pre> 61.54% (480/780)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/xpath_functions.rs.html'>xpath_functions.rs</a></pre></td><td class='column-entry-yellow'><pre> 95.18% (79/83)</pre></td><td class='column-entry-yellow'><pre> 87.34% (911/1043)</pre></td><td class='column-entry-yellow'><pre> 85.58% (1845/2156)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row-bold'><td><pre>Totals</pre></td><td class='column-entry-yellow'><pre> 86.92% (1269/1460)</pre></td><td class='column-entry-yellow'><pre> 86.31% (15790/18294)</pre></td><td class='column-entry-yellow'><pre> 82.80% (25347/30612)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr></table></div><h5>Generated by llvm-cov -- llvm version 22.1.2-rust-1.95.0-stable</h5></body></html>
<!doctype html><html><head><meta name='viewport' content='width=device-width,initial-scale=1'><meta charset='UTF-8'><link rel='stylesheet' type='text/css' href='style.css'><script src='control.js'></script></head><body><h2>Coverage Report</h2><h4>Created: 2026-05-04 09:37</h4><p>Click <a href='http://clang.llvm.org/docs/SourceBasedCodeCoverage.html#interpreting-reports'>here</a> for information about interpreting this report.</p><div class='centered'><table><tr><td class='column-entry-bold'>Filename</td><td class='column-entry-bold'>Function Coverage</td><td class='column-entry-bold'>Line Coverage</td><td class='column-entry-bold'>Region Coverage</td><td class='column-entry-bold'>Branch Coverage</td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/bin/mathml2text.rs.html'>bin/mathml2text.rs</a></pre></td><td class='column-entry-red'><pre> 0.00% (0/3)</pre></td><td class='column-entry-red'><pre> 0.00% (0/60)</pre></td><td class='column-entry-red'><pre> 0.00% (0/129)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/braille.rs.html'>braille.rs</a></pre></td><td class='column-entry-yellow'><pre> 89.63% (147/164)</pre></td><td class='column-entry-yellow'><pre> 84.01% (1608/1914)</pre></td><td class='column-entry-yellow'><pre> 81.11% (2955/3643)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/canonicalize.rs.html'>canonicalize.rs</a></pre></td><td class='column-entry-yellow'><pre> 97.40% (300/308)</pre></td><td class='column-entry-yellow'><pre> 94.43% (4747/5027)</pre></td><td class='column-entry-yellow'><pre> 93.14% (6712/7206)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/chemistry.rs.html'>chemistry.rs</a></pre></td><td class='column-entry-yellow'><pre> 98.68% (149/151)</pre></td><td class='column-entry-yellow'><pre> 94.93% (2453/2584)</pre></td><td class='column-entry-yellow'><pre> 90.78% (2933/3231)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/definitions.rs.html'>definitions.rs</a></pre></td><td class='column-entry-red'><pre> 61.90% (26/42)</pre></td><td class='column-entry-yellow'><pre> 86.97% (207/238)</pre></td><td class='column-entry-yellow'><pre> 82.48% (433/525)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/infer_intent.rs.html'>infer_intent.rs</a></pre></td><td class='column-entry-yellow'><pre> 91.94% (57/62)</pre></td><td class='column-entry-yellow'><pre> 87.67% (654/746)</pre></td><td class='column-entry-red'><pre> 79.38% (916/1154)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/interface.rs.html'>interface.rs</a></pre></td><td class='column-entry-red'><pre> 76.03% (92/121)</pre></td><td class='column-entry-red'><pre> 73.62% (681/925)</pre></td><td class='column-entry-red'><pre> 72.60% (1224/1686)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/lib.rs.html'>lib.rs</a></pre></td><td class='column-entry-yellow'><pre> 85.71% (6/7)</pre></td><td class='column-entry-red'><pre> 78.00% (39/50)</pre></td><td class='column-entry-yellow'><pre> 85.06% (74/87)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/main.rs.html'>main.rs</a></pre></td><td class='column-entry-red'><pre> 0.00% (0/3)</pre></td><td class='column-entry-red'><pre> 0.00% (0/108)</pre></td><td class='column-entry-red'><pre> 0.00% (0/209)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/navigate.rs.html'>navigate.rs</a></pre></td><td class='column-entry-yellow'><pre> 93.96% (140/149)</pre></td><td class='column-entry-yellow'><pre> 87.98% (1881/2138)</pre></td><td class='column-entry-yellow'><pre> 86.18% (2826/3279)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/prefs.rs.html'>prefs.rs</a></pre></td><td class='column-entry-yellow'><pre> 83.33% (65/78)</pre></td><td class='column-entry-red'><pre> 79.25% (615/776)</pre></td><td class='column-entry-red'><pre> 79.66% (1606/2016)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/pretty_print.rs.html'>pretty_print.rs</a></pre></td><td class='column-entry-yellow'><pre> 89.74% (35/39)</pre></td><td class='column-entry-red'><pre> 70.12% (298/425)</pre></td><td class='column-entry-red'><pre> 71.20% (576/809)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/shim_filesystem.rs.html'>shim_filesystem.rs</a></pre></td><td class='column-entry-green'><pre> 100.00% (7/7)</pre></td><td class='column-entry-red'><pre> 78.67% (59/75)</pre></td><td class='column-entry-red'><pre> 74.50% (111/149)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/speech.rs.html'>speech.rs</a></pre></td><td class='column-entry-red'><pre> 67.33% (136/202)</pre></td><td class='column-entry-red'><pre> 76.21% (1371/1799)</pre></td><td class='column-entry-red'><pre> 74.80% (2662/3559)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/tts.rs.html'>tts.rs</a></pre></td><td class='column-entry-red'><pre> 73.17% (30/41)</pre></td><td class='column-entry-red'><pre> 68.86% (272/395)</pre></td><td class='column-entry-red'><pre> 61.54% (480/780)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row'><td><pre><a href='coverage/home/runner/work/MathCAT/MathCAT/src/xpath_functions.rs.html'>xpath_functions.rs</a></pre></td><td class='column-entry-yellow'><pre> 95.18% (79/83)</pre></td><td class='column-entry-yellow'><pre> 87.34% (911/1043)</pre></td><td class='column-entry-yellow'><pre> 85.58% (1845/2156)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr><tr class='light-row-bold'><td><pre>Totals</pre></td><td class='column-entry-yellow'><pre> 86.92% (1269/1460)</pre></td><td class='column-entry-yellow'><pre> 86.30% (15796/18303)</pre></td><td class='column-entry-yellow'><pre> 82.80% (25353/30618)</pre></td><td class='column-entry-gray'><pre>- (0/0)</pre></td></tr></table></div><h5>Generated by llvm-cov -- llvm version 22.1.2-rust-1.95.0-stable</h5></body></html>
16 changes: 15 additions & 1 deletion src/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,23 @@ impl PreferenceManager {
///
/// If rules_dir is an empty PathBuf, the existing rules_dir is used (an error if it doesn't exist)
pub fn initialize(&mut self, rules_dir: PathBuf) -> Result<()> {
// Resolve the rules directory to an absolute, canonical path.
// If canonicalize() fails (e.g., ACCESS_DENIED in containers), fall back to:
// - returning the path as-is if it is already absolute,
// - prepending the current working directory if it is relative.
// Note: if current_dir() also fails, unwrap_or_default yields an empty PathBuf,
// and the result may remain relative.
#[cfg(not(feature = "include-zip"))]
let rules_dir = match rules_dir.canonicalize() {
Err(e) => bail!("set_rules_dir: could not canonicalize path {}: {}", rules_dir.display(), e),
Err(_e) => {
if rules_dir.is_absolute() {
rules_dir
} else {
std::env::current_dir()
.unwrap_or_default()
.join(&rules_dir)
}
},
Ok(rules_dir) => rules_dir,
};

Expand Down
21 changes: 19 additions & 2 deletions src/shim_filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,31 @@ cfg_if! {
}
}

/// Resolves the path to an absolute, canonical form using the OS.
/// If `canonicalize()` fails (e.g., ACCESS_DENIED in containers), falls back to:
/// - returning the path as-is if it is already absolute,
/// - prepending the current working directory if it is relative.
/// Note: the fallback does not resolve symlinks or normalize `..`/`.` segments.
pub fn canonicalize_shim(path: &Path) -> std::io::Result<PathBuf> {
return path.canonicalize();
match path.canonicalize() {
Ok(p) => Ok(p),
Err(_) => {
if path.is_absolute() {
Ok(path.to_path_buf())
} else {
// Prepend cwd to make the relative path absolute.
// unwrap_or_default yields an empty PathBuf if cwd is unavailable,
// in which case the returned path will still be relative.
Ok(std::env::current_dir().unwrap_or_default().join(path))
}
}
}
}

pub fn read_to_string_shim(path: &Path) -> Result<String> {
let path = match path.canonicalize() {
Ok(path) => path,
Err(e) => bail!("Read error while trying to canonicalize in read_to_string_shim {}: {}", path.display(), e),
Err(_) => path.to_path_buf(),
};
debug!("Reading file '{}'", &path.display());
match std::fs::read_to_string(&path) {
Expand Down