From 3d1a90e260483ac31beef7a728520e7e01e20419 Mon Sep 17 00:00:00 2001
From: Bruno Pinto <brunoferreirapinto@gmail.com>
Date: Sat, 19 Dec 2015 12:02:37 +0000
Subject: [PATCH] Split formatter from test runner

---
 pkg/fish-spec/basic_formatter.fish     | 44 +++++++++++++++++++++++
 pkg/fish-spec/functions/fish-spec.fish | 49 +++-----------------------
 2 files changed, 48 insertions(+), 45 deletions(-)
 create mode 100644 pkg/fish-spec/basic_formatter.fish

diff --git a/pkg/fish-spec/basic_formatter.fish b/pkg/fish-spec/basic_formatter.fish
new file mode 100644
index 0000000..0a47e9b
--- /dev/null
+++ b/pkg/fish-spec/basic_formatter.fish
@@ -0,0 +1,44 @@
+function __fish-spec.spec_init -e spec_init -a spec
+  set -e __current_spec_status
+end
+
+function __fish-spec.spec_finished -e spec_finished -a spec
+  functions -e $spec
+
+  switch "$__current_spec_status"
+    case success
+      emit spec_success
+    case error
+      emit spec_error
+    case '*'
+      emit spec_no_assertions
+  end
+end
+
+function __fish-spec.spec_success -e spec_success
+  echo -n '.'
+end
+
+function __fish-spec.spec_error -e spec_error
+  echo -n 'F'
+  set -g __any_spec_failed true
+end
+
+function __fish-spec.spec_no_assertions -e spec_no_assertions
+  echo -n 'N/A'
+end
+
+function __fish-spec_assertion_success -e assertion_success
+  set -q __current_spec_status; or set -g __current_spec_status success
+end
+
+function __fish-spec_assertion_error -e assertion_error -a error_message
+  # Mimics output redirect inside an event handler
+  if set -q __fish_spec_output
+    set __fish_spec_output $error_message
+  else
+    echo $error_message
+  end
+
+  set -g __current_spec_status error
+end
diff --git a/pkg/fish-spec/functions/fish-spec.fish b/pkg/fish-spec/functions/fish-spec.fish
index bf5ea09..f8bdcd4 100644
--- a/pkg/fish-spec/functions/fish-spec.fish
+++ b/pkg/fish-spec/functions/fish-spec.fish
@@ -1,4 +1,8 @@
 function fish-spec
+  # Source formatter
+  set -l fish_spec_dir (dirname (dirname (status -f)))
+  source $fish_spec_dir/basic_formatter.fish
+
   # Reset internal variables
   set -e __any_spec_failed
 
@@ -46,48 +50,3 @@ function __fish-spec.run_suite -a suite_name
 
   functions -e before_all before_each after_each after_all
 end
-
-function __fish-spec.spec_init -e spec_init -a spec
-  set -e __current_spec_status
-end
-
-function __fish-spec.spec_finished -e spec_finished -a spec
-  functions -e $spec
-
-  switch "$__current_spec_status"
-    case success
-      emit spec_success
-    case error
-      emit spec_error
-    case '*'
-      emit spec_no_assertions
-  end
-end
-
-function __fish-spec.spec_success -e spec_success
-  echo -n '.'
-end
-
-function __fish-spec.spec_error -e spec_error
-  echo -n 'F'
-  set -g __any_spec_failed true
-end
-
-function __fish-spec.spec_no_assertions -e spec_no_assertions
-  echo -n 'N/A'
-end
-
-function __fish-spec_assertion_success -e assertion_success
-  set -q __current_spec_status; or set -g __current_spec_status success
-end
-
-function __fish-spec_assertion_error -e assertion_error -a error_message
-  # Mimics output redirect inside an event handler
-  if set -q __fish_spec_output
-    set __fish_spec_output $error_message
-  else
-    echo $error_message
-  end
-
-  set -g __current_spec_status error
-end
-- 
GitLab