From a25d683e54159cd92c21ceab793c6966ca99b6d6 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 25 Jun 2018 02:11:20 -0400 Subject: doc: Adding part 4 of the getting started tutorial: integration commands This new section talks about how integration commands work and shows them at work. --- .../integration-commands/elements/base.bst | 5 + .../integration-commands/elements/base/alpine.bst | 17 +++ .../integration-commands/elements/hello.bst | 22 +++ .../integration-commands/elements/libhello.bst | 22 +++ .../integration-commands/files/hello/Makefile | 12 ++ .../integration-commands/files/hello/hello.c | 20 +++ .../integration-commands/files/libhello/Makefile | 17 +++ .../integration-commands/files/libhello/libhello.c | 9 ++ .../integration-commands/files/libhello/libhello.h | 8 ++ doc/examples/integration-commands/project.conf | 12 ++ doc/sessions/integration-commands.run | 15 ++ doc/source/format_public.rst | 3 + .../integration-commands-build.html | 159 +++++++++++++++++++++ .../integration-commands-shell.html | 26 ++++ doc/source/tutorial/integration-commands.rst | 130 +++++++++++++++++ doc/source/using_tutorial.rst | 1 + tests/examples/integration-commands.py | 36 +++++ 17 files changed, 514 insertions(+) create mode 100644 doc/examples/integration-commands/elements/base.bst create mode 100644 doc/examples/integration-commands/elements/base/alpine.bst create mode 100644 doc/examples/integration-commands/elements/hello.bst create mode 100644 doc/examples/integration-commands/elements/libhello.bst create mode 100644 doc/examples/integration-commands/files/hello/Makefile create mode 100644 doc/examples/integration-commands/files/hello/hello.c create mode 100644 doc/examples/integration-commands/files/libhello/Makefile create mode 100644 doc/examples/integration-commands/files/libhello/libhello.c create mode 100644 doc/examples/integration-commands/files/libhello/libhello.h create mode 100644 doc/examples/integration-commands/project.conf create mode 100644 doc/sessions/integration-commands.run create mode 100644 doc/source/sessions-stored/integration-commands-build.html create mode 100644 doc/source/sessions-stored/integration-commands-shell.html create mode 100644 doc/source/tutorial/integration-commands.rst create mode 100644 tests/examples/integration-commands.py diff --git a/doc/examples/integration-commands/elements/base.bst b/doc/examples/integration-commands/elements/base.bst new file mode 100644 index 000000000..1b85a9e8c --- /dev/null +++ b/doc/examples/integration-commands/elements/base.bst @@ -0,0 +1,5 @@ +kind: stack +description: Base stack + +depends: +- base/alpine.bst diff --git a/doc/examples/integration-commands/elements/base/alpine.bst b/doc/examples/integration-commands/elements/base/alpine.bst new file mode 100644 index 000000000..433f4773a --- /dev/null +++ b/doc/examples/integration-commands/elements/base/alpine.bst @@ -0,0 +1,17 @@ +kind: import +description: | + + Alpine Linux base runtime + +sources: +- kind: tar + url: alpine:integration-tests-base.v1.x86_64.tar.xz + ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639 + +# +# Run ldconfig in the libdir before running anything +# +public: + bst: + integration-commands: + - ldconfig "%{libdir}" diff --git a/doc/examples/integration-commands/elements/hello.bst b/doc/examples/integration-commands/elements/hello.bst new file mode 100644 index 000000000..c90254f10 --- /dev/null +++ b/doc/examples/integration-commands/elements/hello.bst @@ -0,0 +1,22 @@ +kind: manual +description: | + + The hello application + +# Depend on the hello library +depends: +- libhello.bst + +# Stage the files/hello directory for building +sources: + - kind: local + path: files/hello + +# Now configure the commands to run +config: + + build-commands: + - make PREFIX="%{prefix}" + + install-commands: + - make -j1 PREFIX="%{prefix}" DESTDIR="%{install-root}" install diff --git a/doc/examples/integration-commands/elements/libhello.bst b/doc/examples/integration-commands/elements/libhello.bst new file mode 100644 index 000000000..53496c84c --- /dev/null +++ b/doc/examples/integration-commands/elements/libhello.bst @@ -0,0 +1,22 @@ +kind: manual +description: | + + The libhello library + +# Depend on the base system +depends: +- base.bst + +# Stage the files/libhello directory for building +sources: + - kind: local + path: files/libhello + +# Now configure the commands to run +config: + + build-commands: + - make PREFIX="%{prefix}" + + install-commands: + - make -j1 PREFIX="%{prefix}" DESTDIR="%{install-root}" install diff --git a/doc/examples/integration-commands/files/hello/Makefile b/doc/examples/integration-commands/files/hello/Makefile new file mode 100644 index 000000000..21471d40f --- /dev/null +++ b/doc/examples/integration-commands/files/hello/Makefile @@ -0,0 +1,12 @@ +# Sample makefile for hello.c +# +.PHONY: all install + +all: hello + +install: + install -d ${DESTDIR}${PREFIX}/bin + install -m 755 hello ${DESTDIR}${PREFIX}/bin + +hello: hello.c + $(CC) $< -o $@ -Wall -lhello diff --git a/doc/examples/integration-commands/files/hello/hello.c b/doc/examples/integration-commands/files/hello/hello.c new file mode 100644 index 000000000..83e762c29 --- /dev/null +++ b/doc/examples/integration-commands/files/hello/hello.c @@ -0,0 +1,20 @@ +/* + * hello.c - Simple hello program + */ +#include +#include + +int main(int argc, char *argv[]) +{ + const char *person = NULL; + + if (argc > 1) + person = argv[1]; + + if (person) + hello(person); + else + hello("stranger"); + + return 0; +} diff --git a/doc/examples/integration-commands/files/libhello/Makefile b/doc/examples/integration-commands/files/libhello/Makefile new file mode 100644 index 000000000..63ee11069 --- /dev/null +++ b/doc/examples/integration-commands/files/libhello/Makefile @@ -0,0 +1,17 @@ +# Sample makefile for hello library +# +.PHONY: all install + +all: libhello.so + +install: + install -d ${DESTDIR}${PREFIX}/lib + install -d ${DESTDIR}${PREFIX}/include + install -m 644 libhello.so ${DESTDIR}${PREFIX}/lib + install -m 644 libhello.h ${DESTDIR}${PREFIX}/include + +%.o: %.c %.h + $(CC) -c $< -o $@ -Wall + +libhello.so: libhello.o + $(CC) -shared -o $@ $< diff --git a/doc/examples/integration-commands/files/libhello/libhello.c b/doc/examples/integration-commands/files/libhello/libhello.c new file mode 100644 index 000000000..759b33926 --- /dev/null +++ b/doc/examples/integration-commands/files/libhello/libhello.c @@ -0,0 +1,9 @@ +/* + * libhello.c - The hello library + */ +#include + +void hello(const char *person) +{ + printf("Hello %s\n", person); +} diff --git a/doc/examples/integration-commands/files/libhello/libhello.h b/doc/examples/integration-commands/files/libhello/libhello.h new file mode 100644 index 000000000..f714f3659 --- /dev/null +++ b/doc/examples/integration-commands/files/libhello/libhello.h @@ -0,0 +1,8 @@ +/* + * libhello.h - The hello library + */ + +/* + * A function to say hello to @person + */ +void hello(const char *person); diff --git a/doc/examples/integration-commands/project.conf b/doc/examples/integration-commands/project.conf new file mode 100644 index 000000000..b33267005 --- /dev/null +++ b/doc/examples/integration-commands/project.conf @@ -0,0 +1,12 @@ +# Unique project name +name: integration-commands + +# Required BuildStream format version +format-version: 9 + +# Subdirectory where elements are stored +element-path: elements + +# Define an alias for our alpine tarball +aliases: + alpine: https://gnome7.codethink.co.uk/tarballs/ diff --git a/doc/sessions/integration-commands.run b/doc/sessions/integration-commands.run new file mode 100644 index 000000000..35d2433e1 --- /dev/null +++ b/doc/sessions/integration-commands.run @@ -0,0 +1,15 @@ + +commands: +# Make it fetch first +- directory: ../examples/integration-commands + command: fetch hello.bst + +# Capture a build output +- directory: ../examples/integration-commands + output: ../source/sessions/integration-commands-build.html + command: build hello.bst + +# Capture a shell output +- directory: ../examples/integration-commands + output: ../source/sessions/integration-commands-shell.html + command: shell hello.bst -- hello pony diff --git a/doc/source/format_public.rst b/doc/source/format_public.rst index e640de7bb..d596ea753 100644 --- a/doc/source/format_public.rst +++ b/doc/source/format_public.rst @@ -1,4 +1,7 @@ + +.. _public_builtin: + Builtin public data =================== Elements can provide public data which can be read by other elements diff --git a/doc/source/sessions-stored/integration-commands-build.html b/doc/source/sessions-stored/integration-commands-build.html new file mode 100644 index 000000000..4695b5da4 --- /dev/null +++ b/doc/source/sessions-stored/integration-commands-build.html @@ -0,0 +1,159 @@ + +
+user@host:~/integration-commands$ bst build hello.bst
+
+[--:--:--][][] START   Build
+[--:--:--][][] START   Loading pipeline
+[00:00:00][][] SUCCESS Loading pipeline
+[--:--:--][][] START   Resolving pipeline
+[00:00:00][][] SUCCESS Resolving pipeline
+[--:--:--][][] START   Resolving cached state
+[00:00:00][][] SUCCESS Resolving cached state
+[--:--:--][][] START   Checking sources
+[00:00:00][][] SUCCESS Checking sources
+
+BuildStream Version 1.1.3+162.gb77323a5.dirty
+  Session Start: Monday, 25-06-2018 at 01:40:34
+  Project:       integration-commands (/home/user/integration-commands)
+  Targets:       hello.bst
+
+User Configuration
+  Configuration File:      /home/user/.config/buildstream.conf
+  Log Files:               /home/user/.cache/buildstream/logs
+  Source Mirrors:          /home/user/.cache/buildstream/sources
+  Build Area:              /home/user/.cache/buildstream/build
+  Artifact Cache:          /home/user/.cache/buildstream/artifacts
+  Strict Build Plan:       Yes
+  Maximum Fetch Tasks:     10
+  Maximum Build Tasks:     4
+  Maximum Push Tasks:      4
+  Maximum Network Retries: 2
+
+Pipeline
+   buildable f3a052f53373c1d9008c9581600e4b78fd0549b1d914fcb62fd4310fbe356515 base/alpine.bst 
+     waiting 63215ac6b90b0f64ab031f5e8d190d30873c4649e1f016be19bd368d4d74b1bc base.bst 
+     waiting fe98698f332e669187ea281124b037e0d195cdb5068a1f72d8645d3862e78efa libhello.bst 
+     waiting 18c81214a58b3432abe4899ec4973a271d9aa3729e6440b793b865b3702a251c hello.bst 
+===============================================================================
+[--:--:--][f3a052f5][build:base/alpine.bst               ] START   integration-commands/base-alpine/f3a052f5-build.357.log
+[--:--:--][f3a052f5][build:base/alpine.bst               ] START   Staging sources
+[00:00:04][f3a052f5][build:base/alpine.bst               ] SUCCESS Staging sources
+[--:--:--][f3a052f5][build:base/alpine.bst               ] START   Caching artifact
+[00:00:07][f3a052f5][build:base/alpine.bst               ] SUCCESS Caching artifact
+[00:00:13][f3a052f5][build:base/alpine.bst               ] SUCCESS integration-commands/base-alpine/f3a052f5-build.357.log
+[--:--:--][63215ac6][build:base.bst                      ] START   integration-commands/base/63215ac6-build.366.log
+[--:--:--][63215ac6][build:base.bst                      ] START   Caching artifact
+[00:00:00][63215ac6][build:base.bst                      ] SUCCESS Caching artifact
+[00:00:00][63215ac6][build:base.bst                      ] SUCCESS integration-commands/base/63215ac6-build.366.log
+[--:--:--][fe98698f][build:libhello.bst                  ] START   integration-commands/libhello/fe98698f-build.368.log
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Staging dependencies
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Staging dependencies
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Integrating sandbox
+[--:--:--][fe98698f][build:libhello.bst                  ] STATUS  Running integration command
+
+    ldconfig "/usr/lib"
+
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Integrating sandbox
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Staging sources
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Staging sources
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running build-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running build-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] STATUS  Running build-commands
+
+    make PREFIX="/usr"
+
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running build-commands
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running build-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running install-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running install-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] STATUS  Running install-commands
+
+    make -j1 PREFIX="/usr" DESTDIR="/buildstream-install" install
+
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running install-commands
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running install-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running strip-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Running strip-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] STATUS  Running strip-commands
+
+    find "/buildstream-install" -type f \
+      '(' -perm -111 -o -name '*.so*' \
+          -o -name '*.cmxs' -o -name '*.node' ')' \
+      -exec sh -ec \
+      'read -n4 hdr <"$1" # check for elf header
+       if [ "$hdr" != "$(printf \\x7fELF)" ]; then
+           exit 0
+       fi
+       debugfile="/buildstream-install/usr/lib/debug/$(basename "$1")"
+       mkdir -p "$(dirname "$debugfile")"
+       objcopy --only-keep-debug --compress-debug-sections "$1" "$debugfile"
+       chmod 644 "$debugfile"
+       strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1"
+       objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';'
+
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running strip-commands
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Running strip-commands
+[--:--:--][fe98698f][build:libhello.bst                  ] START   Caching artifact
+[00:00:00][fe98698f][build:libhello.bst                  ] SUCCESS Caching artifact
+[00:00:01][fe98698f][build:libhello.bst                  ] SUCCESS integration-commands/libhello/fe98698f-build.368.log
+[--:--:--][18c81214][build:hello.bst                     ] START   integration-commands/hello/18c81214-build.414.log
+[--:--:--][18c81214][build:hello.bst                     ] START   Staging dependencies
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Staging dependencies
+[--:--:--][18c81214][build:hello.bst                     ] START   Integrating sandbox
+[--:--:--][18c81214][build:hello.bst                     ] STATUS  Running integration command
+
+    ldconfig "/usr/lib"
+
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Integrating sandbox
+[--:--:--][18c81214][build:hello.bst                     ] START   Staging sources
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Staging sources
+[--:--:--][18c81214][build:hello.bst                     ] START   Running build-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Running build-commands
+[--:--:--][18c81214][build:hello.bst                     ] STATUS  Running build-commands
+
+    make PREFIX="/usr"
+
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running build-commands
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running build-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Running install-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Running install-commands
+[--:--:--][18c81214][build:hello.bst                     ] STATUS  Running install-commands
+
+    make -j1 PREFIX="/usr" DESTDIR="/buildstream-install" install
+
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running install-commands
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running install-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Running strip-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Running strip-commands
+[--:--:--][18c81214][build:hello.bst                     ] STATUS  Running strip-commands
+
+    find "/buildstream-install" -type f \
+      '(' -perm -111 -o -name '*.so*' \
+          -o -name '*.cmxs' -o -name '*.node' ')' \
+      -exec sh -ec \
+      'read -n4 hdr <"$1" # check for elf header
+       if [ "$hdr" != "$(printf \\x7fELF)" ]; then
+           exit 0
+       fi
+       debugfile="/buildstream-install/usr/lib/debug/$(basename "$1")"
+       mkdir -p "$(dirname "$debugfile")"
+       objcopy --only-keep-debug --compress-debug-sections "$1" "$debugfile"
+       chmod 644 "$debugfile"
+       strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1"
+       objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';'
+
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running strip-commands
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Running strip-commands
+[--:--:--][18c81214][build:hello.bst                     ] START   Caching artifact
+[00:00:00][18c81214][build:hello.bst                     ] SUCCESS Caching artifact
+[00:00:01][18c81214][build:hello.bst                     ] SUCCESS integration-commands/hello/18c81214-build.414.log
+[00:00:17][][] SUCCESS Build
+
+Pipeline Summary
+  Total:       4
+  Session:     4
+  Fetch Queue: processed 0, skipped 4, failed 0 
+  Build Queue: processed 4, skipped 0, failed 0
+
diff --git a/doc/source/sessions-stored/integration-commands-shell.html b/doc/source/sessions-stored/integration-commands-shell.html new file mode 100644 index 000000000..10d642e94 --- /dev/null +++ b/doc/source/sessions-stored/integration-commands-shell.html @@ -0,0 +1,26 @@ + +
+user@host:~/integration-commands$ bst shell hello.bst -- hello pony
+
+[--:--:--][][] START   Loading pipeline
+[00:00:00][][] SUCCESS Loading pipeline
+[--:--:--][][] START   Resolving pipeline
+[00:00:00][][] SUCCESS Resolving pipeline
+[--:--:--][][] START   Resolving cached state
+[00:00:00][][] SUCCESS Resolving cached state
+[--:--:--][][] START   Staging dependencies
+[00:00:00][][] SUCCESS Staging dependencies
+[--:--:--][][] START   Integrating sandbox
+[--:--:--][f3a052f5][ main:base/alpine.bst               ] STATUS  Running integration command
+
+    ldconfig "/usr/lib"
+
+[00:00:00][][] SUCCESS Integrating sandbox
+[--:--:--][18c81214][ main:hello.bst                     ] STATUS  Running command
+
+    hello pony
+
+Hello pony
+
diff --git a/doc/source/tutorial/integration-commands.rst b/doc/source/tutorial/integration-commands.rst new file mode 100644 index 000000000..8d80eb9a2 --- /dev/null +++ b/doc/source/tutorial/integration-commands.rst @@ -0,0 +1,130 @@ + + +Integration commands +==================== +Sometimes a software requires more configuration or processing than what is +performed at installation time, otherwise it will not run properly. + +This is especially true in cases where a daemon or library interoperates +with third party extensions and needs to maintain a system wide cache whenever +it's extensions are installed or removed; system wide font caches are an example +of this. + +In these cases we use :ref:`integration commands ` to +ensure that a runtime is ready to run after all of it's components have been *staged*. + +.. note:: + + This example is distributed with BuildStream + in the `doc/examples/integration-commands + `_ + subdirectory. + + +Overview +-------- +In this chapter, we'll be exploring :ref:`integration commands `, +which will be our first look at :ref:`public data `. + + +Project structure +----------------- + + +``project.conf`` and ``elements/base.bst`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The project.conf and base stack :mod:`stack ` element are configured in the +same way as in the previous chapter: :ref:`tutorial_running_commands`. + + +``elements/base/alpine.bst`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. literalinclude:: ../../examples/integration-commands/elements/base/alpine.bst + :language: yaml + +This is the same ``base/alpine.bst`` we've seen in previous chapters, +except that we've added an :ref:`integration command `. + +This informs BuildStream that whenever the output of this element is +expected to *run*, this command should be run first. In this case we +are simply running ``ldconfig`` as a precautionary measure, to ensure +that the runtime linker is ready to find any shared libraries we may +have added to ``%{libdir}``. + + +Looking at public data +'''''''''''''''''''''' +The :ref:`integration commands ` used here is the first time +we've used any :ref:`builtin public data `. + +Public data is a free form portion of an element's configuration and +is not necessarily understood by the element on which it is declared, public +data is intended to be read by it's reverse dependency elements. + +This allows annotations on some elements to inform elements later in +the dependency chain about details of it's artifact, or to suggest how +it should be processed. + + +``elements/libhello.bst`` and ``elements/hello.bst`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +These are basically manual elements very similar to the ones we've +seen in the previous chapter: :ref:`tutorial_running_commands`. + +These produce a library and a hello program which uses the library, +we will consider these irrelevant to the topic and leave examination +of `their sources +`_ +as an exercise for the reader. + + +Using the project +----------------- + + +Build the hello.bst element +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +To build the project, run :ref:`bst build ` in the +following way: + +.. raw:: html + :file: ../sessions/integration-commands-build.html + +Observe in the build process above, the integration command declared on the +``base/alpine.bst`` element is run after staging the dependency artifacts +into the build sandbox and before running any of the build commands, for +both of the ``libhello.bst`` and ``hello.bst`` elements. + +BuildStream assumes that commands which are to be run in the build sandbox +need to be run in an *integrated* sandbox. + +.. tip:: + + Integration commands can be taxing on your overall build process, + because they need to run at the beginning of every build which + :ref:`runtime depends ` on the element + declaring them. + + For this reason, it is better to leave out more onerous tasks + if they are not needed at software build time, and handle those + specific tasks differently later in the pipeline, before deployment. + + +Run the hello world program +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Unlike the previous chapters, this hello world program takes an argument, +we can invoke the program using :ref:`bst shell `: + +.. raw:: html + :file: ../sessions/integration-commands-shell.html + +Here we see again, the integration commands are also used when preparing +the shell to launch a command. + + +Summary +------- +In this chapter we've observed how :ref:`integration commands ` +work, and we now know about :ref:`public data `, which plugins +can read from their dependencies in order to influence their build process. diff --git a/doc/source/using_tutorial.rst b/doc/source/using_tutorial.rst index 939334c60..190c94c8d 100644 --- a/doc/source/using_tutorial.rst +++ b/doc/source/using_tutorial.rst @@ -12,3 +12,4 @@ projects. tutorial/first-project tutorial/running-commands tutorial/autotools + tutorial/integration-commands diff --git a/tests/examples/integration-commands.py b/tests/examples/integration-commands.py new file mode 100644 index 000000000..32ef763eb --- /dev/null +++ b/tests/examples/integration-commands.py @@ -0,0 +1,36 @@ +import os +import pytest + +from tests.testutils import cli_integration as cli +from tests.testutils.integration import assert_contains +from tests.testutils.site import IS_LINUX + + +pytestmark = pytest.mark.integration +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples', 'integration-commands' +) + + +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux') +@pytest.mark.datafiles(DATA_DIR) +def test_integration_commands_build(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + checkout = os.path.join(cli.directory, 'checkout') + + result = cli.run(project=project, args=['build', 'hello.bst']) + assert result.exit_code == 0 + + +# Test running the executable +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux') +@pytest.mark.datafiles(DATA_DIR) +def test_integration_commands_run(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + + result = cli.run(project=project, args=['build', 'hello.bst']) + assert result.exit_code == 0 + + result = cli.run(project=project, args=['shell', 'hello.bst', '--', 'hello', 'pony']) + assert result.exit_code == 0 + assert result.output == 'Hello pony\n' -- cgit v1.2.1