mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Stop using 7z binaries in test cases
They're not reliably available and are now causing CI failures. Instead use libloot for the test cases that used 7z, and update it because older versions of libloot incorrectly use "ProductVERSION " instead of "ProductVersion".
This commit is contained in:
+12
-18
@@ -42,21 +42,18 @@ jobs:
|
|||||||
7z x 1.4.0.zip
|
7z x 1.4.0.zip
|
||||||
mv testing-plugins-1.4.0 testing-plugins
|
mv testing-plugins-1.4.0 testing-plugins
|
||||||
|
|
||||||
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/loot-api/releases/download/0.13.8/loot_api-0.13.8-0-g47797cc_dev-win32.7z', "$PWD/loot_api_win32.7z")
|
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z', "$PWD/libloot_win32.7z")
|
||||||
7z x loot_api_win32.7z
|
7z x libloot_win32.7z
|
||||||
mv loot_api-0.13.8-0-g47797cc_dev-win32 loot_api_win32
|
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32
|
||||||
|
|
||||||
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/loot-api/releases/download/0.13.8/loot_api-0.13.8-0-g47797cc_dev-win64.7z', "$PWD/loot_api_win64.7z")
|
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z', "$PWD/libloot_win64.7z")
|
||||||
7z x loot_api_win64.7z
|
7z x libloot_win64.7z
|
||||||
mv loot_api-0.13.8-0-g47797cc_dev-win64 loot_api_win64
|
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64
|
||||||
|
|
||||||
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z', "$PWD/loot_api_python.7z")
|
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z', "$PWD/loot_api_python.7z")
|
||||||
7z x loot_api_python.7z
|
7z x loot_api_python.7z
|
||||||
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
|
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
|
||||||
|
|
||||||
(New-Object Net.WebClient).DownloadFile('https://7-zip.org/a/7z1805-extra.7z', "$PWD/7z.7z")
|
|
||||||
7z x "$PWD/7z.7z" -o7z
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build and run tests
|
- name: Build and run tests
|
||||||
@@ -103,21 +100,18 @@ jobs:
|
|||||||
tar -xf 1.4.1.tar.gz
|
tar -xf 1.4.1.tar.gz
|
||||||
mv testing-plugins-1.4.1 testing-plugins
|
mv testing-plugins-1.4.1 testing-plugins
|
||||||
|
|
||||||
wget https://github.com/loot/loot-api/releases/download/0.13.8/loot_api-0.13.8-0-g47797cc_dev-win32.7z
|
wget https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z
|
||||||
7z x loot_api-0.13.8-0-g47797cc_dev-win32.7z
|
7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z
|
||||||
mv loot_api-0.13.8-0-g47797cc_dev-win32 loot_api_win32
|
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32
|
||||||
|
|
||||||
wget https://github.com/loot/loot-api/releases/download/0.13.8/loot_api-0.13.8-0-g47797cc_dev-win64.7z
|
wget https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z
|
||||||
7z x loot_api-0.13.8-0-g47797cc_dev-win64.7z
|
7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z
|
||||||
mv loot_api-0.13.8-0-g47797cc_dev-win64 loot_api_win64
|
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64
|
||||||
|
|
||||||
wget https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z
|
wget https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z
|
||||||
7z x loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z
|
7z x loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z
|
||||||
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
|
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
|
||||||
|
|
||||||
wget https://7-zip.org/a/7z1805-extra.7z
|
|
||||||
7z x 7z1805-extra.7z -o7z
|
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- name: Build and run tests with code coverage
|
- name: Build and run tests with code coverage
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
/target/
|
/target/
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
/tests/7z
|
|
||||||
/tests/testing-plugins
|
/tests/testing-plugins
|
||||||
/tests/loot_api*
|
/tests/libloot*
|
||||||
|
/tests/loot_api_python
|
||||||
/ffi/include/
|
/ffi/include/
|
||||||
/ffi/build/
|
/ffi/build/
|
||||||
.vscode
|
.vscode
|
||||||
|
|||||||
+3
-4
@@ -124,10 +124,9 @@ fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
|
|
||||||
c.bench_function("Expression.eval() version(executable)", |b| {
|
c.bench_function("Expression.eval() version(executable)", |b| {
|
||||||
let state = State::new(GameType::Oblivion, ".".into(), ".".into());
|
let state = State::new(GameType::Oblivion, ".".into(), ".".into());
|
||||||
let expression = Expression::from_str(
|
let expression =
|
||||||
"version(\"tests/loot_api_win32/loot_api.dll\", \"0.13.8.0\", ==)",
|
Expression::from_str("version(\"tests/libloot_win32/loot.dll\", \"0.18.2.0\", ==)")
|
||||||
)
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
assert!(expression.eval(&state).unwrap());
|
assert!(expression.eval(&state).unwrap());
|
||||||
|
|||||||
+11
-8
@@ -1204,20 +1204,23 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn function_version_eval_should_read_executable_file_version() {
|
fn function_version_eval_should_read_executable_file_version() {
|
||||||
let function = Function::Version(
|
let function = Function::Version(
|
||||||
"loot_api.dll".into(),
|
"loot.dll".into(),
|
||||||
"0.13.8.0".into(),
|
"0.18.2.0".into(),
|
||||||
ComparisonOperator::Equal,
|
ComparisonOperator::Equal,
|
||||||
);
|
);
|
||||||
let state = state("tests/loot_api_win32");
|
let state = state("tests/libloot_win32");
|
||||||
|
|
||||||
assert!(function.eval(&state).unwrap());
|
assert!(function.eval(&state).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_product_version_eval_should_read_executable_product_version() {
|
fn function_product_version_eval_should_read_executable_product_version() {
|
||||||
let function =
|
let function = Function::ProductVersion(
|
||||||
Function::ProductVersion("7za.exe".into(), "18.05".into(), ComparisonOperator::Equal);
|
"loot.dll".into(),
|
||||||
let state = state("tests/7z");
|
"0.18.2".into(),
|
||||||
|
ComparisonOperator::Equal,
|
||||||
|
);
|
||||||
|
let state = state("tests/libloot_win32");
|
||||||
|
|
||||||
assert!(function.eval(&state).unwrap());
|
assert!(function.eval(&state).unwrap());
|
||||||
}
|
}
|
||||||
@@ -1234,11 +1237,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_product_version_should_return_ok_some_if_the_path_is_an_executable() {
|
fn get_product_version_should_return_ok_some_if_the_path_is_an_executable() {
|
||||||
let version = get_product_version(Path::new("tests/7z/7za.exe"))
|
let version = get_product_version(Path::new("tests/libloot_win32/loot.dll"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(Version::from("18.05"), version);
|
assert_eq!(Version::from("0.18.2"), version);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+34
-21
@@ -385,17 +385,16 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version_read_file_version_should_read_the_file_version_field_of_a_32_bit_executable() {
|
fn version_read_file_version_should_read_the_file_version_field_of_a_32_bit_executable() {
|
||||||
let version =
|
let version = Version::read_file_version(Path::new("tests/libloot_win32/loot.dll"))
|
||||||
Version::read_file_version(Path::new("tests/loot_api_win32/loot_api.dll"))
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
version.release_ids,
|
version.release_ids,
|
||||||
vec![
|
vec![
|
||||||
ReleaseId::Numeric(0),
|
ReleaseId::Numeric(0),
|
||||||
ReleaseId::Numeric(13),
|
ReleaseId::Numeric(18),
|
||||||
ReleaseId::Numeric(8),
|
ReleaseId::Numeric(2),
|
||||||
ReleaseId::Numeric(0),
|
ReleaseId::Numeric(0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -404,17 +403,16 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version_read_file_version_should_read_the_file_version_field_of_a_64_bit_executable() {
|
fn version_read_file_version_should_read_the_file_version_field_of_a_64_bit_executable() {
|
||||||
let version =
|
let version = Version::read_file_version(Path::new("tests/libloot_win64/loot.dll"))
|
||||||
Version::read_file_version(Path::new("tests/loot_api_win64/loot_api.dll"))
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
version.release_ids,
|
version.release_ids,
|
||||||
vec![
|
vec![
|
||||||
ReleaseId::Numeric(0),
|
ReleaseId::Numeric(0),
|
||||||
ReleaseId::Numeric(13),
|
ReleaseId::Numeric(18),
|
||||||
ReleaseId::Numeric(8),
|
ReleaseId::Numeric(2),
|
||||||
ReleaseId::Numeric(0),
|
ReleaseId::Numeric(0),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -449,13 +447,17 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn version_read_product_version_should_read_the_file_version_field_of_a_32_bit_executable()
|
fn version_read_product_version_should_read_the_file_version_field_of_a_32_bit_executable()
|
||||||
{
|
{
|
||||||
let version = Version::read_product_version(Path::new("tests/7z/7za.exe"))
|
let version = Version::read_product_version(Path::new("tests/libloot_win32/loot.dll"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
version.release_ids,
|
version.release_ids,
|
||||||
vec![ReleaseId::Numeric(18), ReleaseId::Numeric(5),]
|
vec![
|
||||||
|
ReleaseId::Numeric(0),
|
||||||
|
ReleaseId::Numeric(18),
|
||||||
|
ReleaseId::Numeric(2)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
assert!(version.pre_release_ids.is_empty());
|
assert!(version.pre_release_ids.is_empty());
|
||||||
}
|
}
|
||||||
@@ -463,32 +465,43 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn version_read_product_version_should_read_the_file_version_field_of_a_64_bit_executable()
|
fn version_read_product_version_should_read_the_file_version_field_of_a_64_bit_executable()
|
||||||
{
|
{
|
||||||
let version = Version::read_product_version(Path::new("tests/7z/x64/7za.exe"))
|
let version = Version::read_product_version(Path::new("tests/libloot_win64/loot.dll"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
version.release_ids,
|
version.release_ids,
|
||||||
vec![ReleaseId::Numeric(18), ReleaseId::Numeric(5),]
|
vec![
|
||||||
|
ReleaseId::Numeric(0),
|
||||||
|
ReleaseId::Numeric(18),
|
||||||
|
ReleaseId::Numeric(2),
|
||||||
|
]
|
||||||
);
|
);
|
||||||
assert!(version.pre_release_ids.is_empty());
|
assert!(version.pre_release_ids.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn version_read_file_version_should_find_non_us_english_version_strings() {
|
fn version_read_product_version_should_find_non_us_english_version_strings() {
|
||||||
let tmp_dir = tempfile::tempdir().unwrap();
|
let tmp_dir = tempfile::tempdir().unwrap();
|
||||||
let dll_path = tmp_dir.path().join("7zxa.ru.dll");
|
let dll_path = tmp_dir.path().join("loot.ru.dll");
|
||||||
|
|
||||||
|
let mut dll_bytes = std::fs::read("tests/libloot_win32/loot.dll").unwrap();
|
||||||
|
|
||||||
// Set the version info block's language code to 1049 (Russian).
|
// Set the version info block's language code to 1049 (Russian).
|
||||||
let mut dll_bytes = std::fs::read("tests/7z/7zxa.dll").unwrap();
|
dll_bytes[0x53204A] = b'1'; // This changes VersionInfo.strings.Language.lang_id
|
||||||
dll_bytes[0x23B10] = 0x19;
|
dll_bytes[0x53216C] = 0x19; // This changes VersionInfo.langs.Language.lang_id
|
||||||
|
|
||||||
std::fs::write(&dll_path, dll_bytes).unwrap();
|
std::fs::write(&dll_path, dll_bytes).unwrap();
|
||||||
|
|
||||||
let version = Version::read_product_version(&dll_path).unwrap().unwrap();
|
let version = Version::read_product_version(&dll_path).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
version.release_ids,
|
version.release_ids,
|
||||||
vec![ReleaseId::Numeric(18), ReleaseId::Numeric(5)]
|
vec![
|
||||||
|
ReleaseId::Numeric(0),
|
||||||
|
ReleaseId::Numeric(18),
|
||||||
|
ReleaseId::Numeric(2)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
assert!(version.pre_release_ids.is_empty());
|
assert!(version.pre_release_ids.is_empty());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user