private void testScriptFile(String scriptText, List<String> argList,
      OutStream streamType, List<Tuple<String>> expectedMatches, List<Modes> modes)
      throws Throwable {
    // Put the script content in a temp file
    File scriptFile = File.createTempFile(this.getClass().getSimpleName(), "temp");
    System.out.println("script file is " + scriptFile.getAbsolutePath());
    scriptFile.deleteOnExit();
    PrintStream os = new PrintStream(new FileOutputStream(scriptFile));
    os.print(scriptText);
    os.close();

    List<Tuple<Pattern>> patternsToBeMatched = Lists.transform(expectedMatches,
        new Function<Tuple<String>, Tuple<Pattern>>() {
          @Override
          public Tuple<Pattern> apply(Tuple<String> tuple) {
            return new Tuple<>(
                Pattern.compile(".*" + tuple.pattern + ".*", Pattern.DOTALL),
                tuple.shouldMatch
            );
          }
        });

    for (Modes mode : modes) {
      String output = mode.output(scriptFile, argList, streamType);
      for (Tuple<Pattern> patternToMatch : patternsToBeMatched) {
        Matcher m = patternToMatch.pattern.matcher(output);
        boolean matches = m.matches();
        if (patternToMatch.shouldMatch != matches) {
          //failed
          fail("Output" + output + " should" + (patternToMatch.shouldMatch ? "" : " not") +
              " contain " + patternToMatch.pattern.pattern());
        }
      }
    }
    scriptFile.delete();
  }
Attempt to execute a simple script file with the -f or -i option
to BeeLine (or both) to  test for presence of an expected pattern
in the output (stdout or stderr), fail if not found.
Print PASSED or FAILED
@param scriptText script to test the output for
@param argList arguments to be passed to the script file to execute and produce output
@param streamType Whether match should be done against STDERR or STDOUT
@param expectedMatches List of Tuple's defining the pattern to match and result of matching
@param modes testing modes we have to run the script as
@throws Exception on command execution error
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestBeeLineWithArgs.java