*: =index | <SHA1>=  The commit to build, "index" means use the SHA from git write-tree
 *: =<description>= (optional) Description for the workspace build
-*: =all | win | win+ | warn= (optional), passed on to build_workspace script on submit-3
+*: =all | win | win+ | warn= (optional), passed on to submit_workspace script on submit-3 as the platform arguments
+
 {file: build_workspace.bat}
 @echo off
 @setlocal
@@ -373,7 +374,7 @@
 if NOT "%1"=="" set platforms=%1
 
 @echo on
-%tar% | plink -2 -i %USERPROFILE%\keys\putty.ppk -l %USERNAME% %submit% cd workspace ; mkdir %dir% ; cd %dir% ; tar xf - ; ../build_workspace %desc% %platforms%
+%tar% | plink -2 -i %USERPROFILE%\keys\putty.ppk -l %USERNAME% %submit% cd workspace ; mkdir %dir% ; cd %dir% ; tar xf - ; ../submit_workspace %desc% %platforms%
 @echo off
 goto :EOF
 
@@ -394,84 +395,79 @@
 ..\build_workspace index description all
 {endterm}
 
-{subsection: build_workspace (shell script)}
-This bash script invokes nmi_condor_submit It should be executed while at the root of a git clone or archive on one of the batlab submit machines. Arguments are optional the first is the description and second is shorthand for combinations of platform. default is to build on Win8 and Fedora21
+{subsection: submit_workspace (shell script)}
+When run from the root of a git clone or archive, submits the current directory as a workspace build or test. arguments are
+*: =-test <runid>= (optional - must be first) submit a workspace test against the given build id.
+*: =<description>= description of the workspace build/test
+*: =<platforms>= (optional) comma separated list of platforms, or a platform category code. categories are =all win fedora deb mac warn fast win+=. =warn= is platforms with that treat warnings as errors (i.e. fedora). =fast= is platforms that build quickly - fedora, solaris and Win8.
 
-*: =<description>= the description string
-*: =all= build on all platforms
-*: =win= build on all windows platforms
-*: =win+= build on windows and fedora
-*: =warn|fedora= build on fedora
-*: =fast= build on fedora and solaris
-*: =deb= build on all debian
-{file: build_workspace}
+{file: submit_workspace}
 #!/bin/bash
 
-TAG="$1"
-PLATFORMS="x86_64_Windows8,x86_64_Fedora21"
-
-if [[ $2 = "all" || $2 = "ALL" ]]
-then
-   PLATFORMS="all"
-fi
-
-if [[ $2 = "win" || $2 = "WIN" ]]
-then
-   PLATFORMS="x86_64_Windows7,x86_64_Windows8"
-fi
-
-if [[ $2 = "win+" || $2 = "WIN+" ]]
-then
-   PLATFORMS="x86_64_Windows7,x86_64_Windows8,x86_64_Fedora21,x86_64_Fedora22"
+# args are [-test <runid>] <descrip> [<platforms>]
+function usage
+{
+   echo "Usage: $0 [-test <runid>] <descrip> [<platforms>]"
+   echo "   <platforms> may be comma separated list of NMI platforms or a category"
+   echo "               categories are: all|win|fedora|deb|mac|warn|fast|win+"
+}
+
+
+declare -A plat
+plat[win]="x86_64_Windows7,x86_64_Windows8,x86_64_Windows10"
+plat[fedora]="x86_64_Fedora21,x86_64_Fedora22"
+plat[deb]="x86_64_Debian6,x86_64_Debian7,x86_64_Debian8"
+plat[mac]="x86_64_MacOSX7,x86_64_MacOSX8,x86_64_MacOSX10"
+plat[fast]="${plat["fedora"]},x86_64_Solaris11,x86_64_Windows8"
+plat[warn]="${plat["fedora"]}"
+plat[win+]="${plat["win"]},${plat["fedora"]}"
+plat[all]="all"
+
+# if first arg is -test then second arg must be a runid
+RUNID=""
+TASK="building"
+if [[ "$1" = "-test" ]]
+then
+   if [ -z "$2" ]; then usage; exit 1; fi
+   RUNID="$2"
+   TASK="testing"
+   shift; shift;
 fi
 
-if [[ $2 = "win8" || $2 = "WIN8" ]]
-then
-   PLATFORMS="x86_64_Windows8"
-fi
-
-if [[ $2 = "fedora" || $2 = "warn" || $2 == "fast" || $2 == "winfast" ]]
-then
-   PLATFORMS="x86_64_Fedora21,x86_64_Fedora22"
-  if [[ $2 == "fast" || $2 == "winfast" ]]
-  then
-     PLATFORMS="${PLATFORMS},x86_64_Solaris11"
-  fi
-  if [[ $2 == "winfast" ]]
-  then
-     PLATFORMS="${PLATFORMS},x86_64_Windows7,x86_64_Windows8"
-  fi
-fi
-
-if [[ $2 = "f22" ]]
-then
-   PLATFORMS="x86_64_Fedora22"
-fi
+# next arg (description) is required
+if [ -z "$1" ]; then usage; exit 1; fi
+TAG="$1"
 
-if [[ $2 = "deb" ]]
+PLATFORMS="$2"
+if [[ $2 = "all" || $2 = "win" || $2 = "fedora" || $2 = "deb" || $2 = "mac" || $2 = "fast" || $2 = "win+" ]]
 then
-   PLATFORMS="x86_64_Debian6,x86_64_Debian7,x86_64_Debian8"
+    PLATFORMS="${plat[$2]}"
 fi
 
 pwd
 if [ -d "nmi_tools" ]
 then
-   echo "building temporary workspace"
+   echo "$TASK temporary workspace"
    pushd nmi_tools
 else
-   echo "building main workspace"
+   echo "$TASK main workspace"
    pushd ~johnkn/workspace/CONDOR_SRC/nmi_tools
 fi
 pwd
 
-./condor_nmi_submit --build --git --notify-fail-only --workspace=.. --desc="$TAG" -platforms="$PLATFORMS"
-echo ./condor_nmi_submit --build --git --notify-fail-only --workspace=.. --desc=\"$TAG\" -platforms=\"$PLATFORMS\"
-pwd
+if [ -z "$RUNID" ]
+then
+  #./condor_nmi_submit --build --git --notify-fail-only --workspace=.. --desc="$TAG" -platforms="$PLATFORMS"
+  echo ./condor_nmi_submit --build --git --notify-fail-only --workspace=.. --desc=\"$TAG\" -platforms=\"$PLATFORMS\"
+else
+  #./condor_nmi_submit --test --buildid=$RUNID --workspace=.. --desc="$TAG" -platforms="$PLATFORMS" --ignore-missing-platforms --test-sources-from-workspace
+  echo ./condor_nmi_submit --test --buildid=$RUNID --workspace=.. --desc=\"$TAG\" -platforms=\"$PLATFORMS\" --ignore-missing-platforms --test-sources-from-workspace
+fi
 popd
 {endfile}
 Example
 {term}
-cp build_workspace ~/workspace
+cp submit_workspace ~/workspace
 cd ~/workspace/wkNNN
-../build_workspace
+../submit_workspace queue-stuff all
 {endterm}