private void compileTestProgram(String testFileName) throws UserError {
    Path path = ProjectProperties.SOURCE_PATH;
    String s = ProjectProperties.BASEDIR + "tests" + File.separator + testFileName;

    //        System.err.println("compileTestProgram(" + s + ")");

    File file = new File(s);
    s = file.getPath();

    if (s.contains(File.separator)) {
      String head = s.substring(0, s.lastIndexOf(File.separator));
      s = s.substring(s.lastIndexOf(File.separator) + 1, s.length());
      path = path.prepend(head);
    }

    // HACK: We need to compile these test programs using the old Fortress
    // libraries instead of the new compiler libraries.
    // Shell.useFortressLibraries();

    Iterable<? extends StaticError> errors = Shell.compilerPhases(path, s);

    for (StaticError error : errors) {
      fail(error.toString());
    }
  }
Example #2
0
 /* find the api name for a file and chop it off the source path.
  * what remains from the source path is the directory that contains
  * the file( including sub-directories )
  */
 public static Path sourcePath(String file, APIName name) throws IOException {
   Debug.debug(Debug.Type.REPOSITORY, 2, "True api name is ", name);
   String fullPath = new File(file).getCanonicalPath();
   Debug.debug(Debug.Type.REPOSITORY, 2, "Path is ", fullPath);
   Path path = ProjectProperties.SOURCE_PATH;
   /* the path to the file is /absolute/path/a/b/c/foo.fss and the apiname is
    * a.b.c.foo, so we need to take off the apiname plus four more characters,
    * ".fss" or ".fsi"
    */
   String source = fullPath.substring(0, fullPath.length() - (name.toString().length() + 4));
   path = path.prepend(source);
   Debug.debug(Debug.Type.REPOSITORY, 2, "Source path is ", source);
   Debug.debug(Debug.Type.REPOSITORY, 2, "Lookup path is ", path);
   return path;
 }