1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2025-07-24 19:07:52 +02:00
Files
.gitlab-ci
.reuse
LICENSES
docs
fuzzing
gio
glib
gmodule
gobject
tests
performance
.gitignore
accumulator.c
autoptr.c
basic-signals.c
basics-gobject.c
binding.c
bindinggroup.c
boxed.c
closure-refcount.c
closure.c
custom-dispatch.c
cxx.cpp
defaultiface.c
deftype.c
deprecated-properties.c
dynamictests.c
dynamictype.c
enums.c
flags.c
genmarshal.py
gobject-query.py
ifaceproperties.c
marshalers.list
meson.build
mkenums.py
notify-init.c
notify-init2.c
object.c
objects-refcount1.c
objects-refcount2.c
override.c
param.c
private.c
properties-refcount1.c
properties-refcount2.c
properties-refcount3.c
properties-refcount4.c
properties.c
qdata.c
reference.c
references.c
signal-handler.c
signalgroup.c
signals-refcount.c
signals.c
singleton.c
taptestrunner.py
testcommon.h
testing.c
testmodule.c
testmodule.h
threadtests.c
type-flags.c
type.c
value.c
gatomicarray.c
gatomicarray.h
gbinding.c
gbinding.h
gbindinggroup.c
gbindinggroup.h
gboxed.c
gboxed.h
gclosure.c
gclosure.h
genums.c
genums.h
glib-enumtypes.c.template
glib-enumtypes.h.template
glib-genmarshal.in
glib-mkenums.in
glib-types.h
gmarshal.c
gmarshal.h
gobject-autocleanups.h
gobject-query.c
gobject.c
gobject.h
gobject.rc.in
gobject.stp.in
gobject_gdb.py
gobject_probes.d
gobject_trace.h
gobjectnotifyqueue.c
gparam.c
gparam.h
gparamspecs.c
gparamspecs.h
gsignal.c
gsignal.h
gsignalgroup.c
gsignalgroup.h
gsourceclosure.c
gsourceclosure.h
gtype-private.h
gtype.c
gtype.h
gtypemodule.c
gtypemodule.h
gtypeplugin.c
gtypeplugin.h
gvalue.c
gvalue.h
gvaluearray.c
gvaluearray.h
gvaluecollector.h
gvaluetransform.c
gvaluetypes.c
gvaluetypes.h
libgobject-gdb.py.in
meson.build
gthread
m4macros
po
subprojects
tests
tools
.clang-format
.dir-locals.el
.editorconfig
.gitignore
.gitlab-ci.yml
.gitmodules
.lcovrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
HACKING
INSTALL.md
NEWS
README.md
README.win32.md
SECURITY.md
glib.doap
meson.build
meson_options.txt
msvc_recommended_pragmas.h
glib/gobject/tests/gobject-query.py
Marc-André Lureau 8c0fa77a71 tests/gobject-query.py: make it work on msys2/win32
For unclear reasons, universal_newlines=True doesn't seem to set the
text encoding correctly. Even if I set only encoding='utf-8', the test
fails. The combination here works for me, \o/.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-10-17 11:01:53 +04:00

112 lines
3.4 KiB
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright © 2022 Endless OS Foundation, LLC
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA
"""Integration tests for gobject-query utility."""
import collections
import os
import shutil
import subprocess
import sys
import unittest
import taptestrunner
Result = collections.namedtuple("Result", ("info", "out", "err"))
class TestGobjectQuery(unittest.TestCase):
"""Integration test for running gobject-query.
This can be run when installed or uninstalled. When uninstalled, it
requires G_TEST_BUILDDIR and G_TEST_SRCDIR to be set.
The idea with this test harness is to test the gobject-query utility, its
handling of command line arguments, and its exit statuses.
"""
def setUp(self):
self.timeout_seconds = 10 # seconds per test
if "G_TEST_BUILDDIR" in os.environ:
self.__gobject_query = os.path.join(
os.environ["G_TEST_BUILDDIR"], "..", "gobject-query"
)
else:
self.__gobject_query = shutil.which("gobject-query")
print("gobject-query:", self.__gobject_query)
def runGobjectQuery(self, *args):
argv = [self.__gobject_query]
argv.extend(args)
print("Running:", argv)
env = os.environ.copy()
env["LC_ALL"] = "C.UTF-8"
print("Environment:", env)
# We want to ensure consistent line endings...
info = subprocess.run(
argv,
timeout=self.timeout_seconds,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
text=True,
encoding='utf-8',
)
info.check_returncode()
out = info.stdout.strip()
err = info.stderr.strip()
result = Result(info, out, err)
print("Output:", result.out)
return result
def test_help(self):
"""Test the --help argument."""
result = self.runGobjectQuery("--help")
self.assertIn("usage: gobject-query", result.out)
def test_version(self):
"""Test the --version argument."""
result = self.runGobjectQuery("--version")
self.assertIn("2.", result.out)
def test_froots(self):
"""Test running froots with no other arguments."""
result = self.runGobjectQuery("froots")
self.assertEqual("", result.err)
self.assertIn("├gboolean", result.out)
self.assertIn("├GObject", result.out)
def test_tree(self):
"""Test running tree with no other arguments."""
result = self.runGobjectQuery("tree")
self.assertEqual("", result.err)
self.assertIn("GObject", result.out)
if __name__ == "__main__":
unittest.main(testRunner=taptestrunner.TAPTestRunner())