llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.66k stars 11.85k forks source link

'lit' should execute everything "internally" #5613

Open llvmbot opened 15 years ago

llvmbot commented 15 years ago
Bugzilla Link 5241
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @modocache,@rnk

Extended Description

'lit' currently has code for executing tests "internally", but we currently execute tests using shell for performance/scalability reasons.

We should find a good way to execute things internally and still get good performance. Ideally this would also solve other related problems like improving the behavior of lit when it gets a SIGINT, implementing timeouts for tests, and maybe others.

Some possible implementation strategies are:

  1. Use the python multiprocess module. I'm skeptical about its robustness, though.

  2. Implement some components in C++. This is painful to get right and be cross-platform, but it would at least motivate getting nice sophisticated LLVMSystem process (and thread, and pipe) support. OTOH this would be very robust, and interact well with the GIL and signals.

  3. Wait for Unladen Swallow to kill the GIL? :)

Notice how no option is particularly compelling...

rnk commented 8 years ago

I recently spent some time looking at uses of 'REQUIRES: shell', and the two main things that stand out are:

rnk commented 8 years ago

Pasting some more relevant info from the duped bug: (This task was copied from https://reviews.llvm.org/diffusion/L/browse/llvm/tags/RELEASE_390/final/utils/lit/TODO. It was originally written by Daniel Dunbar.)

Currently, the ShTest format uses tests written with shell-script like syntax, and executes them in one of two ways. The first way is by converting them into a bash script and literally executing externally them using bash. The second way is through the use of an internal shell parser and shell execution code (built on the subprocess module). The external execution mode is used on most Unix systems that have bash, the internal execution mode is used on Windows.

Having two ways to do the same thing is error prone and leads to unnecessary complexity in the testing environment. Additionally, because the mode that converts scripts to bash doesn't try and validate the syntax, it is possible to write tests that use bash shell features unsupported by the internal shell. Such tests won't work on Windows but this may not be obvious to the developer writing the test.

Another limitation is that when executing the scripts externally, the ShTest format has no idea which commands fail, or what output comes from which commands, so this limits how convenient the output of ShTest failures can be and limits other features (for example, knowing what temporary files were written).

We should eliminate having two ways of executing the same tests to reduce platform differences and make it easier to develop new features in the ShTest module. This is currently blocked on:

rnk commented 8 years ago

Bug llvm/llvm-bugzilla-archive#30667 has been marked as a duplicate of this bug.

llvmbot commented 15 years ago

Note that one reasonably viable option is a variant of 1., where we hand roll a pure Python multiprocessing based solution.

We can also make #​2 substantially simpler by committing to using temporary files between test commands, instead of pipes, which isn't unreasonable since it might be nice to have them around for showing to users in the case of failures, and should have no negative performance impact.