Verified Commit 43b8a4ba authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Use pytest and update coverage configs

parent 1854cf97
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -12,7 +12,5 @@ build/
dist/

# unit-testing, coverage, etc.
/*.xml
/*.json
.coverage*
.noseids
/*_cache/
/results/
+33 −34
Original line number Diff line number Diff line
@@ -22,55 +22,54 @@ cache:
  stage: test
  image: python:$PY_VERSION
  before_script:
    - pip install -e .[test] nose2
  - pip install -e .[test] coverage pytest
  - mkdir results
  script:
    - nose2 -v -c setup.cfg
  - coverage run -m pytest -v --junit-xml=results/junit.xml tests/unit
  after_script:
    - mv .coverage .coverage.$PY_VERSION
    - mv .unittest.xml .unittest.$PY_VERSION.xml
  coverage: '/^TOTAL.* ([0-9.]+\%)$/'
  - mv results results.$PY_VERSION
  artifacts:
    when: always
    paths:
      - .noseids
      - .coverage.*
      - .unittest.$PY_VERSION.xml
    - results.$PY_VERSION
    reports:
      junit: .unittest.$PY_VERSION.xml
      junit: results.$PY_VERSION/junit.xml

unittest:3.8:
  extends: .unittest
Unit Tests (Py 3.10):
  extends: [.unittest]
  variables:
    PY_VERSION: '3.8'
    PY_VERSION: '3.10'

unittest:3.9:
  extends: .unittest
Unit Tests (Py 3.11):
  extends: [.unittest]
  variables:
    PY_VERSION: '3.9'
    PY_VERSION: '3.11'

unittest:3.10:
  extends: .unittest
Unit Tests (Py 3.12):
  extends: [.unittest]
  variables:
    PY_VERSION: '3.10-rc'
    PY_VERSION: '3.12'

publish:unittests:
  stage: publish
  when: always
  dependencies: &unittests
    - unittest:3.8
    - unittest:3.9
    - unittest:3.10
  - Unit Tests (Py 3.10)
  - Unit Tests (Py 3.11)
  - Unit Tests (Py 3.12)
  needs: *unittests
  script:
  - pip install --upgrade junit2html
  - mkdir -p unittest
    - python util/junit_merge.py .unittest.*.xml > .unittest.xml
    - junit2html .unittest.xml unittest/index.html
  - python util/junit_merge.py results.*/junit.xml > junit.xml
  - junit2html junit.xml unittest/index.html
  artifacts:
    when: always
    paths:
      - .unittest.xml
    - junit.xml
    - unittest
    reports:
      junit: junit.xml


# Aggregate Coverage
@@ -82,13 +81,13 @@ coverage:
  needs: *unittests
  script:
  - pip install --upgrade coverage
    - coverage combine
  - coverage combine results.*/coverage.db
  - coverage report
  coverage: '/^TOTAL.* ([0-9.]+\%)$/'
  artifacts:
    when: always
    paths:
      - .coverage
    - results

publish:coverage:
  stage: publish
@@ -97,12 +96,12 @@ publish:coverage:
  needs: [coverage]
  script:
    - pip install --upgrade coverage
    - coverage html --fail-under=0 -d coverage
    - coverage xml  --fail-under=0 -o coverage/coverage.xml
    - coverage html --fail-under=0 -d results/coverage.html
    - coverage xml  --fail-under=0 -o results/coverage.xml
  artifacts:
    when: always
    paths:
      - coverage
    - results


# Quality Assurance
+34 −0
Original line number Diff line number Diff line
@@ -16,3 +16,37 @@ implicit_reexport = true
strict = true
warn_unreachable = true
warn_unused_configs = true


[tool.coverage.run]
data_file = "results/coverage.db"
branch = true
source = ["wpa_supplicant"]

[tool.coverage.report]
precision = 2
skip_empty = true
exclude_lines = [
	"pragma: no-cover",
	"if .*\\b__name__\\b",
	"if .*\\bTYPE_CHECKING\\b",
	"class .*(.*\\bProtocol\\b.*):",
	"def __repr__",
	"@overload",
	"@(abc\\.)abstractmethod",
]
partial_branches = [
	"pragma: no-branch",
	"if .*\\b__debug__\\b",
]

[tool.coverage.json]
output = "results/coverage.json"
show_contexts = true

[tool.coverage.xml]
output = "results/coverage.xml"

[tool.coverage.html]
directory = "results/coverage"
show_contexts = true
+0 −44
Original line number Diff line number Diff line
@@ -45,50 +45,6 @@ test =
  nose2[coverage_plugin]
  trio

[unittest]
start-dir = tests/unit
verbose = True
plugins =
  nose2.plugins.junitxml
  nose2.plugins.testid

[coverage]
always-on = True
coverage = wpa_supplicant
coverage-report = term

[coverage:run]
branch = True

[coverage:report]
fail_under = 80
precision = 2
show_missing = True
omit = **/__main__.py
exclude_lines =
  pragma: no cover
  if __name__ == .__main__.:
  def __repr__
  __version__ =
  @(.*\.)?abstract((static|class)?method|property)
  except ImportError:\s*(...|pass)

[coverage:xml]
output = .coverage.xml

[coverage:html]
directory = .coverage.html.d

[junit-xml]
always-on = True
path = .unittest.xml

[testid]
always-on = True

[log-capture]
always-on = True

[isort]
force_single_line = true