summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Gomes <tiago.gomes@codethink.co.uk>2015-07-31 13:25:50 +0000
committerTiago Gomes <tiago.gomes@codethink.co.uk>2015-08-12 16:40:52 +0000
commitc5cb1b57cab30d089ad577f89a82e83a6d487d4f (patch)
tree4ddca03b76217f32e4677e3b9af8871d9966fefa
parent2cf830f7df706cab0042481e772b1bd6f4f8ab8a (diff)
downloadmorph-c5cb1b57cab30d089ad577f89a82e83a6d487d4f.tar.gz
Use the shell X-ray mode
Instead of logging every command for ourselves, use the shell X-ray mode. As side effect, each command argument will now be printed out in its evaluated form, which aids debugging. Also, improve the visual separation between the different build steps, and display those steps with finer granularity. Change-Id: I16ebe9ba4ac46fef82e37d0b3e05f42d14249de8
-rw-r--r--morphlib/builder.py7
-rw-r--r--scripts/test-shell.c7
-rw-r--r--tests.build/build-chunk-failures-dump-log.stdout10
-rwxr-xr-xtests.build/prefix.script4
-rw-r--r--tests.build/prefix.stdout10
5 files changed, 19 insertions, 19 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py
index 4f6f2194..39af4146 100644
--- a/morphlib/builder.py
+++ b/morphlib/builder.py
@@ -350,7 +350,7 @@ class ChunkBuilder(BuilderBase):
with open(logfilepath, 'a') as log:
self.app.status(msg='Running %(key)s', key=key)
- log.write('# %s\n' % step)
+ log.write('### %s ###\n' % key.upper())
for cmd in cmds:
if cmd is False: cmd = "false"
@@ -365,9 +365,6 @@ class ChunkBuilder(BuilderBase):
extra_env['MAKEFLAGS'] = '-j1'
try:
- with open(logfilepath, 'a') as log:
- log.write('# # %s\n' % cmd)
-
# flushing is needed because writes from python and
# writes from being the output in Popen have different
# buffers, but flush handles both
@@ -375,7 +372,7 @@ class ChunkBuilder(BuilderBase):
stdout.flush()
with open(os.devnull) as devnull:
- self.runcmd(['sh', '-c', cmd],
+ self.runcmd(['sh', '-x', '-c', cmd],
extra_env=extra_env,
cwd=relative_builddir,
stdin=devnull,
diff --git a/scripts/test-shell.c b/scripts/test-shell.c
index 9818fbb4..963d128c 100644
--- a/scripts/test-shell.c
+++ b/scripts/test-shell.c
@@ -192,9 +192,10 @@ int run_commands(FILE *cmdstream){
}
int main(int argc, char *argv[]) {
- if (argc == 3 && strcmp(argv[1], "-c") == 0) {
- size_t cmdlen = strlen(argv[2]);
- FILE *cmdstream = fmemopen(argv[2], cmdlen, "r");
+ if (argc == 4 && strcmp(argv[1], "-x") == 0 \
+ && strcmp(argv[2], "-c") == 0) {
+ size_t cmdlen = strlen(argv[3]);
+ FILE *cmdstream = fmemopen(argv[3], cmdlen, "r");
return run_commands(cmdstream);
} else if (argc == 2) {
FILE *cmdstream = fopen(argv[1], "r");
diff --git a/tests.build/build-chunk-failures-dump-log.stdout b/tests.build/build-chunk-failures-dump-log.stdout
index 7a13c12a..83c67420 100644
--- a/tests.build/build-chunk-failures-dump-log.stdout
+++ b/tests.build/build-chunk-failures-dump-log.stdout
@@ -1,8 +1,8 @@
build failed
-# configure
-# # echo dummy configure
+### CONFIGURE-COMMANDS ###
++ echo dummy configure
dummy configure
-# build
-# # echo The next command will fail
+### BUILD-COMMANDS ###
++ echo The next command will fail
The next command will fail
-# # false
++ false
diff --git a/tests.build/prefix.script b/tests.build/prefix.script
index 140617e1..662be704 100755
--- a/tests.build/prefix.script
+++ b/tests.build/prefix.script
@@ -34,7 +34,9 @@ name: plugh
kind: chunk
configure-commands:
- "echo Second chunk: prefix $PREFIX"
- - "echo Path: $(echo $PATH | grep -o '/plover')"
+ - |
+ set +x
+ echo Path: $(echo $PATH | grep -o '/plover')
EOF
git add xyzzy.morph
diff --git a/tests.build/prefix.stdout b/tests.build/prefix.stdout
index 80c18fae..cb953a4e 100644
--- a/tests.build/prefix.stdout
+++ b/tests.build/prefix.stdout
@@ -1,8 +1,8 @@
-# configure
-# # echo First chunk: prefix $PREFIX
+### CONFIGURE-COMMANDS ###
++ echo First chunk: prefix /plover
First chunk: prefix /plover
-# configure
-# # echo Second chunk: prefix $PREFIX
+### CONFIGURE-COMMANDS ###
++ echo Second chunk: prefix /usr
Second chunk: prefix /usr
-# # echo Path: $(echo $PATH | grep -o '/plover')
++ set +x
Path: /plover