Przeglądaj źródła

Refactor ffoo_import test inc. docstrings

...so that it can be understood by future reader.
Alois Mahdal 10 lat temu
rodzic
commit
875fd46b01
1 zmienionych plików z 25 dodań i 11 usunięć
  1. 25
    11
      test/tests/ffoo_import/TF_RUN

+ 25
- 11
test/tests/ffoo_import/TF_RUN Wyświetl plik

@@ -33,11 +33,12 @@ ignored() {
33 33
     echo FFOO_VERSION
34 34
 }
35 35
 
36
-print_listing_code() {
36
+mksnippet() {
37 37
     #
38
-    # Print the code that stores the listing we need to compare
38
+    # Produce a snippet to store env info to a file $1
39 39
     #
40
-    # This will be included into the mini-test.
40
+    # File _ignored_ is used as list of tokens to always
41
+    # remove from the info.
41 42
     #
42 43
     local target=$1
43 44
     printf "
@@ -50,24 +51,37 @@ print_listing_code() {
50 51
         " $target
51 52
 }
52 53
 
53
-assemble_test_script() {
54
+wrap_test() {
54 55
     #
55
-    # Assemble test script from listing code and import code
56
+    # Assemble and print test script code
56 57
     #
57
-    # Assemble test script by including listing code, importing
58
-    # code and listing code again.  Final script should generate
59
-    # $1.before and $2.after
58
+    # Assemble test script by including scanning snippet,
59
+    # importing code from file $1, and snippet again.  If run,
60
+    # the code printed by this function will generate two
61
+    # files: $1.before and $1.after.
60 62
     #
61 63
     local name=$1
62
-    print_listing_code $name.before
64
+    mksnippet $name.before
63 65
     cat "$name" \
64 66
       | sed -e "s|\\<ffoom\\>|$ffoom_path|"   # << since PATH may be empty
65
-    print_listing_code $name.after
67
+    mksnippet $name.after
66 68
 }
67 69
 
68 70
 tf_do_subtest() {
71
+    #
72
+    # Prepare, run and check results of test $1
73
+    #
74
+    # Contents of $1 file (which is supposed to be importing
75
+    # code) are altered for testing and wrapped so that on
76
+    # execution in clean environment, two files are produced to
77
+    # hold sets of detected variable and function names--before
78
+    # import and after it.
79
+    #
80
+    # The difference of the sets (i.e. what we have *really*
81
+    # imported) must be same as $1.oracle.
82
+    #
69 83
     local name=$1
70
-    assemble_test_script $name > $name.sh
84
+    wrap_test $name > $name.sh
71 85
     env -i bash $name.sh
72 86
     comm -13 $name.before $name.after > $name.new
73 87
     # i.e. lines introduced by import ^^