Implement package replacement feature across the codebase
- Introduced a new `replaces` field in various structs to support package replacements. - Updated database schema to include a `replaces` table and corresponding queries. - Modified the package index to handle replacements and ensure they take precedence over exact package names. - Enhanced the `create_source_repo_index` function to include replacement entries in the index. - Updated tests to validate the new replacement functionality, including parsing and metadata generation. - Refactored relevant functions and structures to accommodate the new `replaces` feature in package specifications and alternatives.
This commit is contained in:
+11
-7
@@ -890,19 +890,23 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_effective_rustflags_applies_replace_rules() {
|
||||
let mut flags = BuildFlags::default();
|
||||
flags.rustflags = vec!["-C".into(), "debuginfo=2".into()];
|
||||
flags.replace_rustflags = vec!["debuginfo=2=>opt-level=2".into()];
|
||||
let flags = BuildFlags {
|
||||
rustflags: vec!["-C".into(), "debuginfo=2".into()],
|
||||
replace_rustflags: vec!["debuginfo=2=>opt-level=2".into()],
|
||||
..BuildFlags::default()
|
||||
};
|
||||
|
||||
assert_eq!(effective_rustflags(&flags), vec!["-C", "opt-level=2"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_effective_rustflags_appends_rustltoflags_when_enabled() {
|
||||
let mut flags = BuildFlags::default();
|
||||
flags.rustflags = vec!["-C".into(), "opt-level=3".into()];
|
||||
flags.rustltoflags = vec!["-Clinker-plugin-lto".into(), "-Cembed-bitcode=yes".into()];
|
||||
flags.use_lto = true;
|
||||
let flags = BuildFlags {
|
||||
rustflags: vec!["-C".into(), "opt-level=3".into()],
|
||||
rustltoflags: vec!["-Clinker-plugin-lto".into(), "-Cembed-bitcode=yes".into()],
|
||||
use_lto: true,
|
||||
..BuildFlags::default()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
effective_rustflags(&flags),
|
||||
|
||||
Reference in New Issue
Block a user