Closed Bug 502827 Opened 15 years ago Closed 15 years ago

unable to use var or const in xpcshell.exe -e parameter for windows mobile

Categories

(Core :: JavaScript Engine, defect)

ARM
Windows Mobile 6 Professional
defect
Not set
normal

Tracking

()

VERIFIED WORKSFORME

People

(Reporter: jmaher, Unassigned)

Details

when running xpcshell tests on windows mobile I ran into a problem where it was not finding the _HEAD_FILES that are defined as such:
xpcshell.exe -e "const _HEAD_FILES = [...];"

In reducing this, I found that I can call a function using the -e, but not set a var or const.

Here is an example test.js:
function p(x) {
  print("input: '" + x + "'");
};

I call this from test.py:
import subprocess
cmd = ["\\tests\\fennec\\xulrunner\\xpcshell.exe", "-g", "\\tests\\fennec\\xulrunner", "-f", "\\tests\\xpcshell\\test.js", "-e", "var x='test';", "-e", "p(x);"]
proc = subprocess.Popen(cmd)
proc.wait()


What happens is if I just call "-e p('test');" from my test.py script it works as expected.  If I try to define a variable as the example above points out, I get an error:
 -e:1: ReferenceError: x is not defined


I don't get an error if I combine the two lines of js code into a single -e statement:
-e "var x='test';p(x);"

For this last exercise, I did put a printf("%s", argv[i]); in line 1077 in xpcshell.cpp and this is what I see:
"var x='test';p(x);"
(In reply to comment #0)
> For this last exercise, I did put a printf("%s", argv[i]); in line 1077 in
> xpcshell.cpp and this is what I see:
> "var x='test';p(x);"

It looks like a quoting issue. How this works in regular desktop Windows is,

  1. subprocess.Popen takes your array of strings and creates a command line
     which is a single string
  2. that gets passed to CreateProcess
  3. xpcshell contains the C runtime library, which--*before* calling main--
     parses the command line (according to amazingly crufty legacy rules) and
     turns it into an argv array.

Therefore subprocess has to know all the crufty legacy rules and produce just the right command line to finesse the CRT into unpacking it to the desired argv.

Apparently Windows Mobile does something different. Perhaps it's the CRT that's different. Hard to say. In any case subprocess needs a different workaround.

This seems like a bug in subprocess.py.
Joel, do you still see this?
this is now working with my latest patches and updates to python.  We can mark this as resolved/wfm
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WORKSFORME
verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.