about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--001help.cc12
-rw-r--r--020run.cc4
-rw-r--r--050scenario.cc9
-rwxr-xr-xmu15
4 files changed, 38 insertions, 2 deletions
diff --git a/001help.cc b/001help.cc
index a0241e95..fa5c3547 100644
--- a/001help.cc
+++ b/001help.cc
@@ -11,6 +11,10 @@ if (argc <= 1 || is_equal(argv[1], "--help")) {
        << "  mu test\n"
        << "To load files and then run all tests:\n"
        << "  mu test file1.mu file2.mu ...\n"
+       << "To load files and run only the tests in explicitly loaded files (for apps):\n"
+       << "  mu --test-only-app test file1.mu file2.mu ...\n"
+       << "'--test-only-app' must come before all other args\n"
+       << "'test' must come before all other args except '--test-only-app'\n"
        << "To load all files with a numeric prefix in a directory:\n"
        << "  mu directory1\n"
        << "You can test directories just like files.\n"
@@ -194,6 +198,14 @@ bool has_data(istream& in) {
   return in && !in.eof();
 }
 
+////: A hack to support faster debugging.
+:(before "End Globals")
+bool Test_only_app = false;
+:(before "End Commandline Parsing")
+if (argc > 1 && is_equal(argv[1], "--test-only-app")) {
+  Test_only_app = true;  --argc;  ++argv;
+}
+
 :(before "End Includes")
 #include <assert.h>
 
diff --git a/020run.cc b/020run.cc
index 8ea341e4..72fda856 100644
--- a/020run.cc
+++ b/020run.cc
@@ -152,8 +152,8 @@ if (argc > 1) {
   while (argc > 0) {
     if (string(*argv) == "--") break;
     load_file_or_directory(*argv);
-    argv++;
-    argc--;
+    --argc;
+    ++argv;
   }
   if (Run_tests) Recipe.erase(get(Recipe_ordinal, "main"));
 }
diff --git a/050scenario.cc b/050scenario.cc
index eec1bd84..28ef58e7 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -119,6 +119,7 @@ Num_core_mu_tests = SIZE(Scenarios);
 Hide_missing_default_space_errors = false;
 time_t mu_time; time(&mu_time);
 cerr << "\nMu tests: " << ctime(&mu_time);
+run_mu_scenarios:
 for (int i = 0; i < SIZE(Scenarios); ++i) {
 //?   cerr << i << ": " << Scenarios.at(i).name << '\n';
   if (i == Num_core_mu_tests) {
@@ -129,6 +130,14 @@ for (int i = 0; i < SIZE(Scenarios); ++i) {
   if (Passed) cerr << ".";
 }
 
+:(after "End Test Run Initialization")
+if (Test_only_app && Num_core_mu_tests < SIZE(Scenarios)) {
+  // we have app tests; skip core mu tests
+  Scenarios.erase(Scenarios.begin(), Scenarios.begin()+Num_core_mu_tests);
+  // skip C tests
+  goto run_mu_scenarios;
+}
+
 //: Convenience: run a single named scenario.
 :(after "Test Runs")
 for (int i = 0; i < SIZE(Scenarios); ++i) {
diff --git a/mu b/mu
index 3b1bb6c4..0a8dd082 100755
--- a/mu
+++ b/mu
@@ -5,4 +5,19 @@
 # show make output only if something needs doing
 make -q || make >&2 || exit 1
 
+# If I'm setting flags at the commandline I'm often disabling optimizations.
+# In that case don't run all tests if I load any app files.
+if [[ $CFLAGS && $# -gt 0 && $1 != '--help' ]]  # latter two conditions are to continue printing the help message
+then
+  ./mu_bin --test-only-app "$@"
+  exit 1
+fi
+
 ./mu_bin "$@"
+
+# Scenarios considered:
+#   mu
+#   mu --help
+#   mu test
+#   mu test file1.mu
+#   CFLAGS=-g mu test file1.mu  # run only tests in file1.mu