Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update file.size runtime impl and update test cases #1287

Merged
merged 1 commit into from
May 7, 2024
Merged
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
2 changes: 1 addition & 1 deletion kclvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ members = [
]

[features]
llvm = ["kclvm-compiler/llvm", "kclvm-runner/llvm"]
llvm = ["kclvm-compiler/llvm", "kclvm-runner/llvm", "kclvm-tools/llvm"]
6 changes: 3 additions & 3 deletions kclvm/api/src/service/service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ impl KclvmServiceImpl {
/// assert_eq!(result.type_errors.len(), 0);
/// assert_eq!(result.symbols.len(), 12);
/// assert_eq!(result.scopes.len(), 3);
/// assert_eq!(result.node_symbol_map.len(), 175);
/// assert_eq!(result.symbol_node_map.len(), 175);
/// assert_eq!(result.fully_qualified_name_map.len(), 184);
/// assert_eq!(result.node_symbol_map.len(), 174);
/// assert_eq!(result.symbol_node_map.len(), 174);
/// assert_eq!(result.fully_qualified_name_map.len(), 183);
/// assert_eq!(result.pkg_scope_map.len(), 3);
/// ```
#[inline]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -284,13 +291,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -330,4 +330,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
attrs: [],
is_global: false,
},
]
]
50 changes: 25 additions & 25 deletions kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -180,6 +180,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -376,13 +383,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -415,13 +415,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 164,
index: 163,
generation: 0,
},
kind: Value,
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -618,13 +625,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -664,6 +664,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -860,13 +867,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -899,7 +899,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 165,
index: 164,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -982,4 +982,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
attrs: [],
is_global: false,
},
]
]
54 changes: 27 additions & 27 deletions kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -240,7 +240,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 164,
index: 163,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -337,7 +337,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -382,6 +382,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -578,13 +585,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -617,13 +617,20 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 165,
index: 164,
generation: 0,
},
kind: Value,
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -820,13 +827,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -866,6 +866,13 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
),
attrs: [
SymbolRef {
id: Index {
index: 133,
generation: 0,
},
kind: Value,
},
SymbolRef {
id: Index {
index: 134,
Expand Down Expand Up @@ -1062,13 +1069,6 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
},
kind: Value,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
},
],
is_global: false,
},
Expand Down Expand Up @@ -1101,7 +1101,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 166,
index: 165,
generation: 0,
},
kind: Value,
Expand Down Expand Up @@ -1184,4 +1184,4 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
attrs: [],
is_global: false,
},
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 163,
index: 162,
generation: 0,
},
kind: Value,
Expand Down
Binary file modified kclvm/runtime/src/_kclvm.bc
Binary file not shown.
3 changes: 2 additions & 1 deletion kclvm/tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ insta = "1.8.0"
name = "benchmark"
harness = false


[features]
llvm = ["kclvm-runner/llvm"]
14 changes: 10 additions & 4 deletions kclvm/tools/src/testing/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ use anyhow::{anyhow, Result};
use indexmap::IndexMap;
use kclvm_ast::ast;
use kclvm_driver::{get_kcl_files, get_pkg_list};
use kclvm_parser::{parse_file_force_errors, ParseSession};
use kclvm_parser::{parse_file_force_errors, ParseSessionRef};
#[cfg(feature = "llvm")]
use kclvm_runner::build_program;
#[cfg(feature = "llvm")]
use kclvm_runner::runner::ProgramRunner;
use kclvm_runner::{build_program, ExecProgramArgs};
use std::sync::Arc;
use kclvm_runner::{exec_program, ExecProgramArgs};
use std::time::Instant;

/// File suffix for test files.
Expand Down Expand Up @@ -59,15 +61,19 @@ impl TestRun for TestSuite {
..opts.exec_args.clone()
};
// Build the program.
let artifact = build_program::<String>(Arc::new(ParseSession::default()), &args, None)?;
#[cfg(feature = "llvm")]
let artifact = build_program::<String>(ParseSessionRef::default(), &args, None)?;
// Test every case in the suite.
for (name, _) in &self.cases {
args.args = vec![ast::CmdArgSpec {
name: TEST_CASE_RUN_OPTION.into(),
value: format!("{:?}", name),
}];
let start = Instant::now();
#[cfg(feature = "llvm")]
let exec_result = artifact.run(&args)?;
#[cfg(not(feature = "llvm"))]
let exec_result = exec_program(ParseSessionRef::default(), &args)?;
// Check if there was an error.
let error = if exec_result.err_message.is_empty() {
None
Expand Down
1 change: 0 additions & 1 deletion test/grammar/builtins/file/size/stdout.golden

This file was deleted.

Loading