Exemplo n.º 1
0
  // TODO rename this - always call before (only once) before using PhptTestPack
  public void add_named_tests(
      List<PhptTestCase> test_files,
      List<String> names,
      PhptTelemetryWriter twriter,
      PhpBuild build,
      boolean ignore_missing)
      throws FileNotFoundException, IOException, Exception {
    test_pack_file = new File(test_pack);
    test_pack = test_pack_file.getAbsolutePath(); // normalize path

    LinkedList<PhptTestCase> redirect_targets = new LinkedList<PhptTestCase>();

    Iterator<String> name_it = names.iterator();
    String name;
    File file;
    PhptTestCase test_case;
    while (name_it.hasNext()) {
      name = name_it.next();

      if (name.endsWith(PhptTestCase.PHPT_FILE_EXTENSION)) {
        file = new File(test_pack_file, host.fixPath(name));
        if (file.exists()) {
          // String is exact name of test

          test_case = PhptTestCase.load(host, this, name, twriter);

          add_test_case(test_case, test_files, names, twriter, build, null, redirect_targets);

          // don't need to search for it
          name_it.remove();
        }
      }
    }

    if (names.size() > 0) {
      // assume any remaining names are name fragments and search for tests with matching names

      add_test_files(
          test_pack_file.listFiles(), test_files, names, twriter, build, null, redirect_targets);
    }

    if (!ignore_missing && names.size() > 0) {
      // one or more test names not matched to an actual test
      throw new FileNotFoundException(names.toString());
    }

    // sort alphabetically
    Collections.sort(
        test_files,
        new Comparator<PhptTestCase>() {
          @Override
          public int compare(PhptTestCase o1, PhptTestCase o2) {
            return o2.getName().compareTo(o2.getName());
          }
        });

    twriter.setTotalCount(test_files.size());
  }
Exemplo n.º 2
0
 public boolean open(Host host) {
   this.host = host;
   this.test_pack = host.fixPath(test_pack);
   return host.exists(this.test_pack);
 }