How do I get content_shell to run my tests?

Viewed 670

There are questions for this already with answers, but I think this is something new. I'm trying to get drone.io to run my tests in content_shell. I've started the X server as per instructions. Downloaded content_shell via the download_contentshell.sh script. And executed content_shell according to the instructions I get both from the answers found here and from other sources. The problem is none of them work. content_shell will not run my tests, unless I give it an absolute file path, but if I do that, while it runs the tests, it fails, since the required imports aren't available to it. Here is the what I do to run the test script in drone.io settings

sudo start xvfb
pub install
test/run.sh

Here is the run.sh script

#!/bin/bash

which content_shell
if [[ $? -ne 0 ]]; then
    $DART_SDK/../chromium/download_contentshell.sh
    unzip content_shell-linux-x64-release.zip

    cs_path=$(ls -d drt-*)
    PATH=$cs_path:$PATH
fi

results=$(content_shell --args --dump-render-tree test/index.html 2>&1)
echo -e "$results"

# check to see if DumpRenderTree tests
# fails, since it always returns 0
if [[ "$results" == *"Some tests failed"* ]]
then
    exit 1
fi

if [[ "$results" == *"Exception: "* ]]
then
    exit 1
fi

Here is the dart test file

import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
import 'dart:html';
import 'dart:async';
import 'package:polymer/polymer.dart';

main() {
  // Ensure Polymer is looking for bound variables...
  addXParent();
  initPolymer();
  removeXParent();

  setUp(addXParent);
  tearDown(removeXParent);

  group("encountermap", (){
    test('has canvas element', (){
      new Timer(
        new Duration(milliseconds: 2500),
        expectAsync0((){
          expect(
            querySelector('encounter-map').shadowRoot.querySelector('canvas'),
            isNotNull
          );
        })
      );
    });

    test("contains file input element", (){
      new Timer(
        new Duration(milliseconds: 2500),
        expectAsync0((){
          expect(
            querySelector('encounter-map').shadowRoot.querySelector('input'),
            isNotNull
          );
          expect(
              querySelector('encounter-map').shadowRoot.querySelector('input'),
              new isInstanceOf<FileUploadInputElement>()
          );
          expect(
            querySelector('encounter-map').shadowRoot.querySelector('input').attributes['type'],
            contains('file')
          );
        })
      );
    });
  });
}

addXParent() {
  document.body.append(createElement('<encounter-map></encounter-map>'));
}

removeXParent() {
  querySelectorAll('encounter-map').forEach((el)=> el.remove());
}

createElement(String html) =>
  new Element.html(html, treeSanitizer: new NullTreeSanitizer());

class NullTreeSanitizer implements NodeTreeSanitizer {
  void sanitizeTree(node) {}
}

and the index.html file

<head>
<!-- Load component(s) -->
<link rel="import" href="packages/RPGHelper/encountermap.html">
<script type="application/dart" src="test.dart"></script>
<script src="packages/unittest/test_controller.js"></script>
</head>

I've watched as this test is run and all that happens is content_shell doesn't exit, stopping the script from finishing, thus timing out. You can find the entire source for this project here

This is really driving me up the wall. Is this a bug? And in case it makes a difference the version of dart I'm using is "Dart SDK version 1.1.0-dev.4.0"

Also this test runs perfectly in "Dart Editor version 1.1.0.dev_04_00 (DEV)", just not when using content_shell

2 Answers
Related