Exemple #1
0
def RunTestSets(base_dir):
    """Extract and run test sets."""
    print "** For default test sets, please run:"
    print "fileutil cp /cns/ih-d/home/gee/test_sets/*.tgz test_sets/"
    utils.ChDir("%s/test_sets" % base_dir)
    for test_set_tarball in os.listdir("."):
        if test_set_tarball.endswith(".tgz"):
            # Extract tests
            utils.ExecuteCmd("tar -xzf %s" % test_set_tarball)
            utils.ChDir("test_set")
            # Run tests
            RunTests(test_set_tarball)
            utils.ChDir("..")
            # Clean up
            utils.ExecuteCmd("rm -rf test_set")
def SetUpPropertiesFile(installer_dir, template, replace):
  """Create a properties file from the template."""
  utils.ChDir(installer_dir)
  content = utils.GetFileWithReplace(template, replace)
  fp = open("%s/installer.properties" % installer_dir, "w")
  fp.write(content)
  fp.close()
  utils.ExecuteCmd("chmod 755 installer.properties")
def RunTests(base_dir):
  """Runs tests in the test directory."""
  utils.ChDir(base_dir)
  num_tests = 0
  successes = 0
  for test in os.listdir("tests"):
    utils.ChDir("%s/tests" % base_dir)
    if not test.startswith("__") and test.endswith(".py"):
      num_tests += 1
      result = utils.ExecuteCmd("./%s" % test)
      lines = result.split("\n")
      num_lines = len(lines)
      for i in xrange(num_lines):
        if lines[num_lines - 1 - i].strip():
          if "SUCCESS" in lines[num_lines - 1 - i]:
            successes += 1
          print result
          break
  print "*****"
  print "%d of %d tests passed." % (successes, num_tests)
def UnpackTarball(path):
  """Unpack installer from tarball."""
  if not os.path.exists(path):
    print "Unable to find %s." % path
    return False
  if not path.endswith("tar.gz"):
    print "Expecting %s to be installer tarball ending in .tar.gz" % path
    return False
  utils.ChDir(TMP_DIR)
  utils.ExecuteCmd("tar -xzf %s" % path)
  return True
def GetTests(base_dir):
  """Get tests from cns and unpack them."""
  utils.ChDir(base_dir)
  test_sets = [
      "/cns/ih-d/home/bpeterson/gee_tests/gold_tests.tgz"
      ]
  for test_set in test_sets:
    utils.ExecuteCmd("fileutil cp %s test_set.tgz" % test_set)
    utils.ExecuteCmd("tar -xzf test_set.tgz")
    for path in os.listdir("test_set"):
      utils.ExecuteCmd("cp -r test_set/%s tests/" % path)
    utils.ExecuteCmd("rm test_set.tgz")
    utils.ExecuteCmd("rm -rf test_set")
    print "installed test set %s" % test_set
def BuildTutorial(base_dir):
  """Build tutorial databases."""
  utils.ChDir(base_dir)
  utils.ExecuteCmd("env PATH=\"$PATH:/opt/google/bin\" ./run_tutorial.sh")
Exemple #7
0
def RunLocalTests(base_dir):
    """Runs tests in the test directory."""
    utils.ChDir(base_dir)
    utils.ChDir("%s/tests" % base_dir)
    RunTests("local")