<div dir="ltr">I see many tests that are prefixed with "requires: shell".  A quick search over the codebase shows 101 tests that contain this directive.  This basically means there are 101 tests that say "I don't support running on Windows".  <div><br></div><div>I would like to get this number to 0.  </div><div><br></div><div>Ironically, many of these tests can be made to run on Windows simply by removing the requires: shell line.  As in, it doesn't *actually* require a shell.  This is because the meaning of requires shell is not intuitive.  <a href="http://llvm.org/docs/GettingStartedVS.html#software">GnuWin32</a> is already a required dependency, so any shell <i>command </i>that you are familiar with probably exists on Windows already.  For example, consider the following test in clang-tidy:</div><div><br></div><div><div>// REQUIRES: shell</div><div>// RUN: mkdir -p %T/compilation-database-test/include</div><div>// RUN: mkdir -p %T/compilation-database-test/a</div><div>// RUN: mkdir -p %T/compilation-database-test/b</div><div>// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp</div><div>// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp</div><div>// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp</div><div>// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp</div><div>// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h</div><div>// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp</div><div>// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json</div><div>// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*</div><div>// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix</div><div>// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1</div><div>// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2</div><div>// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3</div><div>// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4</div><div>// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5</div></div><div><br></div><div>This test does not require a shell!  Remove the line (and change the %S and %T on the sed line to %/S and %/T) and this test already works on Windows!</div><div><br></div><div>I have inspected around 20 tests so far that claim to require shell, and so far only about 3 of them are more complicated than removing the line.</div><div><br></div><div>"Great, so just remove the lines!  Why are you posting this?"</div><div><br></div><div>Well, It would be nice if we could remove the GnuWin32 dependency as well.  Lots of tests use grep, sed, cd, ln, or whatever.  Anyone who's ever tried downloading and installing GnuWin32 knows what a pain it is.  It installs programs called, for example, "link" which interfere with standard windows tools, and puts them in your path.  There are other examples of this.  And it's also HUGE.  And nobody can ever figure out how to download it correctly.  Plus there are some minor differences in the tools behavior.</div><div><br></div><div>I'm proposing that we replace shell commands in tests with a tool that we create which implements the most common shell commands and options.</div><div><br></div><div>it doesn't need to be a complete implementation of the commands.  Nobody cares about echo -n, or sed -u, for example.  We could keep it simple with the most common commands, most of which would be trivially implementable using the llvm Support library already.  Complicated commands like awk, for example, could be absent.  Chances are you need to simplify your test if you're using something like that (presently exactly 1 test in all of LLVM uses it).  What I'm imagining is something like this:</div><div><br></div><div><div>D:\src\llvmbuild\ninja>bin\llvm-shutil --help</div><div>OVERVIEW: LLVM Shell Utility Program</div><div><br></div><div>USAGE: llvm-shutil.exe [subcommand] [options]</div><div><br></div><div>SUBCOMMANDS:</div><div><br></div><div>  cd - Change current working directory</div><div>  mkdir   - Make a directory</div><div>  ln - Create a link</div><div>  grep - Search for content in a file</div><div>  sort - Sort lines</div><div>  // etc, rest of commands go here.</div><div>  </div><div>  Type "llvm-shutil.exe <subcommand> -help" to get more help on a specific subcommand</div><div><br></div><div>OPTIONS:</div><div><br></div><div>Generic Options:</div><div><br></div><div>  -stdout=<file>   - Redirect stdout to the specified file</div><div>  -stderr=<file>    - Redirect stderr to the specified file</div><div>  -stdin=<file>     - Read stdin from the specified file</div><div>  -help      - Display available options (-help-hidden for more)</div><div>  -help-list - Display list of available options (-help-list-hidden for more)</div><div>  -version   - Display the version of this program</div><div><br></div></div><div><br></div><div>With something like this, we could kill two birds with one stone.  GnuWin32 dependency is gone, and there is no more confusion about what "requires: shell" actually means.</div><div><br></div><div>The reason we wrote lit the way we did is so that everyone could be speaking the same language when they write tests, no matter which platform they're on.  So it would be nice to eliminate the last area where this is still not the case.</div><div><br></div><div>thoughts?</div></div>