diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d079d3..bc09156 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: [push, pull_request] env: CARGO_TERM_COLOR: always + TESTING_PLUGINS_VERSION: "1.6.0" jobs: rustfmt: @@ -33,9 +34,10 @@ jobs: - name: Prepare test resources run: | - (New-Object Net.WebClient).DownloadFile('https://github.com/WrinklyNinja/testing-plugins/archive/1.4.1.zip', "$PWD/1.4.1.zip") - 7z x 1.4.1.zip - mv testing-plugins-1.4.1 testing-plugins + (New-Object Net.WebClient).DownloadFile('https://github.com/WrinklyNinja/testing-plugins/archive/$TESTING_PLUGINS_VERSION.zip', "$PWD/$TESTING_PLUGINS_VERSION.zip") + 7z x $TESTING_PLUGINS_VERSION.zip + mv testing-plugins-$TESTING_PLUGINS_VERSION testing-plugins + - name: Build and run tests run: cargo test --all --all-features @@ -75,9 +77,9 @@ jobs: - name: Prepare test resources run: | - wget https://github.com/WrinklyNinja/testing-plugins/archive/1.4.1.tar.gz - tar -xf 1.4.1.tar.gz - mv testing-plugins-1.4.1 testing-plugins + wget https://github.com/WrinklyNinja/testing-plugins/archive/$TESTING_PLUGINS_VERSION.tar.gz + tar -xf $TESTING_PLUGINS_VERSION.tar.gz + mv testing-plugins-$TESTING_PLUGINS_VERSION testing-plugins - name: Build and run tests with code coverage run: cargo llvm-cov --workspace --lcov --output-path lcov.info diff --git a/src/plugin.rs b/src/plugin.rs index 25b8e93..5bf7ca0 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -404,7 +404,7 @@ impl Plugin { fn is_medium_flag_set(&self) -> bool { let flag = match self.game_id { - GameId::Starfield => 0x10000, + GameId::Starfield => 0x400, _ => return false, }; @@ -1703,8 +1703,8 @@ mod tests { fn is_master_file_should_use_file_extension_and_flag() { use std::fs::copy; copy( - Path::new("testing-plugins/Skyrim/Data/Blank.esm"), - Path::new("testing-plugins/Skyrim/Data/Blank.esm.esp"), + Path::new("testing-plugins/Starfield/Data/Blank.full.esm"), + Path::new("testing-plugins/Starfield/Data/Blank.full.esm.esp"), ) .unwrap(); @@ -1719,14 +1719,14 @@ mod tests { let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/Skyrim/Data/Blank.esp"), + Path::new("testing-plugins/Starfield/Data/Blank.esp"), ); assert!(plugin.parse_file(true).is_ok()); assert!(!plugin.is_master_file()); let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/Skyrim/Data/Blank.esm.esp"), + Path::new("testing-plugins/Starfield/Data/Blank.full.esm.esp"), ); assert!(plugin.parse_file(true).is_ok()); assert!(plugin.is_master_file()); @@ -1766,39 +1766,25 @@ mod tests { #[test] fn is_light_plugin_should_be_true_for_a_plugin_with_the_light_flag_set() { - let mut plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esm")); - let file_data = &[ - 0x54, 0x45, 0x53, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xB2, 0x2E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; - plugin.data.header_record = Record::parse(file_data, GameId::Starfield, false) - .unwrap() - .1; - + let mut plugin = Plugin::new(GameId::Starfield, Path::new("testing-plugins/Starfield/Data/Blank.small.esm")); + assert!(plugin.parse_file(true).is_ok()); assert!(plugin.is_light_plugin()); } #[test] fn is_medium_plugin_should_be_false_for_a_plugin_without_the_medium_flag_set() { - let plugin = Plugin::new(GameId::Morrowind, Path::new("Blank.esp")); + let plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esp")); assert!(!plugin.is_medium_plugin()); - let plugin = Plugin::new(GameId::Morrowind, Path::new("Blank.esm")); + let plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esm")); assert!(!plugin.is_medium_plugin()); - let plugin = Plugin::new(GameId::Morrowind, Path::new("Blank.esl")); + let plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esl")); assert!(!plugin.is_medium_plugin()); } #[test] fn is_medium_plugin_should_be_true_for_a_plugin_with_the_medium_flag_set() { - let mut plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esm")); - let file_data = &[ - 0x54, 0x45, 0x53, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xB2, 0x2E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; - plugin.data.header_record = Record::parse(file_data, GameId::Starfield, false) - .unwrap() - .1; - + let mut plugin = Plugin::new(GameId::Starfield, Path::new("testing-plugins/Starfield/Data/Blank.medium.esm")); + assert!(plugin.parse_file(true).is_ok()); assert!(plugin.is_medium_plugin()); } @@ -1852,7 +1838,7 @@ mod tests { fn valid_light_form_id_range_should_be_0_to_0xfff() { let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/SkyrimSE/Data/Blank - Master Dependent.esm"), + Path::new("testing-plugins/Starfield/Data/Blank.small.esm"), ); assert!(plugin.parse_file(false).is_ok()); @@ -1866,7 +1852,7 @@ mod tests { ) { let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/SkyrimSE/Data/Blank - Master Dependent.esm"), + Path::new("testing-plugins/Starfield/Data/Blank.small.esm"), ); assert!(plugin.parse_file(false).is_ok()); @@ -1888,7 +1874,7 @@ mod tests { fn is_valid_as_override_plugin_should_be_false_if_the_plugin_has_new_records() { let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/SkyrimSE/Data/Blank - Master Dependent.esm"), + Path::new("testing-plugins/Starfield/Data/Blank.full.esm"), ); assert!(plugin.parse_file(false).is_ok());