#131 CI tests: Use `! grep` to assert something is missing
Merged 3 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/pyproject-rpm-macros grep_v  into  master

@@ -42,8 +42,8 @@ 

  

  %check

  # Internal check: Top level __pycache__ is never owned

- grep -vE '/__pycache__$' %{pyproject_files}

- grep -vE '/__pycache__/$' %{pyproject_files}

+ ! grep -E '/__pycache__$' %{pyproject_files}

+ ! grep -E '/__pycache__/$' %{pyproject_files}

  grep -F '/__pycache__/' %{pyproject_files}

  

  

file modified
+1 -1
@@ -47,7 +47,7 @@ 

  test -d %{buildroot}%{python3_sitelib}/%{modname}-%{version}.dist-info/

  

  # Internal check that executables are not present when +auto was not used with %%pyproject_save_files

- grep -vF %{buildroot}%{_bindir}/%{modname} %{pyproject_files}

+ ! grep -F %{buildroot}%{_bindir}/%{modname} %{pyproject_files}

  

  

  %files -n python3-%{modname} -f %{pyproject_files}

file modified
+6 -6
@@ -64,14 +64,14 @@ 

  

  # Internal check: Unmatched modules are not supposed to be listed in %%{pyproject_files}

  # We'll list them explicitly

- grep -vF %{python3_sitearch}/ldif.py %{pyproject_files}

- grep -vF %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.pyc %{pyproject_files}

- grep -vF %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.opt-1.pyc %{pyproject_files}

- grep -vF %{python3_sitearch}/slapdtest/ %{pyproject_files}

+ ! grep -F %{python3_sitearch}/ldif.py %{pyproject_files}

+ ! grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.pyc %{pyproject_files}

+ ! grep -F %{python3_sitearch}/__pycache__/ldif.cpython-%{python3_version_nodots}.opt-1.pyc %{pyproject_files}

+ ! grep -F %{python3_sitearch}/slapdtest %{pyproject_files}

  

  # Internal check: Top level __pycache__ is never owned

- grep -vE '/__pycache__$' %{pyproject_files}

- grep -vE '/__pycache__/$' %{pyproject_files}

+ ! grep -E '/__pycache__$' %{pyproject_files}

+ ! grep -E '/__pycache__/$' %{pyproject_files}

  

  

  %files -n python3-ldap -f %{pyproject_files}

Previously, we have used grep -v to assert something is not there.
However, that doesn't work. See for example this file:

$ cat TEST
line1
line2
line3

$ grep -v line4 TEST
line1
line2
line3
$ echo $?
0

This gives a false sense of correctness, however it exits will 0 with anything:

$ grep -v line3 TEST
line1
line2
$ echo $?
0

Instead, we use ! grep now:

$ ! grep line4 TEST
$ echo $?
0

$ ! grep line3 TEST
line3
$ echo $?
1

Additionally, remove a trailing slash from one of the checks to match both cases
(with or without the slash).

Build succeeded.

Ah, sneaky bug. Makes sense, LGTM.

Pull-Request has been merged by churchyard

3 years ago

Build succeeded.