diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-03-20 14:56:57 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-03-20 15:13:30 -0700 |
commit | 390f4097d67ff648c7328f11e18642249650992c (patch) | |
tree | fb34bcf6f123912511ea5ca375f9dd528cac2d05 | |
parent | 2429c65cce16a11841212a71ec2bb50373aa54d4 (diff) | |
download | mu-390f4097d67ff648c7328f11e18642249650992c.tar.gz |
2800 - remove a gotcha when writing tests
Several times now I've wasted time tracking down a failing test only to eventually remember that order of definition matters in tests even though it doesn't elsewhere -- I've been having tests implicitly start running the first function defined in them. Now I stop doing that if a test defines a function called 'main', and just start the test at main instead.
-rw-r--r-- | 020run.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/020run.cc b/020run.cc index f3891cf6..3f68cb9c 100644 --- a/020run.cc +++ b/020run.cc @@ -329,7 +329,12 @@ void run(string form) { transform_all(); if (tmp.empty()) return; if (trace_count("error") > 0) return; - run(tmp.front()); + // if a test defines main, it probably wants to start there regardless of + // definition order + if (contains_key(Recipe, get(Recipe_ordinal, "main"))) + run(get(Recipe_ordinal, "main")); + else + run(tmp.front()); } :(scenario run_label) |