Skip to content

Commit f704f43

Browse files
committed
chore: add test for ninja script
1 parent b690942 commit f704f43

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
coverage>=4.2
2+
importlib_metadata>=2.0
23
pytest>=4.5.0
34
pytest-cov>=2.7.1

tests/test_ninja.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# -*- coding: utf-8 -*-
2+
import os
23
import subprocess
34
import sys
5+
import sysconfig
46

57
import pytest
8+
from importlib_metadata import distribution
69

710
import ninja
811

@@ -17,6 +20,16 @@ def _run(program, args):
1720
assert excinfo.value.code == 0
1821

1922

23+
def _get_scripts():
24+
dist = distribution("ninja")
25+
scripts_paths = [os.path.abspath(sysconfig.get_path("scripts", scheme)) for scheme in sysconfig.get_scheme_names()]
26+
scripts = []
27+
for file in dist.files:
28+
if os.path.abspath(str(file.locate().parent)) in scripts_paths:
29+
scripts.append(file.locate().resolve(strict=True))
30+
return scripts
31+
32+
2033
def test_ninja_module():
2134
_run("ninja", ["--version"])
2235

@@ -25,3 +38,12 @@ def test_ninja_package():
2538
expected_version = "1.11.1.git.kitware.jobserver-1"
2639
output = subprocess.check_output([sys.executable, "-m", "ninja", "--version"]).decode("ascii")
2740
assert output.splitlines()[0] == expected_version
41+
42+
43+
def test_ninja_script():
44+
expected_version = "1.11.1.git.kitware.jobserver-1"
45+
scripts = _get_scripts()
46+
assert len(scripts) == 1
47+
assert scripts[0].stem == "ninja"
48+
output = subprocess.check_output([str(scripts[0]), "--version"]).decode("ascii")
49+
assert output.splitlines()[0] == expected_version

0 commit comments

Comments
 (0)