[buildout]

extends =
    software.cfg
    ../../component/git/buildout.cfg
    ../../component/pytest/buildout.cfg

[beremiz-repository]
recipe  = slapos.recipe.build:gitclone
repository = https://github.com/beremiz/beremiz
branch  = wxPython4
location = ${buildout:parts-directory}/beremiz
git-executable = ${git:location}/bin/git

[beremiz-setup]
setup = ${beremiz-repository:location}
depends =
  ${beremiz-gen-nxdtest:recipe}

[ddt]
recipe  = zc.recipe.egg:custom
egg     =  ddt
setup-eggs =
  enum34

[python-interpreter]
eggs +=
  ${pytest:eggs}
  pytest-timeout
  ${ddt:egg}

[instance]
type = beremiz-test

# Download only open62541 sources because beremiz test needs
# sources and will rebuild it anyway.
[open62541]
recipe = slapos.recipe.build:download-unpacked

[gen-nxdtest.sh]
recipe = slapos.recipe.template
output = ${buildout:parts-directory}/gennxdtest.sh
nxdtest = ${buildout:directory}/.nxdtest
inline =
  #!/bin/sh -e
  cd ${beremiz-repository:location}/tests/ide_tests/
  testlist=$(ls -d *.sikuli)
  rm -f ${:nxdtest}
  for test in $testlist; do
    if [ -z "$test" ]; then
      continue;
    fi
    # beremiztest script is generated by the instance (call make test_dir=xxx xserver_command=xxx)
    cat <<EOF >> ${:nxdtest}
  TestCase(
      "$test",
      ['beremiztest', '$test'],
      cwd="""${beremiz-repository:location}/tests""",
      summaryf=UnitTest.summary,
  )
  EOF
  done

[beremiz-gen-nxdtest]
recipe = plone.recipe.command
command = ${gen-nxdtest.sh:output}
update-command = ${:command}