-
Notifications
You must be signed in to change notification settings - Fork 143
added kpm_update #1032
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
Closed
Closed
added kpm_update #1032
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b077e74
added kpm_update
octonawish-akcodes 1f56f64
refactor
octonawish-akcodes 1146d87
added test cases for update module driver
octonawish-akcodes a687b2c
fix
octonawish-akcodes f59a206
test cases fix
octonawish-akcodes 54b8bf2
Merge branch 'main' into ts
octonawish-akcodes 8642ac2
formatted code
octonawish-akcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "kpm_update" | ||
edition = "0.0.1" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
k8s = "1.29" |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,10 @@ use kclvm_parser::LoadProgramOptions; | |
use walkdir::WalkDir; | ||
|
||
use crate::arguments::parse_key_value_pair; | ||
use crate::kpm_metadata::{fetch_metadata, fill_pkg_maps_for_k_file, lookup_the_nearest_file_dir}; | ||
use crate::kpm_metadata::fetch_metadata; | ||
use crate::kpm_update::update_kcl_module; | ||
use crate::{canonicalize_input_files, expand_input_files, get_pkg_list}; | ||
use crate::{fill_pkg_maps_for_k_file, lookup_the_nearest_file_dir}; | ||
|
||
#[test] | ||
fn test_canonicalize_input_files() { | ||
|
@@ -382,28 +383,42 @@ fn test_get_pkg_list() { | |
); | ||
} | ||
|
||
#[cfg(test)] | ||
// Define a mock structure to simulate the behavior of Command::output | ||
struct MockCommand { | ||
output: Result<MockCommandOutput, std::io::Error>, | ||
#[test] | ||
fn test_lookup_the_nearest_file_dir_for_update() { | ||
let path = PathBuf::from(".") | ||
.join("src") | ||
.join("test_data") | ||
.join("kpm_update"); | ||
let result = lookup_the_nearest_file_dir(path.clone(), "kcl.mod"); | ||
assert!(result.is_some()); | ||
assert_eq!( | ||
result.unwrap().display().to_string(), | ||
path.canonicalize().unwrap().display().to_string() | ||
); | ||
|
||
let main_path = path.join("subdir").join("main.k"); | ||
let result = lookup_the_nearest_file_dir(main_path, "kcl.mod"); | ||
assert!(result.is_some()); | ||
assert_eq!( | ||
result.unwrap().display().to_string(), | ||
path.canonicalize().unwrap().display().to_string() | ||
); | ||
} | ||
// Define a mock structure to represent the output of Command::output | ||
struct MockCommandOutput { | ||
status: std::process::ExitStatus, | ||
stderr: Vec<u8>, | ||
|
||
fn test_fetch_mod_metadata() { | ||
let path = PathBuf::from(".") | ||
.join("src") | ||
.join("test_data") | ||
.join("kpm_update"); | ||
|
||
let update_mod = update_kcl_module(path.clone()); | ||
// Show more information when the test fails. | ||
println!("{:?}", update_mod); | ||
assert!(!update_mod.is_err()); | ||
} | ||
|
||
#[test] | ||
fn test_update_kcl_module_failure() { | ||
let manifest_path = PathBuf::from("path/to/manifest"); | ||
fn mock_command_new_failing(_command: &str) -> MockCommand { | ||
MockCommand { | ||
output: Err(std::io::Error::new( | ||
std::io::ErrorKind::Other, | ||
"Command failed", | ||
)), | ||
} | ||
} | ||
let result = update_kcl_module(manifest_path); | ||
assert!(result.is_err()); | ||
fn test_update_module() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @octonawish-akcodes CI failed and would you please sign the DCO? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im inspecting that, and i am having trouble signing dco due to conflicts :/ |
||
test_fetch_mod_metadata(); | ||
println!("test_update_module() passed"); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.