2

I am working on a project using Flex and until now we are using Windows to run flex unit tests for the modules/artifacts that require flex environment. Because of given dependencies, it is difficult to automatize anything because I have to swithch between linux/windows when running those maven tests.

I have made an effort to try to make flex units tests run on linux, but have not succedded [yet]. Here is small part of the stack trace from maven clean test -X on a flex project.

[INFO] Flexmojos 3.8
[INFO]   Apache License - Version 2.0 (NO WARRANTY) - See COPYRIGHT file
[INFO] Running tests /root/trunk/flex-project/flex-surface/flex-surface-common/flex-surface-common-flex/target/test-classes/TestRunner.swf
[DEBUG] [org.sonatype.flexmojos.test.monitor.AsVmPing] opened server socket on port 13540
[DEBUG] [org.sonatype.flexmojos.test.monitor.ResultHandler] opened server socket on port 13539
[DEBUG] [LAUNCHER] ASVmLauncher starting
[DEBUG] [LAUNCHER] exec: /usr/bin/flashplayer - /root/trunk/flex-project/flex-project-arbeidsflate/flex-surface-common/flex-surface-common-flex/target/test-classes/TestRunner.swf
[DEBUG] [LAUNCHER] Creating process
[WARNING] [LAUNCHER] Using xvfb-run to launch headless tests
[DEBUG] [LAUNCHER] Process created java.lang.UNIXProcess@1a6c088
[DEBUG] [MOJO] launcher RUNNING
[DEBUG] [MOJO] pinger STARTED
[DEBUG] [MOJO] resultHandler STARTED
[DEBUG] [LAUNCHER] Output pumpers ON
[DEBUG] [LAUNCHER] Waiting for flashplayer termination
[DEBUG] [LAUNCHER] Flashplayer closed
[DEBUG] [LAUNCHER] Unexpected return code 1
[DEBUG] [SYSERR]: mktemp: cannot create temp file /tmp/Xauthority: File exists
[DEBUG] [MOJO] launcher ERROR
[DEBUG] [MOJO] pinger STARTED
[DEBUG] [MOJO] resultHandler STARTED
[INFO] ------------------------------------------------------------------------
[INFO] Tests run: 0, Failures: 0, Errors: 0, Time Elapsed: 0 sec
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:

I need help find out what is wrong. If any of you guys know any other way to run flex units test on linux, NOT THROUGH JENKINS/HUDSON, I will be extremely grateful.

Gogi
  • 1,695
  • 4
  • 23
  • 36
  • Are you running an X client? It seems you are running with root, maybe if you were working with another user it would create a more specific Xauthority. – poussma Jan 07 '13 at 10:29
  • @ZNK-M Yes, as you see I am using xvfb and have installed xvfb-run under /usr/local/bin, and it seems like the flexmojos plugin picks that up fine, but stil something else that is going on. The reason I am running with root is because I am on sandbox testserver, so afraid of nothing :-). I could try to run with another user. – Gogi Jan 07 '13 at 10:35
  • Yes, maybe. I am wondering if the Xauthority generated by the root user has a special behaviour – poussma Jan 07 '13 at 11:26
  • I found out that the problem is the xvfb-run script and you can see the error under "[DEBUG] [SYSERR]: mktemp: cannot create temp file /tmp/Xauthority: File exists". I tried removing everything from /tmp and rerun the test, and voila everything ok. So I think I'll have to modify the script to place the Xauthority file in another random directory under /tmp so it's not using the same place every time. – Gogi Jan 07 '13 at 11:39
  • @ZNK-M See the solution. Thanks for engaging. – Gogi Jan 11 '13 at 12:48

1 Answers1

2

First of all, just follow the linux part of the instructions on the following site:Running unit tests - FlexMojos. Download the flashplayer and untar it some appropriate place and put the absolute directory path in your PATH variable.

Download the xvfb-run script and change the following 'fi'

# 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="${TMPDIR:-/tmp}/$PROGNAME.$$"
  if ! mkdir -p -m 700 "$XVFB_RUN_TMPDIR"; then
    error "temporary directory $XVFB_RUN_TMPDIR already exists"
    exit 4
  fi
  AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority)
fi

to

# 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)
   if ! mkdir -p -m 700 "$XVFB_RUN_TMPDIR"; then
     error "temporary directory $XVFB_RUN_TMPDIR already exists"
     exit 4
   fi
   AUTHFILE=$(mktemp "$XVFB_RUN_TMPDIR/Xauthority")
 fi

I solved my problem, hopefully you will too. Good luck.

Richlewis
  • 15,070
  • 37
  • 122
  • 283
Gogi
  • 1,695
  • 4
  • 23
  • 36