Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
bf0be004df8c
Commit
5c85adda
authored
May 07, 2020
by
Simon Chabot
Browse files
fix(tests): use firefox headless mode instead of xvfb-run script
--HG-- branch : 3.27
parent
8b49be4828fc
Pipeline
#62158
failed with stages
in 26 minutes and 38 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
bf0be004
...
...
@@ -148,6 +148,7 @@ py3-from-forge-server:
before_script
:
-
sudo apt update
-
sudo DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none apt-get install -y --assume-yes -qq -o=Dpkg::Use-Pty=0 slapd ldap-utils
-
sudo apt update && sudo apt install -y firefox-esr
artifacts
:
paths
:
-
/builds/cubicweb/cubicweb/from-forge-server.html
...
...
cubicweb/devtools/data/xvfb-run.sh
deleted
100755 → 0
View file @
8b49be48
#!/bin/sh
# This script starts an instance of Xvfb, the "fake" X server, runs a command
# with that server available, and kills the X server when done. The return
# value of the command becomes the return value of this script.
#
# If anyone is using this to build a Debian package, make sure the package
# Build-Depends on xvfb and xauth.
set
-e
PROGNAME
=
xvfb-run
SERVERNUM
=
99
AUTHFILE
=
ERRORFILE
=
/dev/null
XVFBARGS
=
"-screen 0 640x480x8"
LISTENTCP
=
"-nolisten tcp"
XAUTHPROTO
=
.
# Query the terminal to establish a default number of columns to use for
# displaying messages to the user. This is used only as a fallback in the event
# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the
# script is running, and this cannot, only being calculated once.)
DEFCOLUMNS
=
$(
stty
size 2>/dev/null |
awk
'{print $2}'
)
||
true
if
!
expr
"
$DEFCOLUMNS
"
:
"[[:digit:]]
\+
$"
>
/dev/null 2>&1
;
then
DEFCOLUMNS
=
80
fi
# Display a message, wrapping lines at the terminal width.
message
()
{
echo
"
$PROGNAME
:
$*
"
|
fmt
-t
-w
${
COLUMNS
:-
$DEFCOLUMNS
}
}
# Display an error message.
error
()
{
message
"error:
$*
"
>
&2
}
# Display a usage message.
usage
()
{
if
[
-n
"
$*
"
]
;
then
message
"usage error:
$*
"
fi
cat
<<
EOF
Usage:
$PROGNAME
[OPTION ...] COMMAND
Run COMMAND (usually an X client) in a virtual X server environment.
Options:
-a --auto-servernum try to get a free server number, starting at
--server-num
-e FILE --error-file=FILE file used to store xauth errors and Xvfb
output (default:
$ERRORFILE
)
-f FILE --auth-file=FILE file used to store auth cookie
(default: ./.Xauthority)
-h --help display this usage message and exit
-n NUM --server-num=NUM server number to use (default:
$SERVERNUM
)
-l --listen-tcp enable TCP port listening in the X server
-p PROTO --xauth-protocol=PROTO X authority protocol name to use
(default: xauth command's default)
-s ARGS --server-args=ARGS arguments (other than server number and
"-nolisten tcp") to pass to the Xvfb server
(default: "
$XVFBARGS
")
EOF
}
# Find a free server number by looking at .X*-lock files in /tmp.
find_free_servernum
()
{
# Sadly, the "local" keyword is not POSIX. Leave the next line commented in
# the hope Debian Policy eventually changes to allow it in /bin/sh scripts
# anyway.
#local i
i
=
$SERVERNUM
while
[
-f
/tmp/.X
$i
-lock
]
;
do
i
=
$((
$i
+
1
))
done
echo
$i
}
# Clean up files
clean_up
()
{
if
[
-e
"
$AUTHFILE
"
]
;
then
XAUTHORITY
=
$AUTHFILE
xauth remove
":
$SERVERNUM
"
>>
"
$ERRORFILE
"
2>&1
fi
if
[
-n
"
$XVFB_RUN_TMPDIR
"
]
;
then
if
!
rm
-r
"
$XVFB_RUN_TMPDIR
"
;
then
error
"problem while cleaning up temporary directory"
exit
5
fi
XVFB_RUN_TMPDIR
=
fi
if
[
-n
"
$XVFBPID
"
]
;
then
kill
"
$XVFBPID
"
fi
}
# Parse the command line.
ARGS
=
$(
getopt
--options
+ae:f:hn:lp:s:w:
\
--long
auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait:
\
--name
"
$PROGNAME
"
--
"
$@
"
)
GETOPT_STATUS
=
$?
if
[
$GETOPT_STATUS
-ne
0
]
;
then
error
"internal error; getopt exited with status
$GETOPT_STATUS
"
exit
6
fi
eval set
--
"
$ARGS
"
while
:
;
do
case
"
$1
"
in
-a
|
--auto-servernum
)
SERVERNUM
=
$(
find_free_servernum
)
;
AUTONUM
=
"yes"
;;
-e
|
--error-file
)
ERRORFILE
=
"
$2
"
;
shift
;;
-f
|
--auth-file
)
AUTHFILE
=
"
$2
"
;
shift
;;
-h
|
--help
)
SHOWHELP
=
"yes"
;;
-n
|
--server-num
)
SERVERNUM
=
"
$2
"
;
shift
;;
-l
|
--listen-tcp
)
LISTENTCP
=
""
;;
-p
|
--xauth-protocol
)
XAUTHPROTO
=
"
$2
"
;
shift
;;
-s
|
--server-args
)
XVFBARGS
=
"
$2
"
;
shift
;;
-w
|
--wait
)
shift
;;
--
)
shift
;
break
;;
*
)
error
"internal error; getopt permitted
\"
$1
\"
unexpectedly"
exit
6
;;
esac
shift
done
if
[
"
$SHOWHELP
"
]
;
then
usage
exit
0
fi
if
[
-z
"
$*
"
]
;
then
usage
"need a command to run"
>
&2
exit
2
fi
if
!
which xauth
>
/dev/null
;
then
error
"xauth command not found"
exit
3
fi
# tidy up after ourselves
trap
clean_up EXIT TERM
# If the user did not specify an X authorization file to use, set up a temporary
# directory to house one.
if
[
-z
"
$AUTHFILE
"
]
;
then
XVFB_RUN_TMPDIR
=
"
$(
mktemp
-d
-t
$PROGNAME
.XXXXXX
)
"
# Create empty file to avoid xauth warning
touch
"
$XVFB_RUN_TMPDIR
/Xauthority"
AUTHFILE
=
"
$XVFB_RUN_TMPDIR
/Xauthority"
fi
# Start Xvfb.
MCOOKIE
=
$(
mcookie
)
tries
=
10
while
[
$tries
-gt
0
]
;
do
tries
=
$((
$tries
-
1
))
XAUTHORITY
=
$AUTHFILE
xauth
source
-
<<
EOF
>>"
$ERRORFILE
" 2>&1
add :
$SERVERNUM
$XAUTHPROTO
$MCOOKIE
EOF
# handle SIGUSR1 so Xvfb knows to send a signal when it's ready to accept
# connections
trap
: USR1
(
trap
''
USR1
;
XAUTHORITY
=
$AUTHFILE
exec
Xvfb
":
$SERVERNUM
"
$XVFBARGS
$LISTENTCP
>>
"
$ERRORFILE
"
2>&1
)
&
XVFBPID
=
$!
wait
||
:
if
kill
-0
$XVFBPID
2>/dev/null
;
then
break
elif
[
-n
"
$AUTONUM
"
]
;
then
# The display is in use so try another one (if '-a' was specified).
SERVERNUM
=
$((
SERVERNUM
+
1
))
SERVERNUM
=
$(
find_free_servernum
)
continue
fi
error
"Xvfb failed to start"
>
&2
XVFBPID
=
exit
1
done
# Start the command
DISPLAY
=
:
$SERVERNUM
XAUTHORITY
=
$AUTHFILE
"
$@
"
2>&1 &
wait
$!
# vim:set ai et sts=4 sw=4 tw=80:
cubicweb/devtools/qunit.py
View file @
bf0be004
...
...
@@ -15,7 +15,6 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
import
os
import
os.path
as
osp
import
time
import
errno
...
...
@@ -41,10 +40,7 @@ class FirefoxHelper(object):
self
.
_url
=
url
self
.
_process
=
None
self
.
_profile_dir
=
None
self
.
firefox_cmd
=
[
'firefox'
,
'-no-remote'
]
if
os
.
name
==
'posix'
:
self
.
firefox_cmd
=
[
osp
.
join
(
osp
.
dirname
(
__file__
),
'data'
,
'xvfb-run.sh'
),
'-a'
,
'-s'
,
'-noreset -screen 0 800x600x24'
]
+
self
.
firefox_cmd
self
.
firefox_cmd
=
[
'firefox'
,
'-no-remote'
,
'-headless'
]
def
__enter__
(
self
):
self
.
_profile_dir
=
mkdtemp
(
prefix
=
'cwtest-ffxprof-'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment