diff options
| author | John Turner <jturner.usa@gmail.com> | 2025-11-28 17:13:47 +0000 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2025-11-28 17:13:47 +0000 |
| commit | 558e213ab496ccb7949dab36aeb60149d3137d99 (patch) | |
| tree | a5f7bc77e05278d54ce3ae27af57d0da4fd708e4 /tests | |
| parent | ee5b3c8166be03876286508babfacde6d0a6cf54 (diff) | |
| download | gentoo-utils-558e213ab496ccb7949dab36aeb60149d3137d99.tar.gz | |
add porthole tests to meson
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/meson.build | 19 | ||||
| -rw-r--r-- | tests/porthole/meson.build | 5 | ||||
| -rw-r--r-- | tests/porthole/porthole.rs (renamed from tests/porthole.rs) | 20 | ||||
| -rw-r--r-- | tests/porthole/porthole.txt | 19 |
4 files changed, 52 insertions, 11 deletions
diff --git a/tests/meson.build b/tests/meson.build index 69052cd..e99c9c7 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1 +1,18 @@ -subdir('fuzz') +tests = {} + +subdir('porthole') + +foreach test, test_args : tests + name = fs.name(test) + + test( + f'test_@name@', + executable( + f'test_@name@', + test, + dependencies: [mon, itertools], + link_with: [gentoo_utils], + ), + args: test_args, + ) +endforeach diff --git a/tests/porthole/meson.build b/tests/porthole/meson.build new file mode 100644 index 0000000..68f68fa --- /dev/null +++ b/tests/porthole/meson.build @@ -0,0 +1,5 @@ +tests += { + meson.current_source_dir() / 'porthole.rs': [ + meson.current_source_dir() / 'porthole.txt', + ], +} diff --git a/tests/porthole.rs b/tests/porthole/porthole.rs index 3efbffe..4ff8d49 100644 --- a/tests/porthole.rs +++ b/tests/porthole/porthole.rs @@ -1,4 +1,4 @@ -use std::cmp::Ordering; +use std::{cmp::Ordering, env, fs}; use gentoo_utils::{ Parseable, @@ -6,11 +6,6 @@ use gentoo_utils::{ }; use mon::{Parser, input::InputIter, tag}; -static PORTHOLE_TXT: &'static str = include_str!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/testdata/porthole.txt" -)); - enum Operator { Comment, Yes, @@ -31,16 +26,21 @@ fn parse_operator<'a>() -> impl Parser<&'a str, Output = Operator> { comment.or(yes).or(no).or(eq).or(gt).or(lt) } -#[test] -fn test_porthole() { - for line in PORTHOLE_TXT.lines() { +fn main() { + let path = env::args() + .nth(1) + .expect("pass path to porthole.txt as first parameter"); + + let porthole_txt = fs::read_to_string(&path).expect("failed to open porthole.txt"); + + for line in porthole_txt.lines() { if line.is_empty() { continue; } let operator = parse_operator() .parse_finished(InputIter::new( - line.split_ascii_whitespace().nth(0).unwrap(), + line.split_ascii_whitespace().next().unwrap(), )) .unwrap(); diff --git a/tests/porthole/porthole.txt b/tests/porthole/porthole.txt new file mode 100644 index 0000000..99abf89 --- /dev/null +++ b/tests/porthole/porthole.txt @@ -0,0 +1,19 @@ ++ something/package ++ something/package +- some#thing/package ++ =cat/package-1.0:0/2.0 +- something/pac?kage +- =something/+package-1.0:3.0 +- a b c + ++ >=media-video/knob-goblin-1.0_alpha-r4 ++ media-video/knobgoblin:4 + +- /hello +- group/-1.0 +- >=/ +- >=media-video/revised-knob-3.0aaaaaaaaa-r15 + +*** sanity check +> cat/test-2.0 cat/test-1.0 +< cat/test-1.0 cat/test-2.0 |
