mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
Adapt the Python test script to the new Ouch interface
This commit is contained in:
parent
94ecc63886
commit
1c5005f5a9
@ -12,9 +12,9 @@ def make_random_file():
|
||||
def sanity_check_format(format: str):
|
||||
make_random_file()
|
||||
md5sum = hashlib.md5(open('test-file', 'rb').read()).hexdigest()
|
||||
os.system(f"cargo run -- -i test-file -o test-file.{format}")
|
||||
os.system(f"cargo run -- compress test-file test-file.{format}")
|
||||
os.remove('test-file')
|
||||
os.system(f"cargo run -- -i test-file.{format}")
|
||||
os.system(f"cargo run -- test-file.{format}")
|
||||
if md5sum != hashlib.md5(open('test-file', 'rb').read()).hexdigest():
|
||||
print("Something went wrong with tar (de)compression.")
|
||||
os._exit(2)
|
||||
@ -81,16 +81,16 @@ if __name__ == "__main__":
|
||||
print(f"Failed while decompressing {file}")
|
||||
os._exit(2)
|
||||
|
||||
# os.chdir("..")
|
||||
# os.system("rm -rf testbuilds")
|
||||
os.chdir("..")
|
||||
os.system("rm -rf testbuilds")
|
||||
|
||||
# # We'll now verify if ouch is not altering the data it is compressing
|
||||
# # and decompressing
|
||||
# We'll now verify if ouch is not altering the data it is compressing
|
||||
# and decompressing
|
||||
|
||||
# sanity_check_format("zip")
|
||||
# sanity_check_format("tar")
|
||||
# sanity_check_format("tar.gz")
|
||||
# sanity_check_format("tar.bz")
|
||||
# sanity_check_format("tar.bz2")
|
||||
# sanity_check_format("tar.lz")
|
||||
# sanity_check_format("tar.lzma")
|
||||
sanity_check_format("zip")
|
||||
sanity_check_format("tar")
|
||||
sanity_check_format("tar.gz")
|
||||
sanity_check_format("tar.bz")
|
||||
sanity_check_format("tar.bz2")
|
||||
sanity_check_format("tar.lz")
|
||||
sanity_check_format("tar.lzma")
|
@ -19,7 +19,8 @@ use crate::{
|
||||
dialogs::Confirmation,
|
||||
extension::{CompressionFormat, Extension},
|
||||
file::File,
|
||||
utils
|
||||
utils,
|
||||
debug
|
||||
};
|
||||
|
||||
pub struct Evaluator {}
|
||||
@ -213,7 +214,7 @@ impl Evaluator {
|
||||
output: Option<&Path>,
|
||||
flags: &oof::Flags,
|
||||
) -> crate::Result<()> {
|
||||
let file = File::from(file_path)?;
|
||||
let file = debug!(File::from(file_path)?);
|
||||
let output = match output {
|
||||
Some(inner) => Some(File::from(inner)?),
|
||||
None => None,
|
||||
|
@ -7,7 +7,7 @@ use std::{
|
||||
|
||||
use CompressionFormat::*;
|
||||
|
||||
use crate::utils::to_utf;
|
||||
use crate::{debug, utils::to_utf};
|
||||
|
||||
/// Represents the extension of a file, but only really caring about
|
||||
/// compression formats (and .tar).
|
||||
|
@ -19,13 +19,12 @@ pub struct File<'a> {
|
||||
|
||||
impl<'a> File<'a> {
|
||||
pub fn from(path: &'a Path) -> crate::Result<Self> {
|
||||
let extension = Extension::from(path.as_ref())?;
|
||||
eprintln!("dev warning: Should we really ignore the errors from the convertion above?");
|
||||
let extension = Extension::from(path.as_ref()).ok();
|
||||
|
||||
Ok(File {
|
||||
path,
|
||||
contents_in_memory: None,
|
||||
extension: Some(extension),
|
||||
extension
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user