From bcd77d9ed6d5308799d25a69e87be189252580b7 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Sun, 28 Feb 2021 21:08:35 +1000 Subject: [PATCH] added a python script for testing and a drone config for CI --- .drone.yml | 10 ++++++++++ .gitignore | 1 + Cargo.toml | 2 +- test.py | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .drone.yml create mode 100755 test.py diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..f115db3 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,10 @@ +--- +kind: pipeline +type: docker +name: default + +steps: +- name: build + image: rust:latest + commands: + - cargo test diff --git a/.gitignore b/.gitignore index 7744931..99c0e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /imgs fif_* /old +/.mypy_cache *.sh !clippy.sh cargo-timing*.html diff --git a/Cargo.toml b/Cargo.toml index 308bfd3..514d7cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://git.bune.city/lynnesbian/fif" readme = "README.md" keywords = ["mime", "mimetype", "utilities", "tools"] categories = ["command-line-utilities"] -exclude = [".idea/", "Cross.toml", "*.sh"] +exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"] #resolver = "2" #license-file = "LICENSE" diff --git a/test.py b/test.py new file mode 100755 index 0000000..1b49df9 --- /dev/null +++ b/test.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import re +import subprocess + +def main(): + match = re.search( + r'rust-version ?= ?"([\d.]+)"', + open("Cargo.toml", "r").read(-1) + ) + + if not match: + print("Couldn't find rust-version") + exit(1) + + versions = [match.group(1), "stable", "beta", "nightly"] + backends = ["xdg-mime", "infer"] + + done = 0 + target = len(versions) * len(backends) * 2 + + for version in versions: + for backend in backends: + print(f"[{version}, {backend}] Tests") + subprocess.run(f"cargo +{version} test --features={backend}-backend".split(" ")) + done += 1 + print(f"Success - {done} of {target} complete") + + print(f"[{version}, {backend}] Scanning imgs") + subprocess.run(f"cargo +{version} run --release --features={backend}-backend -- -E images imgs".split(" ")) + done += 1 + print(f"Success - {done} of {target} complete") + + print("Done! You might want to run cargo clean...") + +if __name__ == "__main__": + main() +