testutils: Port to cxx-rs
Another easy port like cliwrap.
This commit is contained in:
parent
bdf8269dfa
commit
241cce1ec4
@ -72,6 +72,11 @@ mod ffi {
|
|||||||
fn script_is_ignored(pkg: &str, script: &str) -> bool;
|
fn script_is_ignored(pkg: &str, script: &str) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// testutils.rs
|
||||||
|
extern "Rust" {
|
||||||
|
fn testutils_entrypoint(argv: Vec<String>) -> Result<()>;
|
||||||
|
}
|
||||||
|
|
||||||
/// Currently cxx-rs doesn't support mappings; like probably most projects,
|
/// Currently cxx-rs doesn't support mappings; like probably most projects,
|
||||||
/// by far our most common case is a mapping from string -> string and since
|
/// by far our most common case is a mapping from string -> string and since
|
||||||
/// our data sizes aren't large, we serialize this as a vector of strings pairs.
|
/// our data sizes aren't large, we serialize this as a vector of strings pairs.
|
||||||
@ -158,7 +163,7 @@ pub use self::progress::*;
|
|||||||
mod scripts;
|
mod scripts;
|
||||||
pub(crate) use self::scripts::*;
|
pub(crate) use self::scripts::*;
|
||||||
mod testutils;
|
mod testutils;
|
||||||
pub use self::testutils::*;
|
pub(crate) use self::testutils::*;
|
||||||
mod treefile;
|
mod treefile;
|
||||||
pub use self::treefile::*;
|
pub use self::treefile::*;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
@ -208,28 +208,10 @@ fn update_os_tree(opts: &SyntheticUpgradeOpts) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testutils_main(args: &[String]) -> Result<()> {
|
pub(crate) fn testutils_entrypoint(args: Vec<String>) -> Result<()> {
|
||||||
let opt = Opt::from_iter(args.iter());
|
let opt = Opt::from_iter(args.iter());
|
||||||
match opt {
|
match opt {
|
||||||
Opt::GenerateSyntheticUpgrade(ref opts) => update_os_tree(opts)?,
|
Opt::GenerateSyntheticUpgrade(ref opts) => update_os_tree(opts)?,
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
mod ffi {
|
|
||||||
use super::*;
|
|
||||||
use glib_sys;
|
|
||||||
use libc;
|
|
||||||
|
|
||||||
use crate::ffiutil::*;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn ror_testutils_entrypoint(
|
|
||||||
argv: *mut *mut libc::c_char,
|
|
||||||
gerror: *mut *mut glib_sys::GError,
|
|
||||||
) -> libc::c_int {
|
|
||||||
let v: Vec<String> = unsafe { glib::translate::FromGlibPtrContainer::from_glib_none(argv) };
|
|
||||||
int_glib_error(testutils_main(&v), gerror)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub use self::ffi::*;
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "rpmostree-builtins.h"
|
#include "rpmostree-builtins.h"
|
||||||
#include "rpmostree-rpm-util.h"
|
#include "rpmostree-rpm-util.h"
|
||||||
#include "rpmostree-rust.h"
|
#include "rpmostree-rust.h"
|
||||||
|
#include "rpmostree-cxxrs.h"
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
rpmostree_testutils_builtin_inject_pkglist (int argc, char **argv,
|
rpmostree_testutils_builtin_inject_pkglist (int argc, char **argv,
|
||||||
@ -51,11 +52,11 @@ rpmostree_builtin_testutils (int argc, char **argv,
|
|||||||
invocation, cancellable, error);
|
invocation, cancellable, error);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_autoptr(GPtrArray) args = g_ptr_array_new ();
|
rust::Vec<rust::String> rustargv;
|
||||||
for (int i = 0; i < argc; i++)
|
for (int i = 0; i < argc; i++)
|
||||||
g_ptr_array_add (args, argv[i]);
|
rustargv.push_back(std::string(argv[i]));
|
||||||
g_ptr_array_add (args, NULL);
|
rpmostreecxx::testutils_entrypoint (rustargv);
|
||||||
return ror_testutils_entrypoint ((char**)args->pdata, error);
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user