|
31 | 31 | (first (str/split-lines out)) |
32 | 32 | (throw (Exception. (str "Failed to find glj bin: " err)))))) |
33 | 33 |
|
| 34 | +(deftest help-flag-test |
| 35 | + (test-that |
| 36 | + "glj --help flag works correctly" |
| 37 | + (let [[out err] (run-cli-cmd glj "--help")] |
| 38 | + (is (re-matches |
| 39 | + #"(?s).*Glojure v\d+\.\d+\.\d+.*Usage: glj.*Options:.*-e.*-h.*--help.*--version.*Examples:.*" |
| 40 | + out) |
| 41 | + "Command should output help information") |
| 42 | + (is (re-matches |
| 43 | + #"(?s).*Environment Variables:.*GLJPATH.*PATH of directories for \.glj libraries.*" |
| 44 | + out) |
| 45 | + "Help should document GLJPATH environment variable") |
| 46 | + (is (empty? err) "Command should not return an error")))) |
| 47 | + |
34 | 48 | (deftest e-flag-test |
35 | 49 | (test-that |
36 | 50 | "glj -e flag works correctly" |
|
46 | 60 | "Command should output version") |
47 | 61 | (is (empty? err) "Command should not return an error")))) |
48 | 62 |
|
49 | | -(deftest glojure-version-test |
50 | | - (test-that |
51 | | - "*glojure-version* should be set correctly" |
52 | | - (let [[out err] (run-cli-cmd glj "-e" "*glojure-version*")] |
53 | | - (is (= out "{:major 0, :minor 3, :incremental 0, :qualifier nil}\n") |
54 | | - "Version should match expected format") |
55 | | - (is (empty? err) "Command should not return an error")))) |
56 | | - |
57 | | -(deftest help-flag-test |
| 63 | +(deftest gljpath-test |
58 | 64 | (test-that |
59 | | - "glj --help flag works correctly" |
60 | | - (let [[out err] (run-cli-cmd glj "--help")] |
61 | | - (is (re-matches |
62 | | - #"(?s).*Glojure v0\.3\.0.*Usage: glj.*Options:.*-e.*-h.*--help.*--version.*Examples:.*" |
63 | | - out) |
64 | | - "Command should output help information") |
65 | | - (is (empty? err) "Command should not return an error")))) |
66 | | - |
67 | | -(deftest short-help-flag-test |
68 | | - (test-that |
69 | | - "glj -h flag works correctly" |
70 | | - (let [[out err] (run-cli-cmd glj "-h")] |
71 | | - (is (re-matches |
72 | | - #"(?s).*Glojure v0\.3\.0.*Usage: glj.*Options:.*-e.*-h.*--help.*--version.*Examples:.*" |
73 | | - out) |
74 | | - "Command should output help information") |
| 65 | + "GLJPATH can load libraries from specified directories" |
| 66 | + (let [lib1-dir (str (os.Getenv "PWD") "/test_gljpath_priority1") |
| 67 | + lib2-dir (str (os.Getenv "PWD") "/test_gljpath_priority2") |
| 68 | + lib1-file (str lib1-dir "/conflict.glj") |
| 69 | + lib2-file (str lib2-dir "/conflict.glj") |
| 70 | + test-script (str (os.Getenv "PWD") "/test_gljpath_priority_script.glj") |
| 71 | + ;; Create conflicting libraries with same name but different content |
| 72 | + _ (do |
| 73 | + (os.MkdirAll lib1-dir 0755) |
| 74 | + (os.MkdirAll lib2-dir 0755) |
| 75 | + (os.WriteFile lib1-file |
| 76 | + (str "(ns conflict)\n(defn version [] \"version 1\")") |
| 77 | + 0644) |
| 78 | + (os.WriteFile lib2-file |
| 79 | + (str "(ns conflict)\n(defn version [] \"version 2\")") |
| 80 | + 0644) |
| 81 | + (os.WriteFile test-script |
| 82 | + (str "(ns main)\n(use 'conflict)\n(println (version))") |
| 83 | + 0644)) |
| 84 | + ;; Test that first directory in GLJPATH takes precedence |
| 85 | + [out err] (run-cli-cmd "sh" "-c" |
| 86 | + (str "GLJPATH=" lib1-dir ":" lib2-dir " " glj " " test-script)) |
| 87 | + ;; Cleanup |
| 88 | + _ (do |
| 89 | + (os.RemoveAll lib1-dir) |
| 90 | + (os.RemoveAll lib2-dir) |
| 91 | + (os.Remove test-script))] |
| 92 | + (is (= out "version 1\n") "First directory in GLJPATH should take precedence") |
75 | 93 | (is (empty? err) "Command should not return an error")))) |
76 | 94 |
|
77 | 95 | (run-tests) |
0 commit comments