|
|
|
@ -12,18 +12,15 @@ |
|
|
|
|
# See the License for the specific language governing permissions and |
|
|
|
|
# limitations under the License. |
|
|
|
|
|
|
|
|
|
import os |
|
|
|
|
import unittest |
|
|
|
|
import pathlib |
|
|
|
|
import subprocess |
|
|
|
|
import glob, os, pathlib, shutil, subprocess, unittest |
|
|
|
|
|
|
|
|
|
from run_tests import ( |
|
|
|
|
Backend |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
from .allplatformstests import git_init |
|
|
|
|
|
|
|
|
|
from .baseplatformtests import BasePlatformTests |
|
|
|
|
|
|
|
|
|
from mesonbuild.mesonlib import TemporaryDirectoryWinProof |
|
|
|
|
|
|
|
|
|
class PythonTests(BasePlatformTests): |
|
|
|
@ -60,3 +57,34 @@ python = pymod.find_installation('python3', required: true) |
|
|
|
|
git_init(dirstr) |
|
|
|
|
self.init(dirstr) |
|
|
|
|
subprocess.check_call(self.meson_command + ['dist', '-C', self.builddir], stdout=subprocess.DEVNULL) |
|
|
|
|
|
|
|
|
|
def _test_bytecompile(self, py2=False): |
|
|
|
|
testdir = os.path.join(self.src_root, 'test cases', 'python', '2 extmodule') |
|
|
|
|
|
|
|
|
|
self.init(testdir, extra_args=['-Dpython2=auto', '-Dpython.bytecompile=1']) |
|
|
|
|
self.build() |
|
|
|
|
self.install() |
|
|
|
|
|
|
|
|
|
count = 0 |
|
|
|
|
for root, dirs, files in os.walk(self.installdir): |
|
|
|
|
for file in files: |
|
|
|
|
realfile = os.path.join(root, file) |
|
|
|
|
if file.endswith('.py'): |
|
|
|
|
cached = glob.glob(realfile+'?') + glob.glob(os.path.join(root, '__pycache__', os.path.splitext(file)[0] + '*.pyc')) |
|
|
|
|
self.assertEqual(len(cached), 2) |
|
|
|
|
count += 1 |
|
|
|
|
# there are 5 files x 2 installations |
|
|
|
|
if py2: |
|
|
|
|
self.assertEqual(count, 10) |
|
|
|
|
else: |
|
|
|
|
self.assertEqual(count, 5) |
|
|
|
|
|
|
|
|
|
def test_bytecompile_multi(self): |
|
|
|
|
if not shutil.which('python2'): |
|
|
|
|
raise self.skipTest('python2 not installed') |
|
|
|
|
self._test_bytecompile(True) |
|
|
|
|
|
|
|
|
|
def test_bytecompile_single(self): |
|
|
|
|
if shutil.which('python2'): |
|
|
|
|
raise self.skipTest('python2 installed, already tested') |
|
|
|
|
self._test_bytecompile() |
|
|
|
|