Skip to content

Commit

Permalink
hudson: Rework tests
Browse files Browse the repository at this point in the history
Change-Id: I0833f4921657f9cfcfe99618372a87785ffc7128
  • Loading branch information
luk1337 committed Dec 24, 2024
1 parent 3a90c8f commit 8d2b780
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/gerrit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ jobs:
ref: ${{ inputs.ref }}

- name: Check
run: |
for file in updater/*.json; do
echo "Checking $file"
jq -e . $file > /dev/null
done
run: ./test.py

- uses: lineageos-infra/gerrit-vote@main
if: always()
Expand Down
42 changes: 42 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
import glob
import json
import unittest


class HudsonTestCase(unittest.TestCase):
def test_build_targets(self):
models_json = set()

with open("updater/devices.json", "r") as f:
for device in json.load(f):
models_json.add(device["model"])

models_hudson = set()

with open("lineage-build-targets", "r") as f:
for line in f.readlines():
line = line.strip()

if not line or line.startswith("#"):
continue

model, _, _, _ = line.split()
models_hudson.add(model)

models_missing = models_hudson - models_json

if models_missing:
self.fail(f"Missing models in devices.json: {', '.join(models_missing)}")

def test_json(self):
for file in glob.glob("updater/*.json"):
with open(file, "r") as f:
try:
json.load(f)
except json.JSONDecodeError as e:
self.fail(f"Failed to load {file}")


if __name__ == "__main__":
unittest.main()

0 comments on commit 8d2b780

Please sign in to comment.