diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-05-22 07:14:00 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-05-22 07:21:58 +0200 |
commit | 8be00dc71dbe409447feddc42d26bdfaf38703a4 (patch) | |
tree | ed1958593655e40907c4bd17232bae98c3a50ecc /nixos/lib | |
parent | efd4fcbebc09d2c40713913de40786d8cb31ed9c (diff) |
nixos/test-driver: Make tesseract OCR optional.
By default this is now enabled, and it has to be explicitely enabled
using "enableOCR = true". If it is set to false, any usage of
getScreenText or waitForText will fail with an error suggesting to pass
enableOCR.
This should get rid of the rather large dependency on tesseract which
we don't need for most tests.
Note, that I'm using system("type -P") here to check whether tesseract
is in PATH. I know it's a bashism but we already have other bashisms
within the test scripts and we also run it with bash, so IMHO it's not a
problem here.
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'nixos/lib')
-rw-r--r-- | nixos/lib/test-driver/Machine.pm | 3 | ||||
-rw-r--r-- | nixos/lib/testing.nix | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm index d149634e9e62..824f23bcc4bb 100644 --- a/nixos/lib/test-driver/Machine.pm +++ b/nixos/lib/test-driver/Machine.pm @@ -499,6 +499,9 @@ sub screenshot { sub getScreenText { my ($self) = @_; + system("type -P tesseract &> /dev/null") == 0 + or die "getScreenText used but enableOCR is false"; + my $text; $self->nest("performing optical character recognition", sub { my $tmpbase = Cwd::abs_path(".")."/ocr"; diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index 431e3de6a8ce..2039740a4578 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -27,7 +27,7 @@ rec { cp ${./test-driver/Logger.pm} $libDir/Logger.pm wrapProgram $out/bin/nixos-test-driver \ - --prefix PATH : "${qemu_kvm}/bin:${vde2}/bin:${netpbm}/bin:${coreutils}/bin:${tesseract}/bin" \ + --prefix PATH : "${qemu_kvm}/bin:${vde2}/bin:${netpbm}/bin:${coreutils}/bin" \ --prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl" ''; }; @@ -68,7 +68,12 @@ rec { makeTest = - { testScript, makeCoverageReport ? false, name ? "unnamed", ... } @ t: + { testScript + , makeCoverageReport ? false + , enableOCR ? false + , name ? "unnamed" + , ... + } @ t: let testDriverName = "nixos-test-driver-${name}"; @@ -102,12 +107,14 @@ rec { vms="$(for i in ${toString vms}; do echo $i/bin/run-*-vm; done)" wrapProgram $out/bin/nixos-test-driver \ --add-flags "$vms" \ + ${lib.optionalString enableOCR "--prefix PATH : '${tesseract}/bin'"} \ --run "testScript=\"\$(cat $out/test-script)\"" \ --set testScript '"$testScript"' \ --set VLANS '"${toString vlans}"' ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-run-vms wrapProgram $out/bin/nixos-run-vms \ --add-flags "$vms" \ + ${lib.optionalString enableOCR "--prefix PATH : '${tesseract}/bin'"} \ --set tests '"startAll; joinAll;"' \ --set VLANS '"${toString vlans}"' \ ${lib.optionalString (builtins.length vms == 1) "--set USE_SERIAL 1"} |