-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from cgwalters/more-tests-2
tests: Add pytest and nushell based tests
- Loading branch information
Showing
11 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.cosa | ||
target | ||
!target/dev-rootfs | ||
# These directories don't contribute to our container build | ||
docs/ | ||
plans/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: Python static analysis | ||
on: [push, pull_request] | ||
jobs: | ||
ruff: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: chartboost/ruff-action@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ test-tmt: | |
validate: | ||
cargo fmt | ||
cargo clippy | ||
ruff check | ||
.PHONY: validate | ||
|
||
vendor: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
# This tmt test just demonstrates local tmt usage. | ||
# We'll hopefully expand it to do more interesting things in the | ||
# future and unify with the other test plans. | ||
# Run this via `make test-tmt` which will build a container, | ||
# and a disk image from it. | ||
provision: | ||
how: virtual | ||
# Generated by `cargo xtask ` | ||
# Generated by make test-tmt | ||
image: file://./target/testvm/disk.qcow2 | ||
disk: 20 | ||
summary: Basic smoke test | ||
summary: Execute booted tests | ||
execute: | ||
how: tmt | ||
script: bootc status | ||
# There's currently two dynamic test frameworks; python and nushell. | ||
# python is well known and understood. nushell is less well known, but | ||
# is quite nice for running subprocesses and the like while making | ||
# it easy to parse JSON etc. | ||
script: | | ||
set -xeu | ||
pytest tests/booted/*.py | ||
ls tests/booted/*-test-*.nu |sort -n | while read t; do nu $t; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use std assert | ||
use tap.nu | ||
|
||
tap begin "verify bootc status --json looks sane" | ||
|
||
let st = bootc status --json | from json | ||
assert equal $st.apiVersion org.containers.bootc/v1alpha1 | ||
tap ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Booted tests | ||
|
||
These are intended to run via tmt; use e.g. | ||
`make test-tmt`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Tests which are read-only/nondestructive | ||
|
||
import json | ||
import subprocess | ||
|
||
def run(*args): | ||
subprocess.check_call(*args) | ||
|
||
def test_bootc_status(): | ||
o = subprocess.check_output(["bootc", "status", "--json"]) | ||
st = json.loads(o) | ||
assert st['apiVersion'] == 'org.containers.bootc/v1alpha1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A simple nushell "library" for the | ||
# "Test anything protocol": | ||
# https://testanything.org/tap-version-14-specification.html | ||
export def begin [description] { | ||
print "TAP version 14" | ||
print $description | ||
} | ||
|
||
export def ok [] { | ||
print "ok" | ||
} | ||
|
||
export def fail [] { | ||
print "not ok" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters