Skip to content

Commit

Permalink
fix: fix entry path in Windows (#1710)
Browse files Browse the repository at this point in the history
* fix: fix entry path in Windows

Signed-off-by: he1pa <18012015693@163.com>

* fix ut

Signed-off-by: he1pa <18012015693@163.com>

---------

Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa authored Oct 23, 2024
1 parent fc64537 commit daa7b18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions kclvm/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ pub struct ParseFileResult {

/// Parse a KCL file to the AST module with parse errors.
pub fn parse_single_file(filename: &str, code: Option<String>) -> Result<ParseFileResult> {
let filename = filename.adjust_canonicalization();
let sess = Arc::new(ParseSession::default());
let mut loader = Loader::new(
sess,
&[filename],
&[&filename],
Some(LoadProgramOptions {
load_packages: false,
k_code_list: if let Some(code) = code {
Expand Down Expand Up @@ -789,7 +790,7 @@ pub fn parse_entry(
let mut files = vec![];
for (i, f) in k_files.iter().enumerate() {
let file = PkgFile {
path: f.into(),
path: f.adjust_canonicalization().into(),
pkg_path: MAIN_PKG.to_string(),
};
files.push((file.clone(), maybe_k_codes.get(i).unwrap_or(&None).clone()));
Expand Down
5 changes: 4 additions & 1 deletion kclvm/query/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,10 @@ fn test_list_variable_with_invalid_kcl() {
result.parse_errors[0].messages[0].message,
"expected one of [\"=\"] got eof",
);
assert_eq!(result.parse_errors[0].messages[0].range.0.filename, file);
assert_eq!(
result.parse_errors[0].messages[0].range.0.filename,
file.adjust_canonicalization()
);
assert_eq!(result.parse_errors[0].messages[0].range.0.line, 1);
assert_eq!(result.parse_errors[0].messages[0].range.0.column, Some(8));
}
Expand Down

0 comments on commit daa7b18

Please sign in to comment.