[Groonga-commit] groonga/grntest [master] Change directive syntax

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 11 21:52:00 JST 2012


Kouhei Sutou	2012-10-11 21:52:00 +0900 (Thu, 11 Oct 2012)

  New Revision: 07c4cacbbab4c33a7ae4dfb471644f28719fcc2b
  https://github.com/groonga/grntest/commit/07c4cacbbab4c33a7ae4dfb471644f28719fcc2b

  Log:
    Change directive syntax
    
    Before:
      # NAME ARGUMENTS...
    
    After:
      #@NAME ARGUMENTS...

  Modified files:
    README.md
    lib/grntest/tester.rb

  Modified: README.md (+13 -13)
===================================================================
--- README.md    2012-10-10 23:10:25 +0900 (ce7803f)
+++ README.md    2012-10-11 21:52:00 +0900 (90412c0)
@@ -202,7 +202,7 @@ Grntest supports directives that control grntest behavior.
 Here is directive syntax:
 
 ```
-# NAME [ARGUMENTS...]
+#@NAME [ARGUMENTS...]
 ```
 
 Here are available `NAME` s:
@@ -220,7 +220,7 @@ any arguments but a directive requires arguments.
 Usage:
 
 ```
-# disable-logging
+#@disable-logging
 ```
 
 It disables logging exected command and exected result until
@@ -230,14 +230,14 @@ commands that isn't important for test.
 Example:
 
 ```
-# disable-logging
+#@disable-logging
 load --table Users
 [
 {"_key": "User1"},
 {"_key": "..."},
 {"_key": "User9999999"}
 ]
-# enable-logging
+#@enable-logging
 
 select Users --query _key:User29
 ```
@@ -249,7 +249,7 @@ See also: `enable-logging`
 Usage:
 
 ```
-# enable-logging
+#@enable-logging
 ```
 
 It enables logging that is disabled by `disable-logging` directive.
@@ -261,7 +261,7 @@ See also: `disable-logging`
 Usage:
 
 ```
-# suggest-create-dataset DATASET_NAME
+#@suggest-create-dataset DATASET_NAME
 ```
 
 It creates dataset `DATASET_NAME` for suggest feature. It is useful
@@ -270,7 +270,7 @@ for testing suggest feature.
 Example:
 
 ```
-# suggest-create-dataset rurema
+#@suggest-create-dataset rurema
 load --table event_rurema --each 'suggest_preparer(_id, type, item, sequence, time, pair_rurema)'
 [
 ["sequence", "time", "item", "type"],
@@ -288,7 +288,7 @@ See also: `--groonga-suggest-create-dataset` option
 Usage
 
 ```
-# include SUB_TEST_FILE_PATH
+#@include SUB_TEST_FILE_PATH
 ```
 
 It includes `SUB_TEST_FILE_PATH` content. It is useful for sharing
@@ -305,10 +305,10 @@ Example:
 
 init.grn:
 ```
-# disable-logging
-# include ddl.grn
-# include data.grn
-# enable-logging
+#@disable-logging
+#@include ddl.grn
+#@include data.grn
+#@enable-logging
 ```
 
 ddl.grn:
@@ -328,7 +328,7 @@ load --table Users
 
 user.test:
 ```
-# include init.grn
+#@include init.grn
 select Users --query _key:Alice
 ```
 

  Modified: lib/grntest/tester.rb (+18 -5)
===================================================================
--- lib/grntest/tester.rb    2012-10-10 23:10:25 +0900 (2522ce6)
+++ lib/grntest/tester.rb    2012-10-11 21:52:00 +0900 (b164031)
@@ -1223,17 +1223,19 @@ EOF
 
       def execute_line(line)
         case line
+        when /\A\#@/
+          directive_content = $POSTMATCH
+          execute_directive(line, directive_content)
         when /\A\s*\z/
           # do nothing
         when /\A\s*\#/
-          comment_content = $POSTMATCH
-          execute_comment(comment_content)
+          # ignore comment
         else
           execute_command_line(line)
         end
       end
 
-      def execute_comment(content)
+      def execute_directive(line, content)
         command, *options = Shellwords.split(content)
         case command
         when "disable-logging"
@@ -1242,12 +1244,23 @@ EOF
           @context.logging = true
         when "suggest-create-dataset"
           dataset_name = options.first
-          return if dataset_name.nil?
+          if dataset_name.nil?
+            log_input(line)
+            log_error("#|e| [suggest-create-dataset] dataset name is missing")
+            return
+          end
           execute_suggest_create_dataset(dataset_name)
         when "include"
           path = options.first
-          return if path.nil?
+          if path.nil?
+            log_input(line)
+            log_error("#|e| [include] path is missing")
+            return
+          end
           execute_script(Pathname(path))
+        else
+          log_input(line)
+          log_error("#|e| unknown directive: <#{command}>")
         end
       end
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index