2021-02-28 11:08:35 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2022-01-22 16:41:24 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2022 Lynnesbian
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2021-10-05 14:24:08 +00:00
|
|
|
|
2021-02-28 11:08:35 +00:00
|
|
|
import re
|
|
|
|
import subprocess
|
2021-04-06 19:20:49 +00:00
|
|
|
import sys
|
2021-02-28 11:08:35 +00:00
|
|
|
|
2022-01-23 14:16:06 +00:00
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
def test_archs():
|
2021-07-21 11:17:10 +00:00
|
|
|
archs = ["aarch64", "powerpc", "riscv64gc"]
|
2021-04-06 19:20:49 +00:00
|
|
|
upto = 1
|
|
|
|
target = len(archs)
|
|
|
|
|
|
|
|
for arch in archs:
|
|
|
|
print(f"Testing {arch} ({upto} of {target})")
|
2022-01-23 14:16:06 +00:00
|
|
|
subprocess\
|
|
|
|
.run(f"cross test --features=json,infer-backend --target {arch}-unknown-linux-gnu".split(" "))\
|
|
|
|
.check_returncode()
|
2021-04-06 19:20:49 +00:00
|
|
|
upto += 1
|
|
|
|
|
2022-01-23 14:16:06 +00:00
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
def test_versions():
|
2021-02-28 11:08:35 +00:00
|
|
|
match = re.search(
|
|
|
|
r'rust-version ?= ?"([\d.]+)"',
|
|
|
|
open("Cargo.toml", "r").read(-1)
|
|
|
|
)
|
|
|
|
|
|
|
|
if not match:
|
|
|
|
print("Couldn't find rust-version")
|
|
|
|
exit(1)
|
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
versions = [match.group(1), "stable", "nightly"]
|
2021-02-28 11:08:35 +00:00
|
|
|
backends = ["xdg-mime", "infer"]
|
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
upto = 1
|
2021-02-28 11:08:35 +00:00
|
|
|
target = len(versions) * len(backends) * 2
|
|
|
|
|
|
|
|
for version in versions:
|
|
|
|
for backend in backends:
|
2021-04-06 19:20:49 +00:00
|
|
|
print(f"[{version}, {backend}] Tests ({upto} of {target})")
|
2021-09-22 16:34:10 +00:00
|
|
|
subprocess.run(f"cargo +{version} test --features=json,{backend}-backend".split(" ")).check_returncode()
|
2021-04-06 19:20:49 +00:00
|
|
|
upto += 1
|
2021-02-28 11:08:35 +00:00
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
print(f"[{version}, {backend}] Scanning imgs ({upto} of {target})")
|
2022-01-23 14:16:06 +00:00
|
|
|
subprocess\
|
|
|
|
.run(f"cargo +{version} run --release --features=json,{backend}-backend -- imgs".split(" "))\
|
|
|
|
.check_returncode()
|
2021-04-06 19:20:49 +00:00
|
|
|
upto += 1
|
|
|
|
|
2022-01-23 14:16:06 +00:00
|
|
|
|
2021-04-06 19:20:49 +00:00
|
|
|
def main():
|
|
|
|
done_something = False
|
|
|
|
if "versions" in sys.argv:
|
|
|
|
test_versions()
|
|
|
|
done_something = True
|
|
|
|
if "archs" in sys.argv:
|
|
|
|
test_archs()
|
|
|
|
done_something = True
|
|
|
|
|
|
|
|
if not done_something:
|
|
|
|
print("You must supply at least one of `versions` or `archs` as an argument! 0uo")
|
|
|
|
sys.exit(2)
|
2021-02-28 11:08:35 +00:00
|
|
|
|
|
|
|
print("Done! You might want to run cargo clean...")
|
2021-08-06 13:33:42 +00:00
|
|
|
subprocess.run(["du", "-sh", "target"])
|
2021-02-28 11:08:35 +00:00
|
|
|
|
2022-01-23 14:16:06 +00:00
|
|
|
|
2021-02-28 11:08:35 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|