You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by re...@apache.org on 2019/07/18 01:46:34 UTC

[incubator-mxnet] branch master updated: make clojure api generator tests less brittle (#15579)

This is an automated email from the ASF dual-hosted git repository.

reminisce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 9983adb  make clojure api generator tests less brittle (#15579)
9983adb is described below

commit 9983adbaa8993c038acb65d7d6195d012c418967
Author: Carin Meier <cm...@gigasquidsoftware.com>
AuthorDate: Wed Jul 17 21:45:52 2019 -0400

    make clojure api generator tests less brittle (#15579)
---
 .../clojure-package/test/dev/generator_test.clj    | 41 +++++++++++++---------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/contrib/clojure-package/test/dev/generator_test.clj b/contrib/clojure-package/test/dev/generator_test.clj
index acc81af..3d7d41f 100644
--- a/contrib/clojure-package/test/dev/generator_test.clj
+++ b/contrib/clojure-package/test/dev/generator_test.clj
@@ -17,7 +17,14 @@
 
 (ns dev.generator-test
   (:require [clojure.test :refer :all]
-            [dev.generator :as gen]))
+            [dev.generator :as gen]
+            [clojure.string :as string]))
+
+(defn file-function-name [f]
+  (->> (string/split (slurp f) #"\n")
+       (take 33)
+       last
+       (string/trim)))
 
 (deftest test-clojure-case
   (is (= "foo-bar" (gen/clojure-case "FooBar")))
@@ -334,20 +341,20 @@
           fns (gen/all-symbol-api-functions gen/op-names)
           _ (gen/write-to-file [(first fns) (second fns)]
                                (gen/symbol-api-gen-ns false)
-                               fname)
-          good-contents (slurp "test/good-test-symbol-api.clj")
-          contents (slurp fname)]
-      (is (= good-contents contents))))
+                               fname)]
+      (is (= "activation"
+             (file-function-name "test/good-test-symbol-api.clj")
+             (file-function-name fname)))))
 
   (testing "symbol-random-api"
     (let [fname "test/test-symbol-random-api.clj"
           fns (gen/all-symbol-random-api-functions gen/op-names)
           _ (gen/write-to-file [(first fns) (second fns)]
                                (gen/symbol-api-gen-ns true)
-                               fname)
-          good-contents (slurp "test/good-test-symbol-random-api.clj")
-          contents (slurp fname)]
-      (is (= good-contents contents))))
+                               fname)]
+      (is (= "exponential"
+             (file-function-name "test/good-test-symbol-random-api.clj")
+             (file-function-name fname)))))
 
 
  (testing "symbol"
@@ -364,20 +371,20 @@
           fns (gen/all-ndarray-api-functions gen/op-names)
           _ (gen/write-to-file [(first fns) (second fns)]
                                (gen/ndarray-api-gen-ns false)
-                               fname)
-          good-contents (slurp "test/good-test-ndarray-api.clj")
-          contents (slurp fname)]
-      (is (= good-contents contents))))
+                               fname)]
+      (is (= "activation"
+             (file-function-name "test/good-test-ndarray-api.clj")
+             (file-function-name fname)))))
 
   (testing "ndarray-random-api"
     (let [fname "test/test-ndarray-random-api.clj"
           fns (gen/all-ndarray-random-api-functions gen/op-names)
           _ (gen/write-to-file [(first fns) (second fns)]
                                (gen/ndarray-api-gen-ns true)
-                               fname)
-          good-contents (slurp "test/good-test-ndarray-random-api.clj")
-          contents (slurp fname)]
-      (is (= good-contents contents))))
+                               fname)]
+      (is (= "exponential"
+             (file-function-name "test/good-test-ndarray-random-api.clj")
+             (file-function-name fname)))))
 
   (testing "ndarray"
     (let [fname "test/test-ndarray.clj"