added a python script for testing and a drone config for CI

This commit is contained in:
Lynne Megido 2021-02-28 21:08:35 +10:00
parent 809df5bc0e
commit bcd77d9ed6
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
4 changed files with 50 additions and 1 deletions

10
.drone.yml Normal file
View file

@ -0,0 +1,10 @@
---
kind: pipeline
type: docker
name: default
steps:
- name: build
image: rust:latest
commands:
- cargo test

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
/imgs /imgs
fif_* fif_*
/old /old
/.mypy_cache
*.sh *.sh
!clippy.sh !clippy.sh
cargo-timing*.html cargo-timing*.html

View file

@ -10,7 +10,7 @@ repository = "https://git.bune.city/lynnesbian/fif"
readme = "README.md" readme = "README.md"
keywords = ["mime", "mimetype", "utilities", "tools"] keywords = ["mime", "mimetype", "utilities", "tools"]
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
exclude = [".idea/", "Cross.toml", "*.sh"] exclude = [".idea/", "Cross.toml", "*.sh", "*.py", ".drone.yml"]
#resolver = "2" #resolver = "2"
#license-file = "LICENSE" #license-file = "LICENSE"

38
test.py Executable file
View file

@ -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()