#2 CI tests
Closed 3 years ago by vtrefny. Opened 5 years ago by vtrefny.
Unknown source master_tests  into  master

@@ -0,0 +1,352 @@

+ From cae191ae459e046dc317b7bc57941e3f1cec910d Mon Sep 17 00:00:00 2001

+ From: Vojtech Trefny <vtrefny@redhat.com>

+ Date: Fri, 10 Aug 2018 08:35:51 +0200

+ Subject: [PATCH 1/4] Run all libbytesize tests from one script

+ 

+ This also makes sure we run tests with all supported python versions.

+ ---

+  tests/Makefile.am                | 2 +-

+  tests/libbytesize_unittest.sh.in | 2 ++

+  tests/libbytesize_unittest.sh    | 2 ++

+  3 files changed, 5 insertions(+), 1 deletion(-)

+ 

+ diff --git a/tests/Makefile.am b/tests/Makefile.am

+ index 1f59f64..1e51834 100644

+ --- a/tests/Makefile.am

+ +++ b/tests/Makefile.am

+ @@ -2,7 +2,7 @@ AM_TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)" top_builddir="$(top_builddir)"

+ 

+  dist_noinst_SCRIPTS = libbytesize_unittest.sh libbytesize_unittest.py lbs_py_override_unittest.py locale_utils.py testenv.sh canary_tests.sh

+ 

+ -TESTS = libbytesize_unittest.sh lbs_py_override_unittest.py canary_tests.sh

+ +TESTS = libbytesize_unittest.sh canary_tests.sh

+ 

+  # Add the translation-canary source files to the tarball

+  EXTRA_DIST = $(top_srcdir)/translation-canary/translation_canary/*.py \

+ diff --git a/tests/libbytesize_unittest.sh.in b/tests/libbytesize_unittest.sh.in

+ index 7896675..e5ca56d 100644

+ --- a/tests/libbytesize_unittest.sh.in

+ +++ b/tests/libbytesize_unittest.sh.in

+ @@ -9,10 +9,12 @@ fi

+ 

+  if [ @WITH_PYTHON2@ = 1 ]; then

+      python2 ${srcdir}/libbytesize_unittest.py || status=1

+ +    python2 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+  if [ @WITH_PYTHON3@ = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py || status=1

+ +    python3 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+  if [ @WITH_PYTHON2@ = 1 ]; then

+ diff --git a/tests/libbytesize_unittest.sh b/tests/libbytesize_unittest.sh

+ index 7896675..e5ca56d 100644

+ --- a/tests/libbytesize_unittest.sh

+ +++ b/tests/libbytesize_unittest.sh

+ @@ -9,10 +9,12 @@ fi

+ 

+  if [ 1 = 1 ]; then

+      python2 ${srcdir}/libbytesize_unittest.py || status=1

+ +    python2 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+  if [ 1 = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py || status=1

+ +    python3 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+  if [ 1 = 1 ]; then

+ --

+ 2.20.1

+ 

+ 

+ From 2c376a25813bf6966ec9c6da5a558dd5f4edc423 Mon Sep 17 00:00:00 2001

+ From: Vojtech Trefny <vtrefny@redhat.com>

+ Date: Tue, 5 Mar 2019 14:20:14 +0100

+ Subject: [PATCH 2/4] Add all "public" python API  symbols to __init__.py

+ 

+ So it can be imported as "from bytesize import xyz" instead of

+ "from bytesize.bytesize import xyz".

+ ---

+  src/python/__init__.py | 3 +++

+  1 file changed, 3 insertions(+)

+ 

+ diff --git a/src/python/__init__.py b/src/python/__init__.py

+ index 6ab80dc..57403d5 100644

+ --- a/src/python/__init__.py

+ +++ b/src/python/__init__.py

+ @@ -1 +1,4 @@

+  from .bytesize import Size

+ +from .bytesize import B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB, KB, MB, GB, TB, PB, EB, ZB, YB

+ +from .bytesize import ROUND_UP, ROUND_DOWN, ROUND_HALF_UP

+ +from .bytesize import SizeError, InvalidSpecError, OverflowError, ZeroDivisionError

+ --

+ 2.20.1

+ 

+ 

+ From f07701b397907cefd7e43063b76277cc991f5339 Mon Sep 17 00:00:00 2001

+ From: Vojtech Trefny <vtrefny@redhat.com>

+ Date: Tue, 5 Mar 2019 14:55:20 +0100

+ Subject: [PATCH 3/4] Allow running tests using installed library

+ 

+ We need to be able to import the SizeStruct object from installed

+ python-bytesize.

+ ---

+  tests/libbytesize_unittest.py | 10 ++++++++--

+  1 file changed, 8 insertions(+), 2 deletions(-)

+ 

+ diff --git a/tests/libbytesize_unittest.py b/tests/libbytesize_unittest.py

+ index 5e63778..d7400be 100755

+ --- a/tests/libbytesize_unittest.py

+ +++ b/tests/libbytesize_unittest.py

+ @@ -8,7 +8,14 @@ import ctypes

+ 

+  from locale_utils import get_avail_locales, requires_locales

+ 

+ -from bytesize import SizeStruct, KiB, GiB, ROUND_UP, ROUND_DOWN, ROUND_HALF_UP, OverflowError

+ +from bytesize import KiB, GiB, ROUND_UP, ROUND_DOWN, ROUND_HALF_UP, OverflowError

+ +

+ +# SizeStruct is part of the 'private' API and needs to be imported differently

+ +# when running from locally build tree and when using installed library

+ +try:

+ +    from bytesize import SizeStruct

+ +except ImportError:

+ +    from bytesize.bytesize import SizeStruct

+ 

+  DEFAULT_LOCALE = "en_US.utf8"

+ 

+ @@ -759,4 +766,3 @@ if __name__=='__main__':

+          sys.argv = [sys.argv[0]]

+      unittest.main()

+  #endif

+ -

+ --

+ 2.20.1

+ 

+ 

+ From 4d692ac4eb178121c4e91ab881645aef94d65ed4 Mon Sep 17 00:00:00 2001

+ From: Vojtech Trefny <vtrefny@redhat.com>

+ Date: Wed, 6 Mar 2019 09:27:41 +0100

+ Subject: [PATCH 4/4] Remove Python 2 support

+ 

+ Python 2 EOL is close and we are no longer shipping python2

+ package in newest distributions, so it makes sense to remove

+ Python 2 support entirely.

+ ---

+  Makefile.am                       |  2 +-

+  configure.ac                      | 16 ----------------

+  dist/libbytesize.spec.in          | 31 +------------------------------

+  src/python/Makefile.am            |  9 +--------

+  tests/lbs_py_override_unittest.py |  4 +---

+  tests/libbytesize_unittest.py     |  2 +-

+  tests/libbytesize_unittest.sh.in  |  9 ---------

+  tests/libbytesize_unittest.sh     |  9 ---------

+  8 files changed, 5 insertions(+), 77 deletions(-)

+ 

+ diff --git a/Makefile.am b/Makefile.am

+ index 93279f2..1ac10bd 100644

+ --- a/Makefile.am

+ +++ b/Makefile.am

+ @@ -38,7 +38,7 @@ dist-hook:

+  	done

+ 

+  run-ipython: all

+ -	LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=$(PYTHONDIR) ipython

+ +	LD_LIBRARY_PATH=${LIBDIRS} PYTHONPATH=$(PYTHONDIR) ipython3

+ 

+  check-requires:

+  	@echo "*** Checking if the dependencies required for testing and analysis are available ***"

+ diff --git a/configure.ac b/configure.ac

+ index 749d929..c2306dc 100644

+ --- a/configure.ac

+ +++ b/configure.ac

+ @@ -50,22 +50,6 @@ AC_CHECK_HEADERS([langinfo.h gmp.h mpfr.h stdint.h stdbool.h stdarg.h string.h s

+                   [LIBBYTESIZE_SOFT_FAILURE([Header file $ac_header not found.])],

+                   [])

+ 

+ -AC_ARG_WITH([python2],

+ -    AS_HELP_STRING([--with-python2], [support python2 @<:@default=check@:>@]),

+ -    [],

+ -    [with_python2=check])

+ -

+ -AC_SUBST(WITH_PYTHON2, 0)

+ -if test "x$with_python2" != "xno"; then

+ -    AC_PATH_PROG([python2], [python2], [no])

+ -    AS_IF([test "x$python2" == "xno"],

+ -    [if test "x$with_python2" = "xyes"; then

+ -      LIBBYTESIZE_SOFT_FAILURE([Python2 support requested, but python2 is not available])

+ -      fi],

+ -    [AC_SUBST(WITH_PYTHON2, 1)])

+ -fi

+ -AM_CONDITIONAL(WITH_PYTHON2, test "x$with_python2" != "xno" -a "x$python2" != "xno")

+ -

+  AC_ARG_WITH([python3],

+      AS_HELP_STRING([--with-python3], [support python3 @<:@default=check@:>@]),

+      [],

+ diff --git a/dist/libbytesize.spec.in b/dist/libbytesize.spec.in

+ index 3f306f9..9658a7c 100644

+ --- a/dist/libbytesize.spec.in

+ +++ b/dist/libbytesize.spec.in

+ @@ -1,5 +1,4 @@

+  %define realname bytesize

+ -%define with_python2 @WITH_PYTHON2@

+  %define with_python3 @WITH_PYTHON3@

+  %define with_gtk_doc @WITH_GTK_DOC@

+ 

+ @@ -8,13 +7,7 @@

+  %define python3_opts --without-python3

+  %endif

+ 

+ -# python2 is not available on RHEL > 7 and not needed on Fedora > 28

+ -%if 0%{?rhel} > 7 || 0%{?fedora} > 28 || %{with_python2} == 0

+ -%define with_python2 0

+ -%define python2_opts --without-python2

+ -%endif

+ -

+ -%define configure_opts %{?python3_opts} %{?python2_opts}

+ +%define configure_opts %{?python3_opts}

+ 

+  Name:        libbytesize

+  Version:     1.4

+ @@ -29,9 +22,6 @@ BuildRequires: gmp-devel

+  BuildRequires: mpfr-devel

+  BuildRequires: pcre-devel

+  BuildRequires: gettext-devel

+ -%if %{with_python2}

+ -BuildRequires: python2-devel

+ -%endif

+  %if %{with_python3}

+  BuildRequires: python3-devel

+  %endif

+ @@ -53,19 +43,6 @@ Requires: %{name}%{?_isa} = %{version}-%{release}

+  This package contains header files and pkg-config files needed for development

+  with the libbytesize library.

+ 

+ -%if %{with_python2}

+ -%package -n python2-%{realname}

+ -Summary: Python 2 bindings for libbytesize

+ -%{?python_provide:%python_provide python2-%{realname}}

+ -%{?python_provide:%python_provide python2-libbytesize}

+ -Requires: %{name}%{?_isa} = %{version}-%{release}

+ -Requires: python2-six

+ -

+ -%description -n python2-%{realname}

+ -This package contains Python 2 bindings for libbytesize making the use of

+ -the library from Python 2 easier and more convenient.

+ -%endif

+ -

+  %if %{with_python3}

+  %package -n python3-%{realname}

+  Summary: Python 3 bindings for libbytesize

+ @@ -108,12 +85,6 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}

+  %{_datadir}/gtk-doc/html/libbytesize

+  %endif

+ 

+ -%if %{with_python2}

+ -%files -n python2-%{realname}

+ -%dir %{python2_sitearch}/bytesize

+ -%{python2_sitearch}/bytesize/*

+ -%endif

+ -

+  %if %{with_python3}

+  %files -n python3-%{realname}

+  %dir %{python3_sitearch}/bytesize

+ diff --git a/src/python/Makefile.am b/src/python/Makefile.am

+ index e0261a6..cb2b197 100644

+ --- a/src/python/Makefile.am

+ +++ b/src/python/Makefile.am

+ @@ -1,14 +1,7 @@

+ -if WITH_PYTHON2

+ -pylibdir = $(shell python -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(1,0,prefix='${exec_prefix}'))")

+ -

+ -pybytesizedir     = $(pylibdir)/bytesize

+ -dist_pybytesize_DATA = bytesize.py __init__.py

+ -endif

+ -

+  if WITH_PYTHON3

+  py3libdir = $(shell python3 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(1,0,prefix='${exec_prefix}'))")

+  py3bytesizedir    = $(py3libdir)/bytesize

+ -nodist_py3bytesize_DATA = bytesize.py __init__.py

+ +dist_py3bytesize_DATA = bytesize.py __init__.py

+  endif

+ 

+  MAINTAINERCLEANFILES = Makefile.in

+ diff --git a/tests/lbs_py_override_unittest.py b/tests/lbs_py_override_unittest.py

+ index c5f3cb2..9a219f2 100755

+ --- a/tests/lbs_py_override_unittest.py

+ +++ b/tests/lbs_py_override_unittest.py

+ @@ -1,4 +1,4 @@

+ -#!/usr/bin/env python

+ +#!/usr/bin/python3

+  # -*- coding: utf-8 -*-

+ 

+  import unittest

+ @@ -306,5 +306,3 @@ class SizeTestCase(unittest.TestCase):

+  if __name__=='__main__':

+      unittest.main()

+  #endif

+ -

+ -

+ diff --git a/tests/libbytesize_unittest.py b/tests/libbytesize_unittest.py

+ index d7400be..1c57d2a 100755

+ --- a/tests/libbytesize_unittest.py

+ +++ b/tests/libbytesize_unittest.py

+ @@ -1,4 +1,4 @@

+ -#!/usr/bin/env python2

+ +#!/usr/bin/python3

+  # -*- coding: utf-8 -*-

+ 

+  import locale

+ diff --git a/tests/libbytesize_unittest.sh.in b/tests/libbytesize_unittest.sh.in

+ index e5ca56d..816bc28 100644

+ --- a/tests/libbytesize_unittest.sh.in

+ +++ b/tests/libbytesize_unittest.sh.in

+ @@ -7,20 +7,11 @@ if [ -z "$srcdir" ]; then

+      srcdir="$(dirname "$0")"

+  fi

+ 

+ -if [ @WITH_PYTHON2@ = 1 ]; then

+ -    python2 ${srcdir}/libbytesize_unittest.py || status=1

+ -    python2 ${srcdir}/lbs_py_override_unittest.py || status=1

+ -fi

+ -

+  if [ @WITH_PYTHON3@ = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py || status=1

+      python3 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+ -if [ @WITH_PYTHON2@ = 1 ]; then

+ -    python2 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1

+ -fi

+ -

+  if [ @WITH_PYTHON3@ = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1

+  fi

+ diff --git a/tests/libbytesize_unittest.sh b/tests/libbytesize_unittest.sh

+ index e5ca56d..816bc28 100644

+ --- a/tests/libbytesize_unittest.sh

+ +++ b/tests/libbytesize_unittest.sh

+ @@ -7,20 +7,11 @@ if [ -z "$srcdir" ]; then

+      srcdir="$(dirname "$0")"

+  fi

+ 

+ -if [ 1 = 1 ]; then

+ -    python2 ${srcdir}/libbytesize_unittest.py || status=1

+ -    python2 ${srcdir}/lbs_py_override_unittest.py || status=1

+ -fi

+ -

+  if [ 1 = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py || status=1

+      python3 ${srcdir}/lbs_py_override_unittest.py || status=1

+  fi

+ 

+ -if [ 1 = 1 ]; then

+ -    python2 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1

+ -fi

+ -

+  if [ 1 = 1 ]; then

+      python3 ${srcdir}/libbytesize_unittest.py fr_FR.UTF8 || status=1

+  fi

+ --

+ 2.20.1

file modified
+11 -31
@@ -1,5 +1,4 @@

  %define realname bytesize

- %define with_python2 1

  %define with_python3 1

  %define with_gtk_doc 1

  
@@ -8,30 +7,25 @@

  %define python3_opts --without-python3

  %endif

  

- # python2 is not available on RHEL > 7 and not needed on Fedora > 28

- %if 0%{?rhel} > 7 || 0%{?fedora} > 28 || %{with_python2} == 0

- %define with_python2 0

- %define python2_opts --without-python2

- %endif

- 

- %define configure_opts %{?python3_opts} %{?python2_opts}

+ %define configure_opts %{?python3_opts}

  

  Name:        libbytesize

  Version:     1.4

- Release:     2%{?dist}

+ Release:     3%{?dist}

  Summary:     A library for working with sizes in bytes

  License:     LGPLv2+

  URL:         https://github.com/storaged-project/libbytesize

  Source0:     https://github.com/storaged-project/libbytesize/releases/download/%{version}-%{release}/%{name}-%{version}.tar.gz

+ Patch0:      libbytesize-tests.patch

  

  BuildRequires: gcc

+ BuildRequires: autoconf

+ BuildRequires: automake

+ BuildRequires: libtool

  BuildRequires: gmp-devel

  BuildRequires: mpfr-devel

  BuildRequires: pcre-devel

  BuildRequires: gettext-devel

- %if %{with_python2}

- BuildRequires: python2-devel

- %endif

  %if %{with_python3}

  BuildRequires: python3-devel

  %endif
@@ -53,19 +47,6 @@

  This package contains header files and pkg-config files needed for development

  with the libbytesize library.

  

- %if %{with_python2}

- %package -n python2-%{realname}

- Summary: Python 2 bindings for libbytesize

- %{?python_provide:%python_provide python2-%{realname}}

- %{?python_provide:%python_provide python2-libbytesize}

- Requires: %{name}%{?_isa} = %{version}-%{release}

- Requires: python2-six

- 

- %description -n python2-%{realname}

- This package contains Python 2 bindings for libbytesize making the use of

- the library from Python 2 easier and more convenient.

- %endif

- 

  %if %{with_python3}

  %package -n python3-%{realname}

  Summary: Python 3 bindings for libbytesize
@@ -79,8 +60,10 @@

  

  %prep

  %setup -q -n %{name}-%{version}

+ %patch0 -p1

  

  %build

+ autoreconf -ivf

  %configure %{?configure_opts}

  %{__make} %{?_smp_mflags}

  
@@ -108,12 +91,6 @@

  %{_datadir}/gtk-doc/html/libbytesize

  %endif

  

- %if %{with_python2}

- %files -n python2-%{realname}

- %dir %{python2_sitearch}/bytesize

- %{python2_sitearch}/bytesize/*

- %endif

- 

  %if %{with_python3}

  %files -n python3-%{realname}

  %dir %{python3_sitearch}/bytesize
@@ -122,6 +99,9 @@

  %endif

  

  %changelog

+ * Wed Mar 20 2019 Vojtech Trefny <vtrefny@redhat.com> - 1.4-1

+ - Run CI tests

+ 

  * Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

  

file added
+17
@@ -0,0 +1,17 @@

+ - hosts: localhost

+   roles:

+   - role: standard-test-source

+     tags:

+     - classic

+ 

+   - role: standard-test-basic

+     tags:

+     - classic

+     tests:

+     - upstream_test_suite:

+         dir: source

+         run: tests/libbytesize_unittest.sh

+     required_packages:

+     - glibc-all-langpacks

+     - python3-polib

+     - python3-six