Commit 16d9b557 authored by Jérome Perrin's avatar Jérome Perrin

software/theia: generate a shell compatible with tasks

When running tasks, shell is invoked like:

   $THEIA_SHELL -c "command with arguments that\ can\ contain\ spaces"
parent a41f3e8c
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance] [instance]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 0cd7d44974b568dbb7b880d6c103dfdf md5sum = d8ad39bc93c492026a93c28b33a5dc3a
[yarn.lock] [yarn.lock]
filename = yarn.lock filename = yarn.lock
......
...@@ -121,7 +121,7 @@ recipe = slapos.cookbook:userinfo ...@@ -121,7 +121,7 @@ recipe = slapos.cookbook:userinfo
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_} wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line = command-line =
env LC_ALL=C.UTF-8 TMP=$${directory:tmp} THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{hostname}}' THEIA_SHELL=$${theia-shell:wrapper-path} ${theia-wrapper:rendered} --hostname=$${:hostname} --port=$${:port} $${directory:project} env LC_ALL=C.UTF-8 TMP=$${directory:tmp} THEIA_WEBVIEW_EXTERNAL_ENDPOINT='{{hostname}}' THEIA_SHELL=$${theia-shell:rendered} ${theia-wrapper:rendered} --hostname=$${:hostname} --port=$${:port} $${directory:project}
ip = $${instance-parameter:ipv4-random} ip = $${instance-parameter:ipv4-random}
hostname = $${:ip} hostname = $${:ip}
...@@ -132,12 +132,18 @@ hash-existing-files = ...@@ -132,12 +132,18 @@ hash-existing-files =
${theia-wrapper:rendered} ${theia-wrapper:rendered}
[theia-shell] [theia-shell]
recipe = slapos.cookbook:wrapper recipe = slapos.recipe.template:jinja2
wrapper-path = $${directory:bin}/$${:_buildout_section_name_} rendered = $${directory:bin}/$${:_buildout_section_name_}
# reset GIT_EXEC_PATH to workaround https://github.com/eclipse-theia/theia/issues/7555 mode = 0700
# activate slapos configuration template = inline:
command-line = #!${python:location}/bin/python
${bash:location}/bin/bash -c ". $${slapos-standalone-activate:rendered} && exec env GIT_EXEC_PATH= ${bash:location}/bin/bash" import sys
import os
args = sys.argv[1:]
# when running interactively, activate slapos configuration and reset GIT_EXEC_PATH to workaround https://github.com/eclipse-theia/theia/issues/7555
if not args: args = ["-c", ". $${slapos-standalone-activate:rendered} && exec env GIT_EXEC_PATH= ${bash:location}/bin/bash", ]
os.execv('${bash:location}/bin/bash', ['${bash:location}/bin/bash'] + args)
[slapos-standalone-activate] [slapos-standalone-activate]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
......
...@@ -29,6 +29,7 @@ from __future__ import unicode_literals ...@@ -29,6 +29,7 @@ from __future__ import unicode_literals
import os import os
import textwrap import textwrap
import logging import logging
import subprocess
import tempfile import tempfile
import time import time
from six.moves.urllib.parse import urlparse, urljoin from six.moves.urllib.parse import urlparse, urljoin
...@@ -131,3 +132,13 @@ class TestTheia(SlapOSInstanceTestCase): ...@@ -131,3 +132,13 @@ class TestTheia(SlapOSInstanceTestCase):
process.terminate() process.terminate()
process.wait() process.wait()
def test_theia_shell_execute_tasks(self):
# shell needs to understand -c "comamnd" arguments for theia tasks feature
test_file = '{}/test file'.format(self.computer_partition_root_path)
subprocess.check_call([
'{}/bin/theia-shell'.format(self.computer_partition_root_path),
'-c',
'touch "{}"'.format(test_file)
])
self.assertTrue(os.path.exists(test_file))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment