This is all outlined in the rulebook!
For Moves a fall or touchdown of a hand or foot to keep the skater from falling is considered a "serious error" - if there is one Move that has a serious error the skater may be asked to re-skate the element. If there is a serious error in the re-skate then the test cannot pass. Also if a Move is omitted from the test - it can be "reskated" but that will count as the one reskate for the test and if there are other serious errors then the test cannot pass. (TR 20.02 2011-2012 Tests book).
For freestyle the following are considered serious errors: a fall, incomplete rotation of a jump on either the take-off or landing, two-footed landings on jumps, a touchdown of the hand or free foot needed to save the skater from falling, a blatant change of edge before a jump (like on a lutz or a flip), when a combination jump is required, a turn between the two jumps of that combination and failure to hold spins for the required revolutions or to attain the required positions in the spins and omission of a required element.
If there is only one serious error the judges have the option of using the presentation mark to pass the test. If there are two serious errors then the judges can ask for a re-skate of that element and the skater can choose to do a different element than what was in the program as long as the skater chooses something that satisfies the requirement for elements in that test. If the error is not corrected on the re-skate then the test cannot pass. (TR 27.02).
Pairs is similar to freestyle in that only two elements can be re-skated.
Dance is a little more wishy-washy in that there are no serious errors listed in the rulebook but you can bet your life that if you do the wrong steps or fall you will be asked to skate another pattern UNLESS you recovered so well from the fall or got the step corrected on the 2nd and 3rd patterns then you might just pass without a re-skate.
Pairs