├── .build
└── bb.edn
├── .carve
├── .carve_ignore
└── ignore
├── .circleci
├── config.yml
└── script
│ ├── deploy
│ ├── docker.clj
│ ├── gen_ci.clj
│ ├── graalvm_ssl
│ ├── lein
│ ├── performance
│ ├── publish_artifact.clj
│ ├── release
│ └── tools.deps
├── .cirrus.yml
├── .clj-kondo
├── babashka
│ ├── fs
│ │ └── config.edn
│ └── sci
│ │ ├── config.edn
│ │ └── sci
│ │ └── core.clj
├── config.edn
└── rewrite-clj
│ └── rewrite-clj
│ └── config.edn
├── .dir-locals.el
├── .dockerignore
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── pull_request_template.md
├── script
│ ├── deploy
│ └── docker
└── workflows
│ ├── build-windows.yml
│ └── build.yml
├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Dockerfile
├── Dockerfile.alpine
├── Dockerfile.ci
├── LICENSE
├── README.md
├── appveyor.yml
├── deps.edn
├── doc
├── build.md
├── cljdoc.edn
├── companies.md
├── dev.md
├── examples.md
├── fly_io
│ ├── Dockerfile
│ ├── README.md
│ ├── example.clj
│ └── fly.toml
├── libraries.csv
├── libraries.md
├── news.md
├── nix.md
├── projects.md
└── surveys
│ └── 2020-11.md
├── examples
├── README.md
├── cprop-override.properties
├── cprop.clj
├── cprop.edn
├── db_who.clj
├── digitalocean-ping.clj
├── download-aliases.clj
├── fzf.clj
├── hsqldb_unused_vars.clj
├── htmx_todoapp.clj
├── http-server.clj
├── http_server_from_scratch.clj
├── httpkit_server.clj
├── image-viewer.clj
├── is_tty.clj
├── logger.clj
├── ls_jar.clj
├── memo.clj
├── mysql_cmdline.clj
├── normalize-keywords.clj
├── notes.clj
├── outdated.clj
├── pom_version_get.clj
├── pom_version_get_xml_zip.clj
├── pom_version_set.clj
├── portal.clj
├── process_builder.clj
├── pst.clj
├── random_doc.clj
├── sqlite.clj
├── torrent-viewer.clj
├── tree.clj
├── vim.clj
├── whatsapp_frequencies.clj
├── which.clj
├── wiki-translate.clj
└── xml-example.clj
├── feature-core-match
└── babashka
│ └── impl
│ └── match.clj
├── feature-csv
└── babashka
│ └── impl
│ └── csv.clj
├── feature-datascript
└── babashka
│ └── impl
│ └── datascript.clj
├── feature-hiccup
└── babashka
│ └── impl
│ └── hiccup.clj
├── feature-httpkit-client
└── babashka
│ └── impl
│ └── httpkit_client.clj
├── feature-httpkit-server
└── babashka
│ └── impl
│ └── httpkit_server.clj
├── feature-jdbc
└── babashka
│ └── impl
│ └── jdbc.clj
├── feature-lanterna
└── babashka
│ └── impl
│ └── lanterna.clj
├── feature-logging
└── babashka
│ └── impl
│ └── logging.clj
├── feature-priority-map
└── babashka
│ └── impl
│ └── priority_map.clj
├── feature-rrb-vector
└── babashka
│ └── impl
│ └── rrb_vector.clj
├── feature-selmer
└── babashka
│ └── impl
│ └── selmer.clj
├── feature-spec-alpha
└── babashka
│ └── impl
│ └── spec.clj
├── feature-test-check
└── babashka
│ └── impl
│ └── clojure
│ └── test
│ └── check.clj
├── feature-transit
└── babashka
│ └── impl
│ └── transit.clj
├── feature-xml
└── babashka
│ └── impl
│ └── xml.clj
├── feature-yaml
└── babashka
│ └── impl
│ ├── ordered.clj
│ └── yaml.clj
├── impl-java
├── .dir-locals.el
├── bb.edn
├── build.clj
├── build
│ └── reify2.clj
├── deps.edn
├── src-java
│ └── babashka
│ │ └── impl
│ │ └── URLClassLoader.java
└── src
│ └── babashka
│ └── impl
│ ├── reify2.clj
│ └── reify2
│ └── interfaces.clj
├── install
├── logo
├── babashka-blue-yellow.png
├── babashka-blue-yellow.svg
├── babashka.png
├── babashka.svg
├── babashka_red.png
├── babashka_red.svg
├── badge.svg
├── built-in-badge.svg
├── icon.png
└── icon.svg
├── project.clj
├── resources
├── BABASHKA_RELEASED_VERSION
├── BABASHKA_VERSION
├── CutOffCoreServicesDependencies.java
├── CutOffSunAwtWwwContentAudioAiff.java
├── META-INF
│ ├── babashka
│ │ └── deps.edn
│ └── native-image
│ │ └── babashka
│ │ └── babashka
│ │ ├── native-image.properties
│ │ └── proxy-config.json
├── UrlClassLoaderSubstitutions.java
└── src
│ └── babashka
│ └── clojure
│ ├── repl
│ └── deps.clj
│ └── spec
│ ├── alpha.clj
│ ├── gen
│ └── alpha.clj
│ └── test
│ └── alpha.clj
├── script
├── add_libtest.clj
├── babashka
│ └── release_artifact.clj
├── built_in.clj
├── bump_graal_version.clj
├── bump_version.clj
├── changelog.clj
├── check_glibc.sh
├── cljdoc-preview
├── compile
├── compile.bat
├── install-clojure
├── install-graalvm
├── install-leiningen
├── lib_tests
│ ├── bb_edn_from_deps.clj
│ ├── run_all_libtests
│ └── run_all_libtests.bat
├── postgresql_test
├── reflection.clj
├── run_lib_tests
├── run_lib_tests.bat
├── setup-musl
├── test
├── test.bat
├── uberjar
└── uberjar.bat
├── src
├── aaaa_this_has_to_be_first
│ └── because_patches.clj
└── babashka
│ ├── deps.clj
│ ├── dude.clj
│ ├── impl
│ ├── bencode.clj
│ ├── cheshire.clj
│ ├── classes.clj
│ ├── classpath.clj
│ ├── cli.clj
│ ├── clojure
│ │ ├── core.clj
│ │ ├── core
│ │ │ ├── async.clj
│ │ │ └── server.clj
│ │ ├── data.clj
│ │ ├── instant.clj
│ │ ├── java
│ │ │ ├── browse.clj
│ │ │ ├── io.clj
│ │ │ ├── process.clj
│ │ │ └── shell.clj
│ │ ├── main.clj
│ │ ├── math.clj
│ │ ├── reflect.clj
│ │ ├── spec
│ │ │ ├── alpha.clj
│ │ │ ├── gen
│ │ │ │ └── alpha.clj
│ │ │ └── test
│ │ │ │ └── alpha.clj
│ │ ├── stacktrace.clj
│ │ ├── test.clj
│ │ ├── tools
│ │ │ ├── reader.clj
│ │ │ └── reader_types.clj
│ │ └── zip.clj
│ ├── common.clj
│ ├── core.clj
│ ├── curl.clj
│ ├── data.clj
│ ├── datafy.clj
│ ├── deps.clj
│ ├── edamame.clj
│ ├── error_handler.clj
│ ├── exceptions.clj
│ ├── features.clj
│ ├── fs.clj
│ ├── http_client.clj
│ ├── markdown.clj
│ ├── nrepl_server.clj
│ ├── patches
│ │ └── datafy.clj
│ ├── pipe_signal_handler.clj
│ ├── pods.clj
│ ├── pprint.clj
│ ├── print_deps.clj
│ ├── process.clj
│ ├── protocols.clj
│ ├── proxy.clj
│ ├── reify.clj
│ ├── repl.clj
│ ├── rewrite_clj.clj
│ ├── sci.clj
│ ├── server.clj
│ ├── sigint_handler.clj
│ ├── socket_repl.clj
│ ├── tasks.clj
│ ├── test.clj
│ ├── tools
│ │ └── cli.clj
│ └── uberscript.clj
│ ├── main.clj
│ └── wait.clj
├── test-resources
├── adjacent_bb
│ ├── bb.edn
│ └── medley.bb
├── babashka
│ ├── assert_expr.clj
│ ├── config_property.clj
│ ├── embedded_pg_tests.clj
│ ├── empty.clj
│ ├── exec_test.clj
│ ├── file_location1.clj
│ ├── file_location2.clj
│ ├── file_location_preloads.clj
│ ├── file_property1.clj
│ ├── file_property2.clj
│ ├── glob.clj
│ ├── init_caller.clj
│ ├── init_test.clj
│ ├── src_for_classpath_test
│ │ ├── call_init_main.clj
│ │ ├── data_readers.clj
│ │ ├── data_readers.cljc
│ │ ├── env
│ │ │ └── env_ns.clj
│ │ ├── foo.jar
│ │ ├── my
│ │ │ ├── impl.cljc
│ │ │ ├── main.clj
│ │ │ └── main2.clj
│ │ ├── my_script.bb
│ │ ├── ns_with_error.clj
│ │ └── reader.clj
│ ├── statsd.clj
│ ├── test_report.clj
│ ├── transit.clj
│ ├── uberjar
│ │ ├── deps.edn
│ │ └── src
│ │ │ └── my
│ │ │ ├── impl.clj
│ │ │ ├── impl2.clj
│ │ │ ├── main_main.clj
│ │ │ └── main_pod.clj
│ ├── uberscript
│ │ └── src
│ │ │ └── my
│ │ │ ├── impl1.clj
│ │ │ ├── impl2.cljc
│ │ │ ├── impl3.cljc
│ │ │ ├── main.clj
│ │ │ ├── main_pod.clj
│ │ │ └── other_ns_with_pod.clj
│ └── version.clj
├── bb-edn
│ └── user.clj
├── bb_in_root_script_in_other_dir
│ ├── bb.edn
│ └── dir
│ │ └── script.clj
├── break_iterator_test.clj
├── bytechannel_and_related_classes.bb
├── certificate.crt
├── clojure-dir-test
│ └── deps.edn
├── coffee-tasks.edn
├── divide_by_zero.jar
├── domain_sockets.bb
├── extended-attributes.txt
├── java.security
├── lib_tests
│ ├── aero
│ │ ├── config.edn
│ │ ├── core_test.cljc
│ │ ├── default-reader.edn
│ │ ├── empty-config.edn
│ │ ├── hosts.edn
│ │ ├── included.edn
│ │ ├── includes.edn
│ │ ├── long_prop.edn
│ │ ├── lumo_test.cljs
│ │ ├── sub
│ │ │ └── includes.edn
│ │ └── valid.edn
│ ├── again
│ │ └── core_test.clj
│ ├── arrangement
│ │ └── core_test.cljc
│ ├── babashka
│ │ ├── curl_test.clj
│ │ ├── run_all_libtests.clj
│ │ └── statecharts_test.clj
│ ├── bb-tested-libs.edn
│ ├── better_cond
│ │ └── core_test.cljc
│ ├── bond
│ │ ├── assertions_test.clj
│ │ ├── james_test.clj
│ │ ├── target_data.clj
│ │ └── test
│ │ │ ├── assertions.cljc
│ │ │ ├── james.cljc
│ │ │ └── target.cljc
│ ├── borkdude
│ │ ├── deps
│ │ │ └── smoke_test.clj
│ │ └── rewrite_edn_test.cljc
│ ├── camel_snake_kebab
│ │ ├── core_test.cljc
│ │ ├── extras_test.cljc
│ │ ├── internals
│ │ │ └── string_separator_test.cljc
│ │ └── test_runner.cljs
│ ├── cheshire
│ │ └── test
│ │ │ ├── core.clj
│ │ │ ├── multi.json
│ │ │ └── pass1.json
│ ├── clarktown
│ │ ├── core.md
│ │ ├── core_result.html
│ │ ├── core_test.clj
│ │ └── parsers
│ │ │ ├── bold_test.clj
│ │ │ ├── code_block.md
│ │ │ ├── code_block_no_language.md
│ │ │ ├── code_block_no_language_result.html
│ │ │ ├── code_block_result.html
│ │ │ ├── code_block_test.clj
│ │ │ ├── empty_block_test.clj
│ │ │ ├── heading_block_test.clj
│ │ │ ├── horizontal_line_block_test.clj
│ │ │ ├── inline_code_test.clj
│ │ │ ├── italic_test.clj
│ │ │ ├── link_and_image_test.clj
│ │ │ ├── quote_block_test.clj
│ │ │ └── strikethrough_test.clj
│ ├── cli_matic
│ │ ├── core_test.cljc
│ │ ├── edn_simple.edn
│ │ ├── help_gen_test.cljc
│ │ ├── json_simple.json
│ │ ├── presets_test.cljc
│ │ ├── three_lines.txt
│ │ ├── utils_candidates_test.cljc
│ │ ├── utils_convert_config_test.cljc
│ │ ├── utils_test.cljc
│ │ ├── utils_v2_test.cljc
│ │ ├── yaml_full.yaml
│ │ └── yaml_simple.yaml
│ ├── clj_commons
│ │ └── digest_test.clj
│ ├── clj_http
│ │ └── lite
│ │ │ ├── client_test.clj
│ │ │ └── test_runner.clj
│ ├── clj_stacktrace
│ │ ├── core_test.clj
│ │ └── repl_test.clj
│ ├── clj_yaml
│ │ └── core_test.clj
│ ├── cljc
│ │ └── java_time_test.cljc
│ ├── clojure
│ │ ├── algo
│ │ │ └── test_monads.clj
│ │ ├── data
│ │ │ ├── csv_test.clj
│ │ │ ├── generators_test.clj
│ │ │ ├── json_compat_0_1_test.clj
│ │ │ ├── json_gen_test.clj
│ │ │ ├── json_test.clj
│ │ │ ├── json_test_suite_test.clj
│ │ │ └── zip_test.clj
│ │ ├── math
│ │ │ ├── test_combinatorics.cljc
│ │ │ └── test_numeric_tower.clj
│ │ ├── term
│ │ │ └── colors_test.clj
│ │ ├── test_clojure
│ │ │ ├── instr.clj
│ │ │ ├── multi_spec.clj
│ │ │ └── spec.clj
│ │ └── tools
│ │ │ ├── gitlibs
│ │ │ └── test_impl.clj
│ │ │ └── test_gitlibs.clj
│ ├── clojure_csv
│ │ └── test
│ │ │ ├── core.clj
│ │ │ └── utils.clj
│ ├── com
│ │ ├── rpl
│ │ │ └── specter
│ │ │ │ ├── cljs_test_helpers.clj
│ │ │ │ ├── cljs_test_runner.cljs
│ │ │ │ ├── core_test.cljc
│ │ │ │ ├── test_helpers.clj
│ │ │ │ └── zipper_test.cljc
│ │ ├── stuartsierra
│ │ │ ├── component_test.clj
│ │ │ └── dependency_test.clj
│ │ └── wsscode
│ │ │ └── misc
│ │ │ ├── coll_test.cljc
│ │ │ ├── macros_test.clj
│ │ │ ├── math_test.cljc
│ │ │ ├── refs_test.cljc
│ │ │ └── uuid_test.cljc
│ ├── comb
│ │ └── test
│ │ │ └── template.clj
│ ├── contajners
│ │ ├── core_test.clj
│ │ └── impl_test.clj
│ ├── core_match
│ │ └── core_tests.clj
│ ├── cprop
│ │ └── smoke_test.clj
│ ├── crispin
│ │ ├── core_test.clj
│ │ ├── crispin-test-cfg.edn
│ │ └── crispin-test-custom-cfg.edn
│ ├── datalog
│ │ ├── parser
│ │ │ ├── impl_test.cljc
│ │ │ ├── pull_test.cljc
│ │ │ └── test
│ │ │ │ └── util.cljc
│ │ ├── parser_test.cljc
│ │ └── unparser_test.clj
│ ├── docopt
│ │ ├── core_test.clj
│ │ └── extra_testcases.docopt
│ ├── doric
│ │ └── test
│ │ │ ├── core.clj
│ │ │ ├── doctest.clj
│ │ │ └── readme.clj
│ ├── edn_query_language
│ │ └── core_test.cljc
│ ├── environ
│ │ ├── core_test.cljc
│ │ └── test
│ │ │ └── runner.cljs
│ ├── exoscale
│ │ ├── coax_cljs_test_runner.cljs
│ │ ├── coax_test.cljc
│ │ └── lingo
│ │ │ └── test
│ │ │ └── core_test.cljc
│ ├── expectations
│ │ └── clojure
│ │ │ └── test_test.clj
│ ├── expound
│ │ ├── alpha_test.cljc
│ │ ├── paths_test.cljc
│ │ ├── print_length_test.cljc
│ │ ├── printer_test.cljc
│ │ ├── problems_test.cljc
│ │ ├── spec_gen.cljc
│ │ ├── specs_test.cljc
│ │ ├── spell_spec_test.cljc
│ │ ├── test_runner.cljs
│ │ └── test_utils.cljc
│ ├── failjure
│ │ ├── runner.cljs
│ │ └── test_core.cljc
│ ├── gaka
│ │ └── core_test.clj
│ ├── hasch
│ │ └── test.cljc
│ ├── hato
│ │ └── client_test.clj
│ ├── helins
│ │ └── binf
│ │ │ ├── test.cljc
│ │ │ └── test
│ │ │ ├── base64.cljc
│ │ │ ├── buffer.cljc
│ │ │ ├── cabi.cljc
│ │ │ ├── endian.cljc
│ │ │ ├── float.cljc
│ │ │ ├── int.cljc
│ │ │ ├── int64.cljc
│ │ │ ├── leb128.cljc
│ │ │ ├── native.clj
│ │ │ └── string.cljc
│ ├── hiccup
│ │ └── core_test.clj
│ ├── hiccup2
│ │ └── core_test.clj
│ ├── honey
│ │ ├── sql
│ │ │ ├── helpers_test.cljc
│ │ │ └── postgres_test.cljc
│ │ └── sql_test.cljc
│ ├── honeysql
│ │ ├── core_test.cljc
│ │ └── format_test.cljc
│ ├── httpkit
│ │ └── client_test.clj
│ ├── hugsql
│ │ ├── babashka_test.clj
│ │ └── characters.sql
│ ├── io
│ │ └── aviso
│ │ │ ├── binary_test.clj
│ │ │ └── exception_test.clj
│ ├── jasentaa
│ │ ├── collections_test.cljc
│ │ ├── parser
│ │ │ ├── basic_test.cljc
│ │ │ └── combinators_test.cljc
│ │ ├── position_test.cljc
│ │ ├── runner.cljs
│ │ ├── test_helpers.cljc
│ │ ├── worked_example_1.cljc
│ │ └── worked_example_2.cljc
│ ├── java_http_clj
│ │ └── smoke_test.clj
│ ├── lambdaisland
│ │ ├── regal
│ │ │ ├── malli_test.cljc
│ │ │ ├── parse_test.cljc
│ │ │ ├── re2_test.clj
│ │ │ ├── spec_gen_test.clj
│ │ │ └── test_util.cljc
│ │ └── regal_test.cljc
│ ├── loom
│ │ └── test
│ │ │ ├── alg.cljc
│ │ │ ├── alg_generic.cljc
│ │ │ ├── attr.cljc
│ │ │ ├── compliance_tester.cljc
│ │ │ ├── derived.cljc
│ │ │ ├── flow.cljc
│ │ │ ├── graph.cljc
│ │ │ ├── label.cljc
│ │ │ ├── network_simplex.cljc
│ │ │ └── runner.cljs
│ ├── markdown
│ │ ├── md_test.cljc
│ │ ├── nbb_runner.cljs
│ │ └── runner.cljs
│ ├── me
│ │ └── raynes
│ │ │ ├── core_test.clj
│ │ │ ├── mock_midje.clj
│ │ │ └── testfiles
│ │ │ ├── bar
│ │ │ ├── bbb.bz2
│ │ │ ├── foo
│ │ │ ├── ggg.gz
│ │ │ ├── ggg.tar
│ │ │ ├── ggg.zip
│ │ │ ├── xxx.xz
│ │ │ ├── zip-slip.tar
│ │ │ └── zip-slip.zip
│ ├── medley
│ │ ├── core_test.cljc
│ │ └── test_runner.cljs
│ ├── meta_merge
│ │ ├── core_test.cljc
│ │ └── test_runner.cljs
│ ├── minimallist
│ │ ├── core_test.cljc
│ │ ├── generator_test.cljc
│ │ └── util_test.cljc
│ ├── missing
│ │ └── test
│ │ │ ├── assertions_test.cljc
│ │ │ └── old_methods.cljc
│ ├── msgpack
│ │ ├── core_check.clj
│ │ └── core_test.clj
│ ├── multigrep
│ │ ├── core_test.clj
│ │ └── haiku.txt
│ ├── omniconf
│ │ └── core_test.clj
│ ├── orchestra
│ │ ├── core_test.cljc
│ │ ├── expound_test.cljc
│ │ ├── make_fns.cljc
│ │ ├── many_fns.cljc
│ │ └── reload_test.cljc
│ ├── portal
│ │ ├── bench.cljc
│ │ ├── e2e.clj
│ │ ├── jvm_test.clj
│ │ ├── runtime
│ │ │ ├── cson_test.cljc
│ │ │ └── fs_test.cljc
│ │ ├── test_planck.cljs
│ │ ├── test_runner.clj
│ │ └── test_runner.cljs
│ ├── progrock
│ │ └── core_test.clj
│ ├── reifyhealth
│ │ └── specmonstah
│ │ │ ├── core_test.cljc
│ │ │ ├── spec_gen_test.cljc
│ │ │ └── test_data.cljc
│ ├── rewrite_clj
│ │ ├── node
│ │ │ └── coercer_test.cljc
│ │ ├── node_test.cljc
│ │ ├── paredit_test.cljc
│ │ ├── parser_test.cljc
│ │ ├── zip
│ │ │ ├── subedit_test.cljc
│ │ │ └── test_helper.cljc
│ │ └── zip_test.cljc
│ ├── ruuter
│ │ └── core_test.cljc
│ ├── selmer
│ │ ├── benchmark.clj
│ │ ├── core_test.clj
│ │ └── our_test.clj
│ ├── slingshot
│ │ ├── slingshot_test.clj
│ │ ├── support_test.clj
│ │ └── test_test.clj
│ ├── spartan
│ │ └── spec_test.clj
│ ├── swirrl
│ │ └── dogstatsd_test.clj
│ ├── table
│ │ ├── core_test.clj
│ │ └── width_test.clj
│ ├── templates
│ │ ├── any.html
│ │ ├── base-custom.html
│ │ ├── base.html
│ │ ├── child-custom.html
│ │ ├── child.html
│ │ ├── elif.html
│ │ ├── if.html
│ │ ├── ifequal.html
│ │ ├── include.html
│ │ ├── inheritance
│ │ │ ├── another-parent.html
│ │ │ ├── base.html
│ │ │ ├── blocks.html
│ │ │ ├── child-a.html
│ │ │ ├── child-b.html
│ │ │ ├── child-c.html
│ │ │ ├── child-d.html
│ │ │ ├── child.html
│ │ │ ├── foo.html
│ │ │ ├── home.html
│ │ │ ├── include-head.html
│ │ │ ├── include-in-block.html
│ │ │ ├── include-snippet.html
│ │ │ ├── include
│ │ │ │ ├── another-grandparent.html
│ │ │ │ ├── another-parent.html
│ │ │ │ ├── child.html
│ │ │ │ ├── grandparent.html
│ │ │ │ ├── head.html
│ │ │ │ ├── parent.html
│ │ │ │ └── snippet.html
│ │ │ ├── inherit-a.html
│ │ │ ├── inherit-b.html
│ │ │ ├── inherit-c.html
│ │ │ ├── parent.html
│ │ │ ├── register.html
│ │ │ ├── super-a.html
│ │ │ ├── super-b.html
│ │ │ └── super-c.html
│ │ ├── my-include-child.html
│ │ ├── my-include.html
│ │ ├── nested-for.html
│ │ ├── no_tag.html
│ │ ├── numerics.html
│ │ ├── raw.html
│ │ ├── safe.html
│ │ ├── snippet.html
│ │ ├── tags-test.html
│ │ ├── validation-test.html
│ │ └── verbatim.html
│ ├── test_check
│ │ └── smoke_test.clj
│ ├── testdoc
│ │ ├── core_test.clj
│ │ └── style
│ │ │ ├── code_first_test.clj
│ │ │ └── repl_test.clj
│ ├── vault
│ │ ├── client
│ │ │ ├── http_test.clj
│ │ │ ├── mock_test.clj
│ │ │ └── secret-fixture-logical.edn
│ │ ├── env_test.clj
│ │ ├── lease_test.clj
│ │ └── secrets
│ │ │ ├── kvv1_test.clj
│ │ │ ├── kvv2_test.clj
│ │ │ └── secret-fixture-kvv2.edn
│ └── version_clj
│ │ ├── compare_test.cljc
│ │ ├── core_test.cljc
│ │ ├── split_test.cljc
│ │ └── via_use_test.clj
├── line_number_test_test.clj
├── local-dep
│ ├── deps.edn
│ └── src
│ │ └── local_dep.clj
├── pod
├── pod.clj
├── pod_tests
│ ├── bootleg.clj
│ └── local.clj
├── pom.xml
├── posix-file-attributes.txt
├── proxy_inputstream_outputstream.bb
├── script_with_overlapping_opts.clj
├── symlink-adjacent-bb
├── task_scripts
│ └── tasks.clj
├── task_test_scripts
│ └── task_test.clj
├── test.csv
├── text_normalizer_test.clj
└── unicode_test.clj
└── test
└── babashka
├── agent_test.clj
├── async_test.clj
├── bb_edn_test.clj
├── cheshire_test.clj
├── classes_test.clj
├── classpath_test.clj
├── crypto_test.clj
├── datafy_test.clj
├── deps_test.clj
├── error_test.clj
├── exec_test.clj
├── file_var_test.clj
├── http_connection_test.clj
├── impl
├── clojure
│ ├── java
│ │ ├── browse_test.clj
│ │ ├── io_test.clj
│ │ └── shell_test.clj
│ └── main_test.clj
├── nrepl_server_test.clj
├── repl_test.clj
├── server_test.clj
├── socket_repl_test.clj
└── tasks_test.clj
├── interop_test.clj
├── java_net_http_test.clj
├── java_security_test.clj
├── java_time_test.clj
├── logging_test.clj
├── main_test.clj
├── namespace_test.clj
├── pod_test.clj
├── postgresql_test.clj
├── pprint_test.clj
├── print_deps_test.clj
├── profile.clj
├── protocols_test.clj
├── proxy_test.clj
├── reify_test.clj
├── sci_test.clj
├── scripts
├── System.bb
├── check_var_names.bb
├── csv.bb
├── divide_by_zero.bb
├── download_and_extract_zip.bb
├── error.bb
├── file_var.bb
├── file_var_classpath.bb
├── interrupt_handler.bb
├── kill_child_processes.bb
├── loaded_by_file_var.bb
├── simple_file_var.bb
├── socket_server.bb
└── tools.cli.bb
├── shutdown_hook_test.clj
├── test_test.clj
├── test_utils.clj
├── transit_test.clj
├── uberjar_test.clj
├── uberscript_test.clj
├── udp_test.clj
├── xml_test.clj
└── yaml_test.clj
/.build/bb.edn:
--------------------------------------------------------------------------------
1 | {:paths ["script"]
2 | :deps {borkdude/gh-release-artifact
3 | #_{:local/root "../gh-release-artifact"}
4 | {:git/url "https://github.com/borkdude/gh-release-artifact"
5 | :git/sha "4a9a74f0e50e897c45df8cc70684360eb30fce80"}}
6 | :tasks {release-artifact babashka.release-artifact/release}}
7 |
--------------------------------------------------------------------------------
/.carve/.carve_ignore:
--------------------------------------------------------------------------------
1 | babashka.impl.clojure.stacktrace/root-cause
2 | babashka.impl.classes/generate-reflection-file
3 | babashka.main/-main
4 |
--------------------------------------------------------------------------------
/.carve/ignore:
--------------------------------------------------------------------------------
1 | babashka.impl.pipe-signal-handler/pipe-signal-received?
2 | babashka.impl.pipe-signal-handler/handle-pipe!
3 | babashka.impl.sigint-handler/handle-sigint!
4 | babashka.impl.classes/generate-reflection-file
5 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Clojure CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-clojure/ for more details
4 | #
5 | version: 2.1
6 |
7 | # this allows you to use CircleCI's dynamic configuration feature
8 | setup: true
9 |
10 | # the continuation orb is required in order to use dynamic configuration
11 | orbs:
12 | continuation: circleci/continuation@0.1.2
13 |
14 | # our defined job, and its steps
15 | jobs:
16 | setup:
17 | docker:
18 | - image: cimg/clojure:1.11.1
19 | steps:
20 | - checkout
21 | - run:
22 | name: Bootstrap Babashka
23 | command: |
24 | curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
25 | sudo bash install --dir /tmp
26 | - run:
27 | name: Rename bb binary
28 | command: mv /tmp/bb /tmp/bbb
29 | - run:
30 | name: Generate config
31 | command: |
32 | /tmp/bbb .circleci/script/gen_ci.clj > generated_config.yml
33 | - continuation/continue:
34 | configuration_path: generated_config.yml
35 |
36 | # our single workflow, that triggers the setup job defined above
37 | workflows:
38 | setup:
39 | jobs:
40 | - setup
41 |
--------------------------------------------------------------------------------
/.circleci/script/deploy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]
4 | then
5 | lein deploy clojars
6 | fi
7 |
8 | exit 0;
9 |
--------------------------------------------------------------------------------
/.circleci/script/graalvm_ssl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -eo pipefail
4 |
5 | mkdir -p ~/.babashka/lib/security
6 |
7 | echo "GRAAL: $GRAALVM_HOME"
8 | # Mac:
9 | cp $GRAALVM_HOME/jre/lib/libsunec.dylib ~/.babashka/lib || true
10 | # Linux:
11 | cp $GRAALVM_HOME/jre/lib/amd64/libsunec.so ~/.babashka/lib || true
12 |
13 | cp $GRAALVM_HOME/jre/lib/security/cacerts ~/.babashka/lib/security
14 |
--------------------------------------------------------------------------------
/.circleci/script/lein:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo '{:a 1}' | lein bb '(:a *in*)'
4 |
--------------------------------------------------------------------------------
/.circleci/script/performance:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | err=0
4 | function _trap_error() {
5 | local exit_code="$1"
6 | if [ "$exit_code" -ne 2 ] && [ "$exit_code" -ne 3 ]; then
7 | echo "EXIT CODE :( $exit_code"
8 | (( err |= "$exit_code" ))
9 | fi
10 | }
11 |
12 | trap '_trap_error $?' ERR
13 | trap 'exit $err' SIGINT SIGTERM
14 |
15 |
16 | rm -rf performance.txt
17 | echo -e "==== Build initial cache" | tee -a performance.txt
18 | cp="$(clojure -R:cljs -Spath)"
19 | read -r -d '' config <<'EOF' || true
20 | {:linters
21 | {:not-a-function
22 | {:skip-args [clojure.pprint/defdirectives
23 | cljs.pprint/defdirectives
24 | clojure.data.json/codepoint-case]}}}
25 | EOF
26 |
27 | (time ./clj-kondo --lint "$cp" --cache --config "$config") 2>&1 | tee -a performance.txt
28 |
29 | echo -e "\n==== Lint a single file (emulate in-editor usage)" | tee -a performance.txt
30 | (time ./clj-kondo --lint src/clj_kondo/impl/core.clj --cache) 2>&1 | tee -a performance.txt
31 |
32 | count=$(find . -name "*.clj*" -type f | wc -l | tr -d ' ')
33 | echo -e "\n==== Launch clj-kondo for each file in project ($count)" | tee -a performance.txt
34 | (time find src -name "*.clj*" -type f -exec ./clj-kondo --lint {} --cache \; ) 2>&1 | tee -a performance.txt
35 |
36 | exit "$err"
37 |
--------------------------------------------------------------------------------
/.circleci/script/release:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | rm -rf /tmp/release
4 | mkdir -p /tmp/release
5 | cp bb /tmp/release
6 |
7 | VERSION=$(cat resources/BABASHKA_VERSION)
8 |
9 |
10 |
11 | ## release binary as tar.gz archive
12 |
13 | arch=${BABASHKA_ARCH:-amd64}
14 |
15 | if [ "$BABASHKA_STATIC" = "true" ]; then
16 | arch="$arch-static"
17 | fi
18 |
19 | # because circle won't allow the same file to be saved/restored in the same workspace concurrently
20 | cp metabom.jar "/tmp/release/$BABASHKA_PLATFORM-$arch-metabom.jar"
21 |
22 | cd /tmp/release
23 | mkdir -p /tmp/bb_size
24 | ./bb '(spit "/tmp/bb_size/size" (.length (io/file "bb")))'
25 |
26 | archive="babashka-$VERSION-$BABASHKA_PLATFORM-$arch.tar.gz"
27 |
28 | tar zcvf "$archive" bb # bbk
29 |
30 | cd -
31 |
32 | if [ "$BABASHKA_RELEASE" = "true" ]; then
33 | ./bb --config .build/bb.edn --deps-root . release-artifact "/tmp/release/$archive"
34 | fi
35 |
36 | ## cleanup
37 |
38 | cd /tmp/release
39 | rm bb # bbk
40 |
--------------------------------------------------------------------------------
/.circleci/script/tools.deps:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | err=0
4 | function _trap_error() {
5 | local exit_code="$1"
6 | if [ "$exit_code" -ne 2 ] && [ "$exit_code" -ne 3 ]; then
7 | (( err |= "$exit_code" ))
8 | fi
9 | }
10 |
11 | trap '_trap_error $?' ERR
12 | trap 'exit $err' SIGINT SIGTERM
13 |
14 |
15 | # Run as local root dependency
16 | rm -rf /tmp/proj
17 | mkdir -p /tmp/proj
18 | cd /tmp/proj
19 | clojure -Sdeps '{:deps {clj-kondo {:local/root "/home/circleci/repo"}}}' \
20 | -m clj-kondo.main --lint /home/circleci/repo/src /home/circleci/repo/test
21 |
22 | # Run as git dependency
23 | rm -rf /tmp/proj
24 | mkdir -p /tmp/proj
25 | cd /tmp/proj
26 |
27 | github_user=${CIRCLE_PR_USERNAME:-borkdude}
28 | clojure -Sdeps "{:deps {clj-kondo {:git/url \"https://github.com/$github_user/clj-kondo\" :sha \"$CIRCLE_SHA1\"}}}" \
29 | -m clj-kondo.main --lint /home/circleci/repo/src /home/circleci/repo/test
30 |
31 | exit "$err"
32 |
--------------------------------------------------------------------------------
/.clj-kondo/babashka/fs/config.edn:
--------------------------------------------------------------------------------
1 | {:lint-as {babashka.fs/with-temp-dir clojure.core/let}}
2 |
--------------------------------------------------------------------------------
/.clj-kondo/babashka/sci/config.edn:
--------------------------------------------------------------------------------
1 | {:hooks {:macroexpand {sci.core/copy-ns sci.core/copy-ns}}}
2 |
--------------------------------------------------------------------------------
/.clj-kondo/babashka/sci/sci/core.clj:
--------------------------------------------------------------------------------
1 | (ns sci.core)
2 |
3 | (defmacro copy-ns
4 | ([ns-sym sci-ns]
5 | `(copy-ns ~ns-sym ~sci-ns nil))
6 | ([ns-sym sci-ns opts]
7 | `[(quote ~ns-sym)
8 | ~sci-ns
9 | (quote ~opts)]))
10 |
--------------------------------------------------------------------------------
/.clj-kondo/config.edn:
--------------------------------------------------------------------------------
1 | {:config-paths ["babashka/sci"]
2 | :lint-as {me.raynes.conch/let-programs clojure.core/let
3 | babashka.impl.File/gen-wrapper-fn clojure.core/def
4 | babashka.impl.Pattern/gen-wrapper-fn clojure.core/def
5 | babashka.impl.File/gen-wrapper-fn-2 clojure.core/def
6 | babashka.impl.Pattern/gen-wrapper-fn-2 clojure.core/def
7 | babashka.impl.Pattern/gen-constants clojure.core/declare}
8 | :linters {:unsorted-required-namespaces {:level :warning}}
9 | :hooks {:analyze-call {clojure.core/requiring-resolve hooks.mine/req-resolve}}}
10 |
--------------------------------------------------------------------------------
/.clj-kondo/rewrite-clj/rewrite-clj/config.edn:
--------------------------------------------------------------------------------
1 | {:lint-as
2 | {rewrite-clj.zip/subedit-> clojure.core/->
3 | rewrite-clj.zip/subedit->> clojure.core/->>
4 | rewrite-clj.zip/edit-> clojure.core/->
5 | rewrite-clj.zip/edit->> clojure.core/->>}}
6 |
--------------------------------------------------------------------------------
/.dir-locals.el:
--------------------------------------------------------------------------------
1 | ((clojure-mode
2 | (cider-clojure-cli-aliases . "test")))
3 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | .circleci/
2 | .git/
3 | .clj-kondo/
4 | .github/
5 | doc/
6 | examples/
7 | logo/
8 | test-resources/
9 | test/
10 | .gitignore
11 | .carve_ignore
12 | .gitmodules
13 | appveyor.yml
14 | CHANGES.md
15 | Dockerfile
16 | LICENSE
17 | README.md
18 | .cpcache/
19 | target/
20 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: borkdude # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | open_collective: babashka
5 | ko_fi: borkdude
6 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
7 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
8 | liberapay: # Replace with a single Liberapay username
9 | issuehunt: # Replace with a single IssueHunt username
10 | otechie: # Replace with a single Otechie username
11 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
12 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | [ To keep development of this project going, consider sponsoring. If you are
11 | already a sponsor, thank you! ]
12 |
13 | **version**
14 |
15 | [ Please specify which version of babashka you're using. You can find this with `babashka --version`. The documentation on the master branch may be ahead of the most released version. ]
16 |
17 | **platform**
18 |
19 | [ Please specify which platform you are using babashka on, so you can test a
20 | new binary when the issue is resolved. ]
21 |
22 | **problem**
23 |
24 | [ Please provide a short and to the point description of the problem ]
25 |
26 | **repro**
27 |
28 | [ Please provide a minimal working reproduction of the problem ]
29 |
30 | **expected behavior**
31 |
32 | [ What is the behavior you expected to see? Please provide a minimal working example ]
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | [ To keep development of this project going, consider sponsoring. If you are
11 | already a sponsor, thank you! ]
12 |
13 | **Is your feature request related to a problem? Please describe.**
14 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
15 |
16 | **Describe the solution you'd like**
17 | A clear and concise description of what you want to happen.
18 |
19 | **Describe alternatives you've considered**
20 | A clear and concise description of any alternative solutions or features you've considered.
21 |
22 | **Additional context**
23 | Add any other context or screenshots about the feature request here.
24 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Please answer the following questions and leave the below in as part of your PR.
2 |
3 | - [ ] I have read the [developer documentation](https://github.com/babashka/babashka/blob/master/doc/dev.md).
4 |
5 | - [ ] This PR corresponds to an [issue with a clear problem statement](https://github.com/babashka/babashka/blob/master/doc/dev.md#start-with-an-issue-before-writing-code).
6 |
7 | - [ ] This PR contains a [test](https://github.com/babashka/babashka/blob/master/doc/dev.md#tests) to prevent against future regressions
8 |
9 | - [ ] I have updated the [CHANGELOG.md](https://github.com/babashka/babashka/blob/master/CHANGELOG.md) file with a description of the addressed issue.
10 |
--------------------------------------------------------------------------------
/.github/script/deploy:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if [ -z "$GITHUB_HEAD_REF" ] && [ "${GITHUB_REF##*/}" = "master" ]
4 | then
5 | lein deploy clojars
6 | fi
7 |
8 | exit 0;
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /classes
3 | /checkouts
4 | profiles.clj
5 | pom.xml
6 | pom.xml.asc
7 | *.jar
8 | *.class
9 | /.lein-*
10 | /.nrepl-port
11 | .hgignore
12 | .hg/
13 | /bb
14 | .clj-kondo/.cache
15 | !java/src/babashka/impl/LockFix.class
16 | !test-resources/babashka/src_for_classpath_test/foo.jar
17 | !test-resources/pom.xml
18 | .cpcache
19 | *reflect-config.json
20 | /tmp
21 | /reports
22 | *.dylib
23 | *.log
24 | org_babashka*.h
25 | /babashka-0.1.4-SNAPSHOT-windows-amd64.zip
26 | /bb.exe
27 | /bb.exp
28 | /bb.lib
29 | /bb.pdb
30 | /bb.stripped.pdb
31 | /.calva
32 | !test-resources/divide_by_zero.jar
33 | .envrc
34 | .lsp
35 | bb.build_artifacts.txt
36 | target
37 | .nrepl-port
38 | .DS_Store
39 | .portal
40 | default.iprof
41 | scratch.clj
42 | bb-markdown
43 | .clj-kondo/metosin/malli-types-clj/config.edn
44 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "sci"]
2 | path = sci
3 | url = https://github.com/borkdude/sci
4 | branch = master
5 | [submodule "babashka.curl"]
6 | path = babashka.curl
7 | url = https://github.com/babashka/babashka.curl
8 | [submodule "babashka.nrepl"]
9 | path = babashka.nrepl
10 | url = https://github.com/babashka/babashka.nrepl
11 | [submodule "depstar"]
12 | path = depstar
13 | url = https://github.com/babashka/depstar
14 | [submodule "process"]
15 | path = process
16 | url = https://github.com/babashka/process
17 | [submodule "pods"]
18 | path = pods
19 | url = https://github.com/babashka/pods
20 | [submodule "deps.clj"]
21 | path = deps.clj
22 | url = https://github.com/borkdude/deps.clj
23 | [submodule "fs"]
24 | path = fs
25 | url = https://github.com/babashka/fs
26 | [submodule "babashka.core"]
27 | path = babashka.core
28 | url = https://github.com/babashka/babashka.core.git
29 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | See [doc/dev.md](doc/dev.md).
2 |
--------------------------------------------------------------------------------
/Dockerfile.ci:
--------------------------------------------------------------------------------
1 | FROM ubuntu:latest
2 |
3 | RUN apt-get update \
4 | && apt-get install -y curl \
5 | && rm -rf /var/lib/apt/lists/* \
6 | && mkdir -p /usr/local/bin
7 |
8 | ARG TARGETARCH
9 | ARG TARGETOS
10 |
11 | COPY metabom.jar /opt/babashka-metabom.jar
12 | COPY ${TARGETOS}/${TARGETARCH}/bb /usr/local/bin/bb
13 |
14 | RUN chmod +x /usr/local/bin/bb
15 |
16 | CMD ["bb"]
17 |
--------------------------------------------------------------------------------
/doc/cljdoc.edn:
--------------------------------------------------------------------------------
1 | {:cljdoc.doc/tree
2 | [["Readme" {:file "README.md"}]
3 | ["Developing Babashka" {:file "doc/dev.md"}]]}
4 |
--------------------------------------------------------------------------------
/doc/examples.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | This pages was moved [here](../examples/README.md).
4 |
--------------------------------------------------------------------------------
/doc/fly_io/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM babashka/babashka:0.8.2
2 |
3 | COPY example.clj /
4 |
5 | ENTRYPOINT bb /example.clj
6 |
--------------------------------------------------------------------------------
/doc/fly_io/README.md:
--------------------------------------------------------------------------------
1 | # Deploying a babashka app to fly.io
2 |
3 | [Fly.io](https://fly.io/) is a service that can run full stack apps with minimal
4 | configuration. If you like the ease of Heroku, you might like fly.io and perhaps
5 | even better! This document shows how to get a minimal babashka application up
6 | and running on `fly.io`.
7 |
8 | In `example.clj` we start an http-kit web server which spits out some HTML. You
9 | can run this locally by invoking `bb example.clj` from the command line.
10 |
11 | To get this site running on `fly.io`, you need to
12 | [install](https://fly.io/docs/getting-started/installing-flyctl/) and [log
13 | in](https://fly.io/docs/getting-started/log-in-to-fly/).
14 |
15 | Then run `flyctl launch` to create a new application. After making changes, you
16 | can re-deploy the site with `flyctl deploy`.
17 |
18 | That's it! See this
19 | [tweet](https://twitter.com/borkdude/status/1526175120825401344) for a demo.
20 |
--------------------------------------------------------------------------------
/doc/fly_io/example.clj:
--------------------------------------------------------------------------------
1 | (ns example
2 | (:require [hiccup2.core :refer [html]]
3 | [org.httpkit.server :refer [run-server]]))
4 |
5 | (def port (or (some-> (System/getenv "PORT")
6 | parse-long)
7 | 8092))
8 |
9 | (run-server
10 | (fn [_]
11 | {:body
12 | (str (html
13 | [:html
14 | [:body
15 | [:h1 "Hello world!"]
16 | [:p (str "This site is running with babashka v"
17 | (System/getProperty "babashka.version"))]]]))})
18 | {:port port})
19 |
20 | (println "Site running on port" port)
21 | @(promise)
22 |
--------------------------------------------------------------------------------
/doc/fly_io/fly.toml:
--------------------------------------------------------------------------------
1 | # fly.toml file generated for shy-sound-2847 on 2022-05-16T14:12:38+02:00
2 |
3 | app = "shy-sound-2847"
4 |
5 | kill_signal = "SIGINT"
6 | kill_timeout = 5
7 | processes = []
8 |
9 | [env]
10 | PORT = "8092"
11 |
12 | [experimental]
13 | allowed_public_ports = []
14 | auto_rollback = true
15 |
16 | [[services]]
17 | http_checks = []
18 | internal_port = 8092
19 | processes = ["app"]
20 | protocol = "tcp"
21 | script_checks = []
22 |
23 | [services.concurrency]
24 | hard_limit = 25
25 | soft_limit = 20
26 | type = "connections"
27 |
28 | [[services.ports]]
29 | force_https = true
30 | handlers = ["http"]
31 | port = 80
32 |
33 | [[services.ports]]
34 | handlers = ["tls", "http"]
35 | port = 443
36 |
37 | [[services.tcp_checks]]
38 | grace_period = "1s"
39 | interval = "15s"
40 | restart_limit = 0
41 | timeout = "2s"
42 |
--------------------------------------------------------------------------------
/doc/libraries.md:
--------------------------------------------------------------------------------
1 | Moved to [projects.md](projects.md).
2 |
--------------------------------------------------------------------------------
/examples/cprop-override.properties:
--------------------------------------------------------------------------------
1 | datomic.url=datomic:sql://?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic
2 |
3 | source.account.rabbit.host=localhost
4 |
5 | aws.access-key=super secret key
6 | aws.secret_key=super secret s3cr3t!!!
7 | aws.region=us-east-2
8 |
9 | io.http.pool.conn_timeout=42
10 | io.http.pool.max_per_route=42
11 |
12 | other_things=1,2,3,4,5,6,7
--------------------------------------------------------------------------------
/examples/cprop.edn:
--------------------------------------------------------------------------------
1 | #_
2 | {:datomic
3 | {:url "datomic:sql://?jdbc:postgresql://localhost:5432/datomic?user=datomic&password=datomic"}
4 | :source
5 | {:account
6 | {:rabbit
7 | {:host "127.0.0.1"
8 | :port 5672
9 | :vhost "/z-broker"
10 | :username "guest"
11 | :password "guest"}}}
12 | :answer 42}
13 |
14 | {:datomic {:url "CHANGE ME"}
15 | :aws {:access-key "AND ME"
16 | :secret-key "ME TOO"
17 | :region "FILL ME IN AS WELL"
18 | :visiblity-timeout-sec 30
19 | :max-conn 50
20 | :queue "cprop-dev"}
21 | :io {:http {:pool {:socket-timeout 600000
22 | :conn-timeout :I-SHOULD-BE-A-NUMBER
23 | :conn-req-timeout 600000
24 | :max-total 200
25 | :max-per-route :ME-ALSO}}}
26 | :other-things ["I am a vector and also like to place the substitute game"]}
27 |
--------------------------------------------------------------------------------
/examples/db_who.clj:
--------------------------------------------------------------------------------
1 | (ns db-who
2 | (:require [clojure.java.shell :as shell]
3 | [clojure.string :as str]
4 | [clojure.pprint :as pp]))
5 | (defn tsv->maps [tsv]
6 | (let [lines (str/split-lines tsv)
7 | [headers & rows] (map #(str/split % #"\t") lines)]
8 | (map #(zipmap headers %) rows)))
9 |
10 | (-> (shell/sh "mysql" "--column-names" "-e" "select user, program_name from sys.session;")
11 | :out tsv->maps pp/print-table)
12 |
--------------------------------------------------------------------------------
/examples/digitalocean-ping.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[babashka.curl :as curl]
4 | '[clojure.java.shell :as shell]
5 | '[clojure.string :as str])
6 |
7 | (def url "http://speedtest-ams2.digitalocean.com/")
8 |
9 | (def get-endpoints
10 | (let [{:keys [body]} (curl/get url)]
11 | (re-seq #"speedtest\-.+.digitalocean.com" body)))
12 |
13 | (defn get-average [result]
14 | (-> result
15 | str/split-lines
16 | last
17 | (str/split #"/")
18 | (get 4)))
19 |
20 | (def mac? (str/starts-with? (System/getProperty "os.name") "Mac"));; TODO: test on Windows
21 |
22 | (def timeout-arg (if mac? "-t3" "-w3"))
23 |
24 | (defn ping-result [endpoint]
25 | (let [{:keys [out]} (shell/sh "ping" "-c5" timeout-arg endpoint)
26 | msg (str endpoint " => " (get-average out) "ms")]
27 | (println msg)))
28 |
29 | (doseq [endpoint get-endpoints]
30 | (ping-result endpoint))
31 |
--------------------------------------------------------------------------------
/examples/download-aliases.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.edn :as edn]
4 | '[clojure.string :as str])
5 |
6 | (def edn (edn/read-string (slurp "deps.edn")))
7 |
8 | (def aliases (keys (:aliases edn)))
9 |
10 | (require '[babashka.deps :as deps])
11 |
12 | (def cmd ["-P" (str "-A" (str/join aliases))])
13 |
14 | (println "Downloading deps using:" cmd)
15 |
16 | (deps/clojure cmd)
17 |
--------------------------------------------------------------------------------
/examples/fzf.clj:
--------------------------------------------------------------------------------
1 | (require '[babashka.process :as p])
2 |
3 | (defn fzf [s]
4 | (let [proc (p/process ["fzf" "-m"]
5 | {:in s :err :inherit
6 | :out :string})]
7 | (:out @proc)))
8 |
9 | (fzf (slurp *in*))
10 |
--------------------------------------------------------------------------------
/examples/httpkit_server.clj:
--------------------------------------------------------------------------------
1 | (ns examples.httpkit-server
2 | (:require [clojure.pprint :refer [pprint]]
3 | [org.httpkit.server :as server]))
4 |
5 | (defn handler [req]
6 | (let [reply (str (slurp "examples/httpkit_server.clj")
7 | "---\n\n"
8 | (with-out-str (pprint (dissoc req
9 | :headers
10 | :async-channel))))]
11 | {:body reply}))
12 |
13 | (server/run-server handler {:port 8090})
14 | @(promise) ;; wait until SIGINT
15 |
16 |
--------------------------------------------------------------------------------
/examples/is_tty.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (ns is-tty
4 | (:require [babashka.process :as p]))
5 |
6 | (defn- is-tty
7 | [fd key]
8 | (-> ["test" "-t" (str fd)]
9 | (p/process {key :inherit :env {}})
10 | deref
11 | :exit
12 | (= 0)))
13 |
14 | (defn in-is-tty? [] (is-tty 0 :in))
15 | (defn out-is-tty? [] (is-tty 1 :out))
16 | (defn err-is-tty? [] (is-tty 2 :err))
17 |
18 | (when (= *file* (System/getProperty "babashka.file"))
19 | (println "STDIN is TTY?:" (in-is-tty?))
20 | (println "STDOUT is TTY?:" (out-is-tty?))
21 | (println "STDERR is TTY?:" (err-is-tty?)))
22 |
--------------------------------------------------------------------------------
/examples/logger.clj:
--------------------------------------------------------------------------------
1 | (ns logger)
2 |
3 | (defmacro log [& msgs]
4 | (let [m (meta &form)
5 | _ns (ns-name *ns*) ;; can also be used for logging
6 | file *file*]
7 | `(binding [*out* *err*] ;; or bind to (io/writer log-file)
8 | (println (str ~file ":"
9 | ~(:line m) ":"
10 | ~(:column m))
11 | ~@msgs))))
12 |
--------------------------------------------------------------------------------
/examples/ls_jar.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | ;; usage: ls_jar.clj borkdude/sci 0.0.13-alpha.24
4 |
5 | (require '[clojure.java.io :as io]
6 | '[clojure.string :as str])
7 | (let [file (if (= 1 (count *command-line-args*))
8 | (io/file (first *command-line-args*))
9 | (let [lib (first *command-line-args*)
10 | [_org lib-name] (str/split lib #"/")
11 | version (second *command-line-args*)]
12 | (io/file (System/getProperty "user.home")
13 | (format ".m2/repository/%s/%s/%s-%s.jar"
14 | (str/replace lib "." (System/getProperty "file.separator"))
15 | version
16 | lib-name version))))]
17 | (doseq [e (enumeration-seq
18 | (.entries (java.util.jar.JarFile. file)))]
19 | (println (.getName e))))
20 |
--------------------------------------------------------------------------------
/examples/memo.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (defn stash [file-name]
4 | (with-open [os (java.util.zip.GZIPOutputStream. (io/output-stream (str "/tmp/" file-name ".zip")))]
5 | (.write os (.getBytes (slurp *in*)))
6 | (.finish os))
7 | 'ok)
8 |
9 | (defn unstash [file-name]
10 | (print (slurp (java.util.zip.GZIPInputStream. (io/input-stream (str "/tmp/" file-name ".zip"))))))
11 |
12 | (let [[action stash-name] *command-line-args*]
13 | (case action
14 | "put" (stash stash-name)
15 | "get" (unstash stash-name)
16 | (println "Invalid op:" action)))
17 |
--------------------------------------------------------------------------------
/examples/outdated.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.edn :as edn])
4 | (require '[clojure.java.shell :refer [sh]])
5 | (require '[clojure.string :as str])
6 |
7 | (def deps (-> (slurp (or (first *command-line-args*)
8 | "deps.edn"))
9 | edn/read-string
10 | :deps))
11 | (def with-release (zipmap (keys deps)
12 | (map #(assoc % :mvn/version "RELEASE")
13 | (vals deps))))
14 |
15 | (defn deps->versions [deps]
16 | (let [res (sh "clojure" "-Sdeps" (str {:deps deps}) "-Stree")
17 | tree (:out res)
18 | lines (str/split tree #"\n")
19 | top-level (remove #(str/starts-with? % " ") lines)
20 | deps (map #(str/split % #" ") top-level)]
21 | (reduce (fn [acc [dep version]]
22 | (assoc acc dep version))
23 | {}
24 | deps)))
25 |
26 | (def version-map (deps->versions deps))
27 | (def new-version-map (deps->versions with-release))
28 |
29 | (doseq [[dep version] version-map
30 | :let [new-version (get new-version-map dep)]
31 | :when (not= version new-version)]
32 | (println dep "can be upgraded from" version "to" new-version))
33 |
34 | ;; Inspired by an idea from @seancorfield on Clojurians Slack
35 |
--------------------------------------------------------------------------------
/examples/pom_version_get.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (ns pom-version-get
4 | {:author "Wilker Lucio"}
5 | (:require [clojure.data.xml :as xml]
6 | [clojure.string :as str]))
7 |
8 | (defn tag-name? [tag tname]
9 | (some-> tag :tag name #{tname}))
10 |
11 | (defn tag-content-str [tag]
12 | (->> tag :content (filter string?) (str/join "")))
13 |
14 | (defn pom-version
15 | ([] (pom-version "pom.xml"))
16 | ([path]
17 | (->>
18 | (slurp path)
19 | (xml/parse-str)
20 | (xml-seq)
21 | (filter #(tag-name? % "version"))
22 | first
23 | tag-content-str)))
24 |
25 | (if-let [arg (first *command-line-args*)]
26 | (pom-version arg)
27 | (pom-version))
28 |
--------------------------------------------------------------------------------
/examples/pom_version_get_xml_zip.clj:
--------------------------------------------------------------------------------
1 | (require '[babashka.deps :as deps])
2 |
3 | (deps/add-deps '{:deps {org.clojure/data.zip {:mvn/version "RELEASE"}}})
4 |
5 | (require '[clojure.data.xml :as xml]
6 | '[clojure.data.zip.xml :as xmlz]
7 | '[clojure.zip :as zip])
8 |
9 | (def xml "<pom><version>1.0.0</version></pom>")
10 |
11 | (-> xml
12 | xml/parse-str
13 | zip/xml-zip
14 | (xmlz/xml1-> :pom :version zip/down zip/node))
15 | ;; => 1.0.0
16 |
--------------------------------------------------------------------------------
/examples/pom_version_set.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | ;; usage: version.clj pom.xml 1.0.1
4 |
5 | ;; pom.xml:
6 | ;; <project>
7 | ;; <version></version>
8 | ;; </project>
9 |
10 | ;; prints to stdout:
11 | ;; <project>
12 | ;; <version>1.0.1</version>
13 | ;; </project>
14 |
15 | (ns pom-version-set
16 | {:author "Michiel Borkent"}
17 | (:require [clojure.data.xml :as xml]))
18 |
19 | (def pom-xml (first *command-line-args*))
20 | (def version (second *command-line-args*))
21 |
22 | (def xml (xml/parse-str (slurp pom-xml)))
23 |
24 | (defn update-version [elt]
25 | (if-let [t (:tag elt)]
26 | (if (= "version" (name t))
27 | (assoc elt :content version)
28 | elt)
29 | elt))
30 |
31 | (println
32 | (xml/emit-str
33 | (update xml :content
34 | (fn [contents]
35 | (map update-version contents)))))
36 |
37 |
--------------------------------------------------------------------------------
/examples/process_builder.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.java.io :as io])
4 | (import '[java.lang ProcessBuilder$Redirect])
5 |
6 | (defn grep [input pattern]
7 | (let [proc (-> (ProcessBuilder. ["grep" pattern])
8 | (.redirectOutput ProcessBuilder$Redirect/INHERIT)
9 | (.redirectError ProcessBuilder$Redirect/INHERIT)
10 | (.start))
11 | proc-input (.getOutputStream proc)]
12 | (with-open [w (io/writer proc-input)]
13 | (binding [*out* w]
14 | (print input)
15 | (flush)))
16 | (.waitFor proc)
17 | nil))
18 |
19 | (grep "hello\nbye\n" "bye")
20 |
--------------------------------------------------------------------------------
/examples/pst.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (def now (java.time.ZonedDateTime/now))
4 | (def LA-timezone (java.time.ZoneId/of "America/Los_Angeles"))
5 | (def LA-time (.withZoneSameInstant now LA-timezone))
6 | (def pattern (java.time.format.DateTimeFormatter/ofPattern "HH:mm"))
7 | (println (.format LA-time pattern))
8 |
--------------------------------------------------------------------------------
/examples/random_doc.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.repl])
4 |
5 | (defmacro random-doc []
6 | (let [sym (-> (ns-publics 'clojure.core) keys rand-nth)]
7 | (if (:doc (meta (resolve sym)))
8 | `(clojure.repl/doc ~sym)
9 | `(random-doc))))
10 |
11 | (random-doc)
12 |
--------------------------------------------------------------------------------
/examples/torrent-viewer.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.java.io :as io])
4 | (require '[bencode.core :refer [read-bencode]])
5 | (require '[clojure.walk :refer [prewalk]])
6 | (require '[clojure.pprint :refer [pprint]])
7 | (import 'java.io.PushbackInputStream)
8 |
9 | (defn bytes->strings [coll]
10 | (prewalk #(if (bytes? %) (String. % "UTF-8") %) coll))
11 |
12 | (defn read-torrent [src]
13 | (with-open [in (io/input-stream (io/file src))]
14 | (-> in PushbackInputStream. read-bencode bytes->strings)))
15 |
16 | (when-let [src (first *command-line-args*)]
17 | (-> (read-torrent src)
18 | (assoc-in ["info" "pieces"] "...") ; binary data
19 | pprint))
20 |
--------------------------------------------------------------------------------
/examples/vim.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 | (require '[clojure.java.io :as io])
3 |
4 | (defn vim [file]
5 | (->
6 | (ProcessBuilder. ["vim" file])
7 | (.inheritIO)
8 | (.start)
9 | (.waitFor)))
10 |
11 | (def readme
12 | (let [f (io/file "README.md")]
13 | (when (not (.exists f))
14 | (vim (.getPath f)))
15 | (slurp f)))
16 |
17 | (println readme)
18 |
--------------------------------------------------------------------------------
/examples/whatsapp_frequencies.clj:
--------------------------------------------------------------------------------
1 | ;; USAGE: in whatsapp group chat, export your chat _without_ media, and store somewhere.
2 | ;; Then
3 | ;; $ cat chatfile.txt | bb -i -f whatsapp_frequencies.clj
4 |
5 | (ns whatsapp-frequencies
6 | {:author "Marten Sytema"}
7 | (:require [clojure.java.io :as io]
8 | [clojure.pprint :refer [print-table]]
9 | [clojure.string :refer [trim] :as string]))
10 |
11 | (defn parse-line
12 | "Returns the name of the message, or nil if it can't be found"
13 | [l]
14 | (->> (string/replace l #"\p{C}" "")
15 | trim
16 | (re-find #"\[.*\] (.+?):")
17 | second))
18 |
19 | (defn chats-by-user
20 | ([lines]
21 | (chats-by-user lines parse-line))
22 | ([lines keep-fn]
23 | (->> lines
24 | (keep keep-fn)
25 | frequencies
26 | (sort-by second >)
27 | (map (fn [[name amount]]
28 | {:name name
29 | :amount amount}))
30 | (print-table [:name :amount]))))
31 |
32 | (chats-by-user (line-seq (io/reader *in*)))
33 |
--------------------------------------------------------------------------------
/examples/which.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.java.io :as io])
4 |
5 | (defn which [executable]
6 | (let [path (System/getenv "PATH")
7 | paths (.split path (System/getProperty "path.separator"))]
8 | (loop [paths paths]
9 | (when-first [p paths]
10 | (let [f (io/file p executable)]
11 | (if (and (.isFile f)
12 | (.canExecute f))
13 | (.getCanonicalPath f)
14 | (recur (rest paths))))))))
15 |
16 | (when-let [executable (first *command-line-args*)]
17 | (println (which executable)))
18 |
--------------------------------------------------------------------------------
/examples/wiki-translate.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 | ;; by Janne Himanka shared on Clojurians Slack
3 | (require '[babashka.curl :as curl])
4 |
5 | (let [url (str "https://en.wikipedia.org/wiki/" (first *command-line-args*))
6 | page (:body (curl/get url))]
7 | (cond
8 | (re-find #"Disambiguation" page)
9 | (doseq [item (map last (re-seq #"<li><a href...wiki/([^\"]+)" page))]
10 | (println item))
11 | :else (last (re-find #"nl.wikipedia.org/.+?title..([^\"]+)" page))))
12 |
--------------------------------------------------------------------------------
/feature-core-match/babashka/impl/match.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.match
2 | {:no-doc true}
3 | (:require [clojure.core.match :as match]
4 | clojure.core.match.array ;; side effecting
5 | clojure.core.match.debug ;; side effecting
6 | clojure.core.match.protocols ;; side effecting
7 | clojure.core.match.regex ;; side effecting
8 | [sci.core :as sci :refer [copy-var]]))
9 |
10 | (def mns (sci/create-ns 'clojure.core.match nil))
11 |
12 | (def core-match-namespace
13 | {'match (copy-var match/match mns)
14 | 'backtrack (copy-var match/backtrack mns)
15 | 'val-at* (copy-var match/val-at* mns)
16 | 'defpred (copy-var match/defpred mns)})
17 |
--------------------------------------------------------------------------------
/feature-csv/babashka/impl/csv.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.csv
2 | {:no-doc true}
3 | (:require [clojure.data.csv :as csv]
4 | [sci.core :as sci]))
5 |
6 | (def cns (sci/create-ns 'clojure.data.csv nil))
7 |
8 | (def csv-namespace
9 | {'read-csv (sci/copy-var csv/read-csv cns)
10 | 'write-csv (sci/copy-var csv/write-csv cns)})
11 |
--------------------------------------------------------------------------------
/feature-datascript/babashka/impl/datascript.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.datascript
2 | {:no-doc true}
3 | (:require [datascript.core :as d]
4 | [datascript.db :as db]
5 | [sci.core :as sci :refer [copy-var]]))
6 |
7 | (def datascript-ns (sci/create-ns 'datascript.core nil))
8 | (def datascript-db-ns (sci/create-ns 'datascript.db nil))
9 |
10 | (def datascript-namespace
11 | {'create-conn (copy-var d/create-conn datascript-ns)
12 | 'transact! (copy-var d/transact! datascript-ns)
13 | 'q (copy-var d/q datascript-ns)
14 | 'empty-db (copy-var d/empty-db datascript-ns)
15 | 'db-with (copy-var d/db-with datascript-ns)
16 | 'filter (copy-var d/filter datascript-ns)
17 | 'init-db (copy-var d/init-db datascript-ns)
18 | 'datom (copy-var d/datom datascript-ns)
19 | 'pull (copy-var d/pull datascript-ns)
20 | 'pull-many (copy-var d/pull-many datascript-ns)})
21 |
22 | (def datascript-db-namespace
23 | {'db-from-reader (copy-var db/db-from-reader datascript-db-ns)
24 | 'datom-from-reader (copy-var db/datom-from-reader datascript-db-ns)
25 | 'datom-added (copy-var db/datom-added datascript-db-ns)
26 | 'datom-tx (copy-var db/datom-tx datascript-db-ns)})
27 |
--------------------------------------------------------------------------------
/feature-httpkit-server/babashka/impl/httpkit_server.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.httpkit-server
2 | (:require [org.httpkit.server :as server]
3 | [sci.core :as sci :refer [copy-var]]))
4 |
5 | (def sns (sci/create-ns 'org.httpkit.server nil))
6 |
7 | (def httpkit-server-namespace
8 | {:obj sns
9 | 'server-stop! (copy-var server/server-stop! sns)
10 | 'server-port (copy-var server/server-port sns)
11 | 'server-status (copy-var server/server-status sns)
12 | 'run-server (copy-var server/run-server sns)
13 | 'sec-websocket-accept (copy-var server/sec-websocket-accept sns)
14 | 'websocket-handshake-check (copy-var server/websocket-handshake-check sns)
15 | 'send-checked-websocket-handshake! (copy-var server/send-checked-websocket-handshake! sns)
16 | 'send-websocket-handshake! (copy-var server/send-websocket-handshake! sns)
17 | 'as-channel (copy-var server/as-channel sns)
18 | 'send! (copy-var server/send! sns)
19 | 'with-channel (copy-var server/with-channel sns)
20 | 'on-close (copy-var server/on-close sns)
21 | 'close (copy-var server/close sns)}
22 | )
23 |
--------------------------------------------------------------------------------
/feature-priority-map/babashka/impl/priority_map.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.priority-map
2 | (:require [clojure.data.priority-map :as pm]
3 | [sci.core :as sci]))
4 |
5 | (def pmns (sci/create-ns 'clojure.data.priority-map))
6 |
7 | (def priority-map-namespace
8 | {'priority-map (sci/copy-var pm/priority-map pmns)
9 | 'priority-map-keyfn (sci/copy-var pm/priority-map-keyfn pmns)
10 | 'subseq (sci/copy-var pm/subseq pmns)
11 | 'rsubseq (sci/copy-var pm/rsubseq pmns)})
12 |
--------------------------------------------------------------------------------
/feature-rrb-vector/babashka/impl/rrb_vector.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.rrb-vector
2 | (:require [clojure.core.rrb-vector :as rrb]
3 | [sci.core :as sci]))
4 |
5 | (def rrbns (sci/create-ns 'clojure.core.rrb-vector))
6 |
7 | (def rrb-vector-namespace {'catvec (sci/copy-var rrb/catvec rrbns)})
8 |
--------------------------------------------------------------------------------
/feature-transit/babashka/impl/transit.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.transit
2 | (:require
3 | [cognitect.transit :as transit]
4 | [sci.core :as sci :refer [copy-var]]))
5 |
6 | (def tns (sci/create-ns 'cognitect.transit nil))
7 |
8 | (def transit-namespace
9 | {'write (copy-var transit/write tns)
10 | 'writer (copy-var transit/writer tns)
11 | 'write-handler (copy-var transit/write-handler tns)
12 | 'write-handler-map (copy-var transit/write-handler-map tns)
13 | 'write-meta (copy-var transit/write-meta tns)
14 | 'read (copy-var transit/read tns)
15 | 'reader (copy-var transit/reader tns)
16 | 'read-handler (copy-var transit/read-handler tns)
17 | 'read-handler-map (copy-var transit/read-handler-map tns)
18 | 'default-write-handlers (copy-var transit/default-write-handlers tns)
19 | 'tagged-value (copy-var transit/tagged-value tns)})
20 |
--------------------------------------------------------------------------------
/feature-yaml/babashka/impl/ordered.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.ordered
2 | {:no-doc true}
3 | (:require [flatland.ordered.map :as omap]
4 | [flatland.ordered.set :as oset]
5 | [sci.core :as sci]))
6 |
7 | (def omap-ns (sci/create-ns 'flatland.ordered.map nil))
8 | (def oset-ns (sci/create-ns 'flatland.ordered.set nil))
9 |
10 | (def ordered-map-ns
11 | {'ordered-map (sci/copy-var omap/ordered-map omap-ns)})
12 |
13 | (def ordered-set-ns
14 | {'ordered-set (sci/copy-var oset/ordered-set oset-ns)})
15 |
--------------------------------------------------------------------------------
/feature-yaml/babashka/impl/yaml.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.yaml
2 | {:no-doc true}
3 | (:require [clj-yaml.core :as yaml]
4 | [sci.core :as sci :refer [copy-var]]))
5 |
6 | (def yns (sci/create-ns 'clj-yaml.core nil))
7 |
8 | (def yaml-namespace
9 | {'mark (copy-var yaml/mark yns)
10 | 'unmark (copy-var yaml/unmark yns)
11 | 'generate-string (copy-var yaml/generate-string yns)
12 | 'parse-string (copy-var yaml/parse-string yns)
13 | 'generate-stream (copy-var yaml/generate-stream yns)
14 | 'parse-stream (copy-var yaml/parse-stream yns)
15 | })
16 |
--------------------------------------------------------------------------------
/impl-java/.dir-locals.el:
--------------------------------------------------------------------------------
1 | ((nil
2 | (cider-clojure-cli-global-options . "-A:test:build")))
3 |
--------------------------------------------------------------------------------
/impl-java/bb.edn:
--------------------------------------------------------------------------------
1 | {:tasks {install (clojure "-T:build install")
2 | deploy (clojure "-T:build deploy")}}
3 |
--------------------------------------------------------------------------------
/impl-java/deps.edn:
--------------------------------------------------------------------------------
1 | {:deps {org.babashka/sci.impl.types {:mvn/version "0.0.2"}}
2 | :aliases
3 | {:build ;; added by neil
4 | {:paths ["." "build" "src"]
5 | :deps {io.github.clojure/tools.build {:git/tag "v0.9.6" :git/sha "8e78bcc"}
6 | slipset/deps-deploy {:mvn/version "0.2.0"}
7 | org.babashka/sci.impl.types {:mvn/version "0.0.2"}
8 | ;; insn/insn {:mvn/version "0.5.3"}
9 | insn/insn {
10 | :git/sha "f85da286d429b507480f8527b12ce3e1e0e17296"
11 | :git/url "https://github.com/phronmophobic/insn"
12 | }}
13 | :ns-default build}}}
14 |
--------------------------------------------------------------------------------
/logo/babashka-blue-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/logo/babashka-blue-yellow.png
--------------------------------------------------------------------------------
/logo/babashka.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/logo/babashka.png
--------------------------------------------------------------------------------
/logo/babashka_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/logo/babashka_red.png
--------------------------------------------------------------------------------
/logo/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/logo/icon.png
--------------------------------------------------------------------------------
/resources/BABASHKA_RELEASED_VERSION:
--------------------------------------------------------------------------------
1 | 1.12.209
--------------------------------------------------------------------------------
/resources/BABASHKA_VERSION:
--------------------------------------------------------------------------------
1 | 1.12.210-SNAPSHOT
--------------------------------------------------------------------------------
/resources/CutOffCoreServicesDependencies.java:
--------------------------------------------------------------------------------
1 | import org.graalvm.nativeimage.Platform;
2 | import org.graalvm.nativeimage.Platforms;
3 | import com.oracle.svm.core.annotate.TargetClass;
4 | import com.oracle.svm.core.annotate.Delete;
5 |
6 | public final class CutOffCoreServicesDependencies {
7 | }
8 |
9 | // @Platforms(Platform.DARWIN.class)
10 | // @TargetClass(className = "sun.net.spi.DefaultProxySelector")
11 | // @Delete
12 | // final class Target_sun_net_spi_DefaultProxySelector {
13 | // }
14 |
15 | @Platforms(Platform.DARWIN.class)
16 | @TargetClass(className = "apple.security.KeychainStore")
17 | @Delete
18 | final class Target_apple_security_KeychainStore {
19 | }
20 |
--------------------------------------------------------------------------------
/resources/CutOffSunAwtWwwContentAudioAiff.java:
--------------------------------------------------------------------------------
1 | import org.graalvm.nativeimage.Platform;
2 | import org.graalvm.nativeimage.Platforms;
3 | import com.oracle.svm.core.annotate.TargetClass;
4 | import com.oracle.svm.core.annotate.Delete;
5 |
6 | public final class CutOffSunAwtWwwContentAudioAiff {
7 | }
8 |
9 | // @Platforms(Platform.DARWIN.class)
10 | // @TargetClass(className = "sun.net.spi.DefaultProxySelector")
11 | // @Delete
12 | // final class Target_sun_net_spi_DefaultProxySelector {
13 | // }
14 |
15 | // @Platforms(Platform.DARWIN.class)
16 |
17 | // This cuts of access to the javax.sound package via java.net.HttpUrlConnection:
18 | // sun.awt.www.content.audio.aiff.getContent ->
19 | // java.net.ContentHandler.getContent ->
20 | // java.net.URLConnection.getContent()
21 |
22 | @Platforms(Platform.DARWIN.class)
23 | @TargetClass(className = "sun.awt.www.content.audio.aiff")
24 | @Delete
25 | final class Target_sun_awt_www_content_audio_aiff {
26 | }
27 |
--------------------------------------------------------------------------------
/resources/META-INF/native-image/babashka/babashka/proxy-config.json:
--------------------------------------------------------------------------------
1 | [{
2 | "interfaces": [
3 | "java.util.function.Predicate"
4 | ]
5 | },
6 | {
7 | "interfaces": [
8 | "java.util.function.Function"
9 | ]
10 | },
11 | {
12 | "interfaces": [
13 | "java.io.FileFilter"
14 | ]
15 | },
16 | {
17 | "interfaces": [
18 | "java.nio.file.DirectoryStream$Filter"
19 | ]
20 | },
21 | {
22 | "interfaces": [
23 | "java.util.function.Supplier"
24 | ]
25 | },
26 | {
27 | "interfaces": [
28 | "java.util.function.UnaryOperator"
29 | ]
30 | }
31 | ]
32 |
--------------------------------------------------------------------------------
/resources/src/babashka/clojure/repl/deps.clj:
--------------------------------------------------------------------------------
1 | (ns clojure.repl.deps
2 | (:require [babashka.deps :as deps]))
3 |
4 | (defn add-libs
5 | "Given lib-coords, a map of lib to coord, will resolve all transitive deps for the libs
6 | together and add them to the repl classpath, unlike separate calls to add-lib."
7 | {:added "1.12"}
8 | [lib-coords]
9 | (deps/add-deps {:deps lib-coords})
10 | nil)
11 |
12 | (defn add-lib
13 | "Given a lib that is not yet on the repl classpath, make it available by
14 | downloading the library if necessary and adding it to the classloader.
15 | Libs already on the classpath are not updated. Requires a valid parent
16 | DynamicClassLoader.
17 |
18 | lib - symbol identifying a library, for Maven: groupId/artifactId
19 | coord - optional map of location information specific to the procurer,
20 | or latest if not supplied
21 |
22 | Returns coll of libs loaded, including transitive (or nil if none).
23 |
24 | For info on libs, coords, and versions, see:
25 | https://clojure.org/reference/deps_and_cli"
26 | {:added "1.12"}
27 | ([lib coord]
28 | (add-libs {lib coord}))
29 | ([lib]
30 | (throw (ex-info "add-lib without explicit version isn't supported in babashka (yet)" {:lib lib}))))
31 |
32 |
--------------------------------------------------------------------------------
/script/built_in.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (ns built-in
4 | (:require [babashka.fs :as fs]
5 | [babashka.process :refer [shell]]))
6 |
7 | ;; copy clojure spec as built-in
8 | (fs/with-temp-dir [tmp-dir {}]
9 | (let [tmp-dir (fs/file tmp-dir)]
10 | (shell {:dir tmp-dir} "git clone https://github.com/babashka/spec.alpha")
11 | (let [spec-dir (fs/file tmp-dir "spec.alpha")]
12 | (shell {:dir spec-dir} "git reset 951b49b8c173244e66443b8188e3ff928a0a71e7 --hard")
13 | (fs/copy-tree (fs/file spec-dir "src" "main" "clojure") (fs/file "resources" "src" "babashka")
14 | {:replace-existing true}))))
15 |
16 |
17 |
--------------------------------------------------------------------------------
/script/check_glibc.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | function ver_lte() {
4 | printf '%s\n%s' "$1" "$2" | sort -C -V
5 | }
6 |
7 | max_glibc_version="2.31"
8 | current_glibc_version=$(ldd --version | head -1 | awk '{print $4}' | cut -d "-" -f 1)
9 |
10 | function bail() {
11 | echo "glibc greater than max version ${max_glibc_version}: ${current_glibc_version}"
12 | exit 1
13 | }
14 |
15 | ver_lte "${current_glibc_version}" "${max_glibc_version}" || bail
16 |
--------------------------------------------------------------------------------
/script/cljdoc-preview:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | rm -rf /tmp/cljdoc
4 | mkdir -p /tmp/cljdoc
5 | version=$(cat resources/BABASHKA_VERSION)
6 |
7 | echo "---- cljdoc preview: installing jar in local repo"
8 | lein install
9 |
10 | echo "---- cljdoc preview: ingesting babashka"
11 | docker run --rm -v "$PWD:/babashka" \
12 | -v "$HOME/.m2:/root/.m2" -v /tmp/cljdoc:/app/data --entrypoint "clojure" \
13 | cljdoc/cljdoc -A:cli ingest -p babashka/babashka -v "$version" \
14 | --git /babashka
15 |
16 | echo "---- cljdoc preview: starting server on port 8000"
17 | docker run --rm -p 8000:8000 -v /tmp/cljdoc:/app/data cljdoc/cljdoc
18 | # go directly to http://localhost:8000/d/babashka/babashka/0.0.10-SNAPSHOT, not via the search
19 |
--------------------------------------------------------------------------------
/script/compile.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | Rem set GRAALVM_HOME=C:\Users\IEUser\Downloads\graalvm-ce-java8-19.3.1
4 | Rem set PATH=%PATH%;C:\Users\IEUser\bin
5 |
6 | if "%GRAALVM_HOME%"=="" (
7 | echo Please set GRAALVM_HOME
8 | exit /b
9 | )
10 |
11 | set JAVA_HOME=%GRAALVM_HOME%
12 | set PATH=%GRAALVM_HOME%\bin;%PATH%
13 |
14 | set /P BABASHKA_VERSION=< resources\BABASHKA_VERSION
15 | echo Building Babashka %BABASHKA_VERSION%
16 |
17 | Rem the --no-server option is not supported in GraalVM Windows.
18 | Rem -H:EnableURLProtocols=jar,http,https is also not supported.
19 |
20 | call %GRAALVM_HOME%\bin\gu.cmd install native-image
21 |
22 | if "%BABASHKA_SHA%"=="" (
23 | for /f %%i in ('git rev-parse HEAD') do set sha=%%i
24 | if not errorlevel 1 (
25 | set BABASHKA_SHA=%sha%
26 | )
27 | )
28 |
29 | call %GRAALVM_HOME%\bin\native-image.cmd ^
30 | "-jar" "target/babashka-%BABASHKA_VERSION%-standalone.jar" ^
31 | "-H:Name=bb" ^
32 | "-H:+ReportExceptionStackTraces" ^
33 | "--verbose" ^
34 | "--no-fallback" ^
35 | "--enable-preview" ^
36 | "--install-exit-handlers" ^
37 | "-march=compatibility" ^
38 | "-O1" ^
39 | %*
40 |
41 | if %errorlevel% neq 0 exit /b %errorlevel%
42 |
43 | call bb "(+ 1 2 3)"
44 | call bb describe
45 |
--------------------------------------------------------------------------------
/script/install-clojure:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 |
5 | CLOJURE_TOOLS_VERSION="1.11.1.1200"
6 |
7 | install_dir="${1:-/usr/local}"
8 | mkdir -p "$install_dir"
9 | cd /tmp
10 | curl -O -sL "https://download.clojure.org/install/clojure-tools-$CLOJURE_TOOLS_VERSION.tar.gz"
11 | tar xzf "clojure-tools-$CLOJURE_TOOLS_VERSION.tar.gz"
12 | cd clojure-tools
13 | clojure_lib_dir="$install_dir/lib/clojure"
14 | mkdir -p "$clojure_lib_dir/libexec"
15 | cp ./*.jar "$clojure_lib_dir/libexec"
16 | cp deps.edn "$clojure_lib_dir"
17 | cp example-deps.edn "$clojure_lib_dir"
18 |
19 | sed -i -e 's@PREFIX@'"$clojure_lib_dir"'@g' clojure
20 | mkdir -p "$install_dir/bin"
21 | cp clojure "$install_dir/bin"
22 | cp clj "$install_dir/bin"
23 |
24 | cd /tmp
25 | rm -rf "clojure-tools-$CLOJURE_TOOLS_VERSION.tar.gz"
26 | rm -rf "clojure-tools"
27 | echo "Installed clojure to $install_dir/bin"
28 |
--------------------------------------------------------------------------------
/script/install-graalvm:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 |
5 | INSTALL_DIR="${1:-$HOME}"
6 |
7 | GRAALVM_VERSION="${GRAALVM_VERSION:-25}"
8 |
9 | GRAALVM_PLATFORM=$BABASHKA_PLATFORM
10 |
11 | case "${BABASHKA_ARCH:-}" in
12 | aarch64)
13 | GRAALVM_ARCH="aarch64"
14 | ;;
15 | *)
16 | GRAALVM_ARCH="x64"
17 | ;;
18 | esac
19 |
20 | GRAALVM_DIR_NAME="graalvm-$GRAALVM_VERSION"
21 | GRAALVM_FILENAME="graalvm-jdk-${GRAALVM_VERSION}_${GRAALVM_PLATFORM}-${GRAALVM_ARCH}_bin.tar.gz"
22 | DOWNLOAD_URL="https://download.oracle.com/graalvm/${GRAALVM_VERSION}/archive/${GRAALVM_FILENAME}"
23 |
24 | pushd "$INSTALL_DIR" >/dev/null
25 |
26 | if ! [ -d "$GRAALVM_DIR_NAME" ]; then
27 | echo "Downloading GraalVM $GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION on '$PWD'..."
28 | echo "$DOWNLOAD_URL"
29 | curl --fail -LO "$DOWNLOAD_URL"
30 | ls -la
31 | mkdir "$GRAALVM_DIR_NAME"
32 | tar xzvf "$GRAALVM_FILENAME" -C "$GRAALVM_DIR_NAME" --strip-components 1
33 | ls -la "$GRAALVM_DIR_NAME"
34 | fi
35 |
36 | popd >/dev/null
37 |
--------------------------------------------------------------------------------
/script/install-leiningen:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | curl https://raw.githubusercontent.com/technomancy/leiningen/2.9.1/bin/lein > lein
4 | mkdir -p /usr/local/bin/
5 | mv lein /usr/local/bin/lein
6 | chmod a+x /usr/local/bin/lein
7 | lein self-install
8 |
--------------------------------------------------------------------------------
/script/lib_tests/bb_edn_from_deps.clj:
--------------------------------------------------------------------------------
1 | (ns bb_edn_from_deps
2 | (:require [clojure.edn :as edn]
3 | [clojure.set :as set]))
4 |
5 | (defn select-deps [m] (select-keys m [:paths :deps]))
6 |
7 | (defn extra-deps [m]
8 | (-> m
9 | (get-in [:aliases :lib-tests])
10 | (set/rename-keys {:extra-deps :deps
11 | :extra-paths :paths})
12 | select-deps))
13 |
14 | (if (seq *command-line-args*)
15 | (->> (slurp "deps.edn")
16 | edn/read-string
17 | ((juxt select-deps extra-deps))
18 | (apply merge-with into)
19 | (spit (first *command-line-args*)))
20 | (println "Please specify an output file"))
21 |
--------------------------------------------------------------------------------
/script/lib_tests/run_all_libtests:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -eo pipefail
4 |
5 | : "${BABASHKA_TEST_ENV:=jvm}"
6 | export BABASHKA_TEST_ENV
7 |
8 | if [ "$BABASHKA_TEST_ENV" = "native" ]; then
9 | BB_CMD="./bb"
10 | else
11 | BB_CMD="lein bb"
12 | fi
13 |
14 | export PATH
15 | PATH=$(pwd)/process/target/test/on-path:$PATH
16 |
17 | export BABASHKA_CLASSPATH
18 | BABASHKA_CLASSPATH=$(clojure -Spath -A:lib-tests)
19 |
20 | $BB_CMD -cp "$BABASHKA_CLASSPATH" \
21 | -f "test-resources/lib_tests/babashka/run_all_libtests.clj" "$@"
22 |
--------------------------------------------------------------------------------
/script/lib_tests/run_all_libtests.bat:
--------------------------------------------------------------------------------
1 | if not defined BABASHKA_TEST_ENV set BABASHKA_TEST_ENV=jvm
2 |
3 | if "%BABASHKA_TEST_ENV%" EQU "native" (set BB_CMD=.\bb) else (set BB_CMD=lein bb)
4 |
5 | set EDN=lib_tests.edn
6 |
7 | set PATH=%CD%\process\target\test\on-path;%PATH%
8 |
9 | .\bb -f script/lib_tests/bb_edn_from_deps.clj %EDN%
10 |
11 | %BB_CMD% --config %EDN% --deps-root . -f test-resources/lib_tests/babashka/run_all_libtests.clj %*
12 |
--------------------------------------------------------------------------------
/script/postgresql_test:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | export BABASHKA_FEATURE_JDBC=true
4 | export BABASHKA_FEATURE_POSTGRESQL=true
5 | lein test :only babashka.postgresql-test
6 |
--------------------------------------------------------------------------------
/script/reflection.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[clojure.java.io :as io]
4 | '[clojure.java.shell :refer [sh]]
5 | '[clojure.string :as str])
6 |
7 | (def version (str/trim (slurp (io/file "resources" "BABASHKA_VERSION"))))
8 | (sh "lein" "with-profiles" "+reflection" "run")
9 | (io/copy (io/file "resources/META-INF/native-image/babashka/babashka/reflect-config.json") (io/file (str "babashka-" version "-reflection.json")))
10 |
--------------------------------------------------------------------------------
/script/run_lib_tests:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -eo pipefail
4 |
5 | if [ "$GRAALVM_HOME" != "" ]
6 | then
7 | export JAVA_HOME=$GRAALVM_HOME
8 | export PATH=$GRAALVM_HOME/bin:$PATH
9 | fi
10 |
11 | script/lib_tests/run_all_libtests "$@"
12 |
--------------------------------------------------------------------------------
/script/run_lib_tests.bat:
--------------------------------------------------------------------------------
1 | call script/lib_tests/run_all_libtests.bat %* || exit /B 1
2 |
--------------------------------------------------------------------------------
/src/babashka/dude.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.dude
2 | (:require [clojure-csv.core :as csv]
3 | [clojure.java.io :as io]
4 | [clojure.string :as string]))
5 |
6 | csv/x
7 | io/x
8 | string/x
9 |
--------------------------------------------------------------------------------
/src/babashka/impl/bencode.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.bencode
2 | {:no-doc true}
3 | (:require
4 | [bencode.core :as bencode]
5 | [sci.core :as sci :refer [copy-var]]))
6 |
7 | (def tns (sci/create-ns 'bencode.core nil))
8 |
9 | (def bencode-namespace
10 | {'read-bencode (copy-var bencode/read-bencode tns)
11 | 'write-bencode (copy-var bencode/write-bencode tns)})
12 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/instant.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.instant
2 | (:require [clojure.instant :as i]
3 | [sci.core :as sci]))
4 |
5 | (def ins (sci/create-ns 'clojure.instant nil))
6 |
7 | (def instant-namespace
8 | {'read-instant-date (sci/copy-var i/read-instant-date ins)
9 | 'parse-timestamp (sci/copy-var i/parse-timestamp ins)})
10 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/java/browse.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.java.browse
2 | {:no-doc true}
3 | (:require [clojure.java.shell :refer [sh]]
4 | [clojure.string :as str]
5 | [sci.core :as sci]))
6 |
7 | (def bns (sci/create-ns 'clojure.java.browse nil))
8 |
9 | (def open-url-script (sci/new-dynamic-var '*open-url-script* (atom nil) {:ns bns}))
10 |
11 | (def os
12 | (let [os-name (System/getProperty "os.name")
13 | os-name (str/lower-case os-name)]
14 | (cond (str/starts-with? os-name "mac os x")
15 | :mac
16 | (str/includes? os-name "linux")
17 | :linux
18 | (str/includes? os-name "win")
19 | :windows)))
20 |
21 | (defn browse-url [url]
22 | (let [url (str url)]
23 | (if-let [script (-> open-url-script deref deref)]
24 | (sh script url)
25 | (case os
26 | :mac (sh "open" url)
27 | :linux (sh "xdg-open" url)
28 | :windows (sh "cmd" "/C" "start" (.replace url "&" "^&"))))))
29 |
30 | (def browse-namespace
31 | {'*open-url-script* open-url-script
32 | 'browse-url (sci/copy-var browse-url bns)})
33 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/java/process.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.java.process
2 | (:require [clojure.java.process]
3 | [sci.core :as sci]))
4 |
5 | (def cjp (sci/create-ns 'clojure.java.process nil))
6 | (def cjp-namespace (sci/copy-ns clojure.java.process cjp))
7 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/math.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.math
2 | (:require [clojure.math]
3 | [sci.core :as sci]))
4 |
5 | (def mns (sci/create-ns 'clojure.math nil))
6 | (def math-namespace (sci/copy-ns clojure.math mns))
7 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/reflect.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.reflect
2 | (:require [clojure.reflect]
3 | [sci.core :as sci]))
4 |
5 | (def rns (sci/create-ns 'clojure.reflect))
6 |
7 | (def reflect-namespace {'reflect (sci/copy-var clojure.reflect/reflect rns)})
8 |
--------------------------------------------------------------------------------
/src/babashka/impl/clojure/stacktrace.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.stacktrace
2 | {:no-doc true}
3 | (:require [clojure.stacktrace :as stacktrace]
4 | [sci.core :as sci]))
5 |
6 | (def sns (sci/create-ns 'clojure.stacktrace nil))
7 |
8 | (defmacro wrap-out [f]
9 | `(fn [& ~'args]
10 | (binding [*out* @sci/out]
11 | (apply ~f ~'args))))
12 |
13 | (defn new-var [var-sym f]
14 | (sci/new-var var-sym f {:ns sns}))
15 |
16 | (def stacktrace-namespace
17 | {'root-cause (sci/copy-var stacktrace/root-cause sns)
18 | 'print-trace-element (new-var 'print-trace-element (wrap-out stacktrace/print-trace-element))
19 | 'print-throwable (new-var 'print-throwable (wrap-out stacktrace/print-throwable))
20 | 'print-stack-trace (new-var 'print-stack-trace (wrap-out stacktrace/print-stack-trace))
21 | 'print-cause-trace (new-var 'print-cause-trace (wrap-out stacktrace/print-cause-trace))})
22 |
--------------------------------------------------------------------------------
/src/babashka/impl/common.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.common
2 | (:require
3 | [clojure.java.io :as io]
4 | [clojure.string :as str]
5 | [sci.ctx-store :as ctx-store]))
6 |
7 | (set! *warn-on-reflection* true)
8 |
9 | ;; placeholder for ctx
10 | (defn ctx [] (ctx-store/get-ctx))
11 | (def bb-edn (volatile! nil))
12 | (def debug (volatile! false))
13 | (def version (str/trim (slurp (io/resource "BABASHKA_VERSION"))))
14 | (def jvm-loader (.getContextClassLoader (Thread/currentThread)))
15 | (def solo-executor (volatile! nil))
16 |
--------------------------------------------------------------------------------
/src/babashka/impl/core.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.core
2 | {:no-doc true}
3 | (:require [babashka.core]
4 | [sci.core :as sci]))
5 |
6 | (def cns (sci/create-ns 'babashka.core nil))
7 |
8 | (def core-namespace
9 | (sci/copy-ns babashka.core cns))
10 |
--------------------------------------------------------------------------------
/src/babashka/impl/curl.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.curl
2 | {:no-doc true}
3 | (:require
4 | [babashka.curl :as curl]
5 | [sci.core :as sci :refer [copy-var]]))
6 |
7 | (def tns (sci/create-ns 'babashka.curl nil))
8 |
9 | (def curl-namespace
10 | {'request (copy-var curl/request tns)
11 | 'get (copy-var curl/get tns)
12 | 'patch (copy-var curl/patch tns)
13 | 'post (copy-var curl/post tns)
14 | 'put (copy-var curl/put tns)
15 | 'head (copy-var curl/head tns)
16 | 'delete (copy-var curl/delete tns)})
17 |
--------------------------------------------------------------------------------
/src/babashka/impl/data.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.data
2 | {:no-doc true}
3 | (:require
4 | [babashka.impl.clojure.data :as data]
5 | [sci.core :as sci :refer [copy-var]]))
6 |
7 | (def data-ns (sci/create-ns 'clojure.data nil))
8 |
9 | (def data-namespace
10 | {'diff (copy-var data/diff data-ns)
11 | 'equality-partition (copy-var data/equality-partition data-ns)})
12 |
--------------------------------------------------------------------------------
/src/babashka/impl/datafy.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.datafy
2 | {:no-doc true}
3 | (:refer-clojure :exclude [create-ns])
4 | (:require
5 | [babashka.impl.protocols :as protocols]
6 | [sci.core :as sci :refer [copy-var]]))
7 |
8 | (def datafy-ns (sci/create-ns 'clojure.datafy nil))
9 |
10 | (def datafy-namespace
11 | {'datafy (copy-var protocols/datafy datafy-ns)
12 | 'nav (copy-var protocols/nav datafy-ns)})
13 |
--------------------------------------------------------------------------------
/src/babashka/impl/edamame.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.edamame
2 | (:require [edamame.core]
3 | [sci.core :as sci]))
4 |
5 | (def ens (sci/create-ns 'edamame.core))
6 |
7 | (def edamame-namespace (sci/copy-ns edamame.core ens))
8 |
--------------------------------------------------------------------------------
/src/babashka/impl/exceptions.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.exceptions)
--------------------------------------------------------------------------------
/src/babashka/impl/fs.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.fs
2 | (:require [babashka.fs]
3 | [sci.core :as sci]))
4 |
5 | (def fs-namespace
6 | (sci/copy-ns babashka.fs (sci/create-ns 'babashka.fs)))
7 |
--------------------------------------------------------------------------------
/src/babashka/impl/http_client.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.http-client
2 | (:require
3 | [babashka.http-client]
4 | [babashka.http-client.interceptors]
5 | [babashka.http-client.websocket]
6 | [sci.core :as sci]))
7 |
8 | (def hns (sci/create-ns 'babashka.http-client))
9 | (def wns (sci/create-ns 'babashka.http-client.websocket))
10 | (def ins (sci/create-ns 'babashka.http-client.interceptors))
11 |
12 | (def http-client-namespace
13 | (sci/copy-ns babashka.http-client hns))
14 |
15 | (def http-client-websocket-namespace
16 | (sci/copy-ns babashka.http-client.websocket wns))
17 |
18 | (def http-client-interceptors-namespace
19 | (sci/copy-ns babashka.http-client.interceptors ins))
20 |
--------------------------------------------------------------------------------
/src/babashka/impl/markdown.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.markdown
2 | (:require
3 | [nextjournal.markdown]
4 | [nextjournal.markdown.utils]
5 | [sci.core :as sci]))
6 |
7 | (def markdown-namespace (sci/copy-ns nextjournal.markdown
8 | (sci/create-ns 'nextjournal.markdown nil)))
9 |
10 | (def markdown-utils-namespace (sci/copy-ns nextjournal.markdown.utils
11 | (sci/create-ns 'nextjournal.markdown.utils)))
12 |
13 |
--------------------------------------------------------------------------------
/src/babashka/impl/pipe_signal_handler.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.pipe-signal-handler
2 | {:no-doc true}
3 | (:import [sun.misc Signal]
4 | [sun.misc SignalHandler]))
5 |
6 | (def pipe-state (volatile! nil))
7 |
8 | (defn pipe-signal-received? []
9 | (identical? :PIPE @pipe-state))
10 |
11 | (defn handle-pipe! []
12 | (when-not (= "true" (System/getenv "BABASHKA_DISABLE_SIGNAL_HANDLERS"))
13 | (Signal/handle
14 | (Signal. "PIPE")
15 | (reify SignalHandler
16 | (handle [_ _]
17 | (vreset! pipe-state :PIPE))))))
18 |
--------------------------------------------------------------------------------
/src/babashka/impl/rewrite_clj.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.rewrite-clj
2 | {:no-doc true}
3 | (:require [rewrite-clj.node]
4 | [rewrite-clj.paredit]
5 | [rewrite-clj.parser]
6 | [rewrite-clj.zip]
7 | [rewrite-clj.zip.subedit]
8 | [sci.core :as sci]))
9 |
10 | (def nns (sci/create-ns 'rewrite-clj.node nil))
11 | (def pens (sci/create-ns 'rewrite-clj.paredit nil))
12 | (def pns (sci/create-ns 'rewrite-clj.parser nil))
13 | (def zns (sci/create-ns 'rewrite-clj.zip nil))
14 | (def zsns (sci/create-ns 'rewrite-clj.zip.subedit nil))
15 |
16 | (def node-namespace
17 | (sci/copy-ns rewrite-clj.node nns))
18 |
19 | (def parser-namespace
20 | (sci/copy-ns rewrite-clj.parser pns))
21 |
22 | (def paredit-namespace
23 | (sci/copy-ns rewrite-clj.paredit pens))
24 |
25 | (def zip-namespace
26 | (sci/copy-ns rewrite-clj.zip zns))
27 |
28 | (def subedit-namespace
29 | (sci/copy-ns rewrite-clj.zip.subedit zsns))
30 |
--------------------------------------------------------------------------------
/src/babashka/impl/server.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.server
2 | (:require [babashka.impl.clojure.core.server :as server]
3 | [babashka.impl.common :as common]
4 | [babashka.impl.repl :as repl]
5 | [babashka.impl.socket-repl :as socket-repl]
6 | [sci.core :as sci]))
7 |
8 | (def sns (sci/create-ns 'clojure.core.server nil))
9 |
10 | (def prepl (fn [& args]
11 | (apply server/prepl (common/ctx) args)))
12 |
13 | (def io-prepl
14 | (fn [& args]
15 | (apply server/io-prepl (common/ctx) args)))
16 |
17 | (def start-server
18 | (fn [& args]
19 | (apply server/start-server (common/ctx) args)))
20 |
21 | (def repl-read
22 | (fn [& args]
23 | (apply repl/repl-read (common/ctx) @sci/in args)))
24 |
25 | (def clojure-core-server-namespace
26 | {'repl (sci/copy-var socket-repl/repl sns)
27 | 'prepl (sci/copy-var prepl sns)
28 | 'io-prepl (sci/copy-var io-prepl sns)
29 | 'start-server (sci/copy-var start-server sns)
30 | 'stop-server (sci/copy-var server/stop-server sns)
31 | 'repl-read (sci/copy-var repl-read sns)})
32 |
--------------------------------------------------------------------------------
/src/babashka/impl/sigint_handler.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.sigint-handler
2 | {:no-doc true}
3 | (:import [sun.misc Signal]
4 | [sun.misc SignalHandler]))
5 |
6 | (set! *warn-on-reflection* true)
7 |
8 | (defn handle-sigint! []
9 | (when-not (= "true" (System/getenv "BABASHKA_DISABLE_SIGNAL_HANDLERS"))
10 | (Signal/handle
11 | (Signal. "INT")
12 | (reify SignalHandler
13 | (handle [_ _]
14 | ;; This is needed to run shutdown hooks on interrupt, System/exit triggers those
15 | (System/exit 130))))))
16 |
--------------------------------------------------------------------------------
/src/babashka/impl/tools/cli.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.tools.cli
2 | {:no-doc true}
3 | (:require [clojure.tools.cli :as tools.cli]
4 | [sci.core :as sci :refer [copy-var]]))
5 |
6 | (def cli-ns (sci/create-ns 'clojure.tools.cli nil))
7 |
8 | (def tools-cli-namespace
9 | {'format-lines (copy-var tools.cli/format-lines cli-ns)
10 | 'summarize (copy-var tools.cli/summarize cli-ns)
11 | 'get-default-options (copy-var tools.cli/get-default-options cli-ns)
12 | 'parse-opts (copy-var tools.cli/parse-opts cli-ns)
13 | 'make-summary-part (copy-var tools.cli/make-summary-part cli-ns)})
14 |
--------------------------------------------------------------------------------
/test-resources/adjacent_bb/bb.edn:
--------------------------------------------------------------------------------
1 | {:deps {medley/medley {:mvn/version "1.3.0"}
2 | my-local/dep {:local/root "../local-dep"}}}
3 |
--------------------------------------------------------------------------------
/test-resources/adjacent_bb/medley.bb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (require '[local-dep])
4 |
5 | (assert (= :foo local-dep/local-dep-var))
6 |
7 | (ns medley
8 | (:require [medley.core :as medley]))
9 |
10 | (prn (medley/index-by :id [{:id 1}]))
11 |
--------------------------------------------------------------------------------
/test-resources/babashka/assert_expr.clj:
--------------------------------------------------------------------------------
1 | (require '[clojure.test :refer [is deftest] :as t])
2 |
3 | (defmethod t/assert-expr 'roughly [msg form]
4 | `(let [op1# ~(nth form 1)
5 | op2# ~(nth form 2)
6 | tolerance# (if (= 4 ~(count form)) ~(last form) 2)
7 | decimals# (/ 1. (Math/pow 10 tolerance#))
8 | result# (< (Math/abs (- op1# op2#)) decimals#)]
9 | (t/do-report
10 | {:type (if result# :pass :fail)
11 | :message ~msg
12 | :expected (format "%s should be roughly %s with %s tolerance"
13 | op1# op2# decimals#)
14 | :actual result#})
15 | result#))
16 |
17 | (deftest PI-test
18 | (is (roughly 3.14 Math/PI 2))
19 | (is (roughly 3.14 Math/PI 3)))
20 |
21 | (t/test-var #'PI-test)
22 |
--------------------------------------------------------------------------------
/test-resources/babashka/config_property.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.config-property
2 | (:require [babashka.fs :as fs]))
3 |
4 | (def prop (System/getProperty "babashka.config"))
5 |
6 | (prn (boolean (seq prop)))
7 |
8 | (when prop
9 | (prn (fs/exists? (System/getProperty "babashka.config"))))
10 |
--------------------------------------------------------------------------------
/test-resources/babashka/embedded_pg_tests.clj:
--------------------------------------------------------------------------------
1 | (ns embedded-pg-tests
2 | (:require [clojure.test :as t :refer [is]]
3 | [next.jdbc :as jdbc]
4 | [next.jdbc.sql :as sql]))
5 |
6 | (defn wait-for-postgres
7 | [db]
8 | (while
9 | (not
10 | (try (jdbc/execute! db ["select version()"])
11 | (catch Exception e
12 | (prn (ex-message e))
13 | (Thread/sleep 100))))))
14 |
15 | (defn create-table-test [db]
16 | (is (jdbc/execute! db ["drop table if exists foo; create table foo ( foo text )"])))
17 |
18 | (defn insert-test [db]
19 | (is (sql/insert-multi! db :foo [:foo] [["foo"] ["bar"] ["baz"]])))
20 |
21 | (defn query-test [db]
22 | (let [results (jdbc/execute! db ["select * from foo"])]
23 | results))
24 |
--------------------------------------------------------------------------------
/test-resources/babashka/empty.clj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/babashka/empty.clj
--------------------------------------------------------------------------------
/test-resources/babashka/exec_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.exec-test
2 | {:org.babashka/cli {:coerce {:foo []}}})
3 |
4 | (defn exec-test
5 | {:org.babashka/cli
6 | {:exec-args {:foo :foo}
7 | :coerce {:bar :keyword}}}
8 | [m]
9 | (if (:meta m)
10 | (prn (meta m))
11 | (prn m)))
12 |
--------------------------------------------------------------------------------
/test-resources/babashka/file_location1.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-location1
2 | (:require [babashka.classpath :as cp]))
3 |
4 | (cp/add-classpath "test-resources")
5 |
6 | (require '[babashka.file-location2 :as f2])
7 |
8 | (f2/uh-oh)
9 |
--------------------------------------------------------------------------------
/test-resources/babashka/file_location2.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-location2)
2 |
3 | (defn ok []
4 | "ok")
5 |
6 | (defn uh-oh []
7 | (/ 1 0))
8 |
--------------------------------------------------------------------------------
/test-resources/babashka/file_location_preloads.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-location-preloads)
2 |
3 | (require 'user)
4 | (user/ithrow)
5 |
6 |
--------------------------------------------------------------------------------
/test-resources/babashka/file_property1.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-property1
2 | (:require [clojure.java.io :as io]))
3 |
4 | (prn (= *file* (System/getProperty "babashka.file")))
5 |
6 | (load-file (.getPath (io/file "test-resources" "babashka" "file_property2.clj")))
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/file_property2.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-property2)
2 |
3 | (prn (= *file* (System/getProperty "babashka.file")))
4 |
--------------------------------------------------------------------------------
/test-resources/babashka/glob.clj:
--------------------------------------------------------------------------------
1 | (require '[clojure.java.io :as io])
2 |
3 | (defn glob [pattern]
4 | (let [matcher (.getPathMatcher
5 | (java.nio.file.FileSystems/getDefault)
6 | (str "glob:" pattern))]
7 | (into []
8 | (comp (filter #(.isFile %))
9 | (filter #(.matches matcher (.normalize (.toPath %))))
10 | (map #(.relativize (.toURI (io/file ".")) (.toURI %)))
11 | (map #(.getPath %)))
12 | (file-seq (io/file ".")))))
13 |
14 | (glob "*/doc/*.md") ;;=> ["sci/doc/libsci.md" "babashka.nrepl/doc/intro.md"]
15 |
--------------------------------------------------------------------------------
/test-resources/babashka/init_caller.clj:
--------------------------------------------------------------------------------
1 | (ns init-caller
2 | (:require [init-test :as i]))
3 |
4 | (i/do-a-thing)
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/init_test.clj:
--------------------------------------------------------------------------------
1 | (ns init-test)
2 |
3 | (defn do-a-thing [] "foo")
4 |
5 | (defn -main [& _]
6 | "Hello from init!")
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/call_init_main.clj:
--------------------------------------------------------------------------------
1 | (ns call-init-main
2 | (:require [init-test :as i]))
3 |
4 | (defn foobar [] (str (i/do-a-thing) "bar"))
5 |
6 | (defn -main [& _] (i/do-a-thing))
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/data_readers.clj:
--------------------------------------------------------------------------------
1 | {r/reverse reader/reversev}
2 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/data_readers.cljc:
--------------------------------------------------------------------------------
1 | {r/distinct reader/distinctv}
2 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/env/env_ns.clj:
--------------------------------------------------------------------------------
1 | (ns env-ns)
2 |
3 | (defn foo []
4 | "env!")
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/foo.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/babashka/src_for_classpath_test/foo.jar
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/my/impl.cljc:
--------------------------------------------------------------------------------
1 | (ns my.impl)
2 |
3 | (defn impl-fn
4 | "identity"
5 | [x] x)
6 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/my/main.clj:
--------------------------------------------------------------------------------
1 | (ns my.main
2 | (:require [my.impl :as impl]))
3 |
4 | (defn -main [& args]
5 | (impl/impl-fn args))
6 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/my/main2.clj:
--------------------------------------------------------------------------------
1 | (ns my.main2)
2 |
3 | (defn -main [& _args]
4 | (System/getProperty "babashka.main"))
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/my_script.bb:
--------------------------------------------------------------------------------
1 | (ns my-script)
2 |
3 | (defn foo []
4 | ::bb)
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/ns_with_error.clj:
--------------------------------------------------------------------------------
1 | (ns ns-with-error)
2 |
3 | (def x 0)
4 | (def y (/ 1 0))
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/src_for_classpath_test/reader.clj:
--------------------------------------------------------------------------------
1 | (ns reader)
2 |
3 | (defn reversev [data]
4 | (vec (reverse data)))
5 |
6 | (defn distinctv [data]
7 | (vec (distinct data)))
8 |
--------------------------------------------------------------------------------
/test-resources/babashka/test_report.clj:
--------------------------------------------------------------------------------
1 | (ns foo
2 | (:require
3 | [clojure.test :as t]))
4 |
5 | (t/deftest bar
6 | (t/is (= 1 2) "1 is not equal to 2"))
7 |
8 | (binding [t/report (fn [m]
9 | (prn (update m :var (comp :name meta))))]
10 | (t/test-var #'bar))
11 |
--------------------------------------------------------------------------------
/test-resources/babashka/transit.clj:
--------------------------------------------------------------------------------
1 | (require '[cognitect.transit :as transit])
2 | (import [java.io ByteArrayInputStream ByteArrayOutputStream])
3 |
4 | ;; Write data to a stream
5 | (def out (ByteArrayOutputStream. 4096))
6 | (def writer (transit/writer out :json))
7 | (transit/write writer "foo")
8 | (transit/write writer {:a [1 2]})
9 |
10 | ;; Take a peek at the JSON
11 | (.toString out)
12 | ;; => "{\"~#'\":\"foo\"} [\"^ \",\"~:a\",[1,2]]"
13 |
14 | ;; Read data from a stream
15 | (def in (ByteArrayInputStream. (.toByteArray out)))
16 | (def reader (transit/reader in :json))
17 | (prn (transit/read reader)) ;; => "foo"
18 | (prn (transit/read reader)) ;; => {:a [1 2]}
19 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberjar/deps.edn:
--------------------------------------------------------------------------------
1 | {:aliases {:babashka {:classpath-overrides {org.clojure/clojure ""
2 | org.clojure/spec.alpha ""
3 | org.clojure/core.specs.alpha ""}}}}
4 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberjar/src/my/impl.clj:
--------------------------------------------------------------------------------
1 | (ns my.impl
2 | (:require [clojure.string]))
3 |
4 | (defn impl-fn
5 | "identity"
6 | [x] x)
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberjar/src/my/impl2.clj:
--------------------------------------------------------------------------------
1 | (ns my.impl2
2 | (:require [my.impl :as impl]))
3 |
4 | (def impl-fn impl/impl-fn)
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberjar/src/my/main_main.clj:
--------------------------------------------------------------------------------
1 | (ns my.main-main
2 | (:require [my.impl :as impl])
3 | (:require [my.impl2]))
4 |
5 | (defn -main [& args]
6 | (prn (impl/impl-fn args)))
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberjar/src/my/main_pod.clj:
--------------------------------------------------------------------------------
1 | (ns my.main-pod
2 | (:require [pod.babashka.go-sqlite3 :as sqlite]))
3 |
4 | (defn -main [& _args]
5 | (sqlite/query ":memory:" ["SELECT 1 + 2 as sum"]))
6 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/impl1.clj:
--------------------------------------------------------------------------------
1 | (ns my.impl1
2 | (:require [babashka.pods :as pods]
3 | [clojure.string :as str]))
4 |
5 | ;; uberscript parser can parse and skip this
6 | (prn ::str/foo)
7 | str/join
8 |
9 | (alias 'a 'clojure.string)
10 | ::a/foo ;; no error either
11 |
12 | (pods/load-pod 'clj-kondo/clj-kondo "2021.10.19")
13 | (require '[pod.borkdude.clj-kondo :as clj-kondo])
14 |
15 | (prn (some? clj-kondo/run!))
16 |
17 | (defn impl-fn
18 | "identity"
19 | [x] x)
20 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/impl2.cljc:
--------------------------------------------------------------------------------
1 | (ns my.impl2
2 | (:require [my.impl1 :as impl1]))
3 |
4 | (def impl-fn impl1/impl-fn)
5 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/impl3.cljc:
--------------------------------------------------------------------------------
1 | (ns my.impl3)
2 |
3 | ;; see https://github.com/juxt/aero/blob/743e9bc495425b4a4a7c780f5e4b09f6680b4e7a/src/aero/core.cljc#L27
4 | ;; and https://github.com/juxt/aero/blob/743e9bc495425b4a4a7c780f5e4b09f6680b4e7a/src/aero/impl/macro.cljc#L9
5 | (defmacro usetime
6 | [& body]
7 | (when #?(:clj true :cljs (not (re-matches #".*\$macros" (name (ns-name *ns*)))))
8 | `(do ~@body)))
9 |
10 | (usetime
11 | (defn foo []))
12 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/main.clj:
--------------------------------------------------------------------------------
1 | (ns my.main
2 | (:require [my.impl1 :as impl1] ;; my.impl is already loaded, so it will not be loaded again (normally)
3 | ;; but my.impl2 also loads my.impl
4 | [my.impl2]))
5 |
6 | ;; top-level requires are also supported
7 | (require '[my.impl3 :refer [foo]])
8 |
9 | (defn -main [& args]
10 | ;; this function is defined non-top-level and may cause problems
11 | (foo)
12 | ;; this should just return args
13 | (impl1/impl-fn args))
14 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/main_pod.clj:
--------------------------------------------------------------------------------
1 | (ns my.main-pod
2 | (:require [my.other-ns-with-pod]
3 | [pod.babashka.go-sqlite3 :as sqlite]))
4 |
5 | (defn -main [& _args]
6 | (sqlite/query ":memory:" ["SELECT 1 + 2 as sum"]))
7 |
--------------------------------------------------------------------------------
/test-resources/babashka/uberscript/src/my/other_ns_with_pod.clj:
--------------------------------------------------------------------------------
1 | (ns my.other-ns-with-pod
2 | (:require [pod.babashka.go-sqlite3]))
3 |
--------------------------------------------------------------------------------
/test-resources/babashka/version.clj:
--------------------------------------------------------------------------------
1 | (require '[clojure.string :as str])
2 |
3 | (def babashka-version (System/getProperty "babashka.version"))
4 | ;; e.g. 0.1.3-SNAPSHOT
5 |
6 | (defn compare-version [v]
7 | (nat-int? (compare
8 | (mapv #(Integer. %)
9 | (take 3 (str/split babashka-version #"[\.\-]"))) v)))
10 |
11 | (prn (compare-version [0 1 2])) ;; true
12 | (prn (compare-version [0 1 3])) ;; true
13 | (prn (compare-version [100 1 4])) ;; false
14 |
--------------------------------------------------------------------------------
/test-resources/bb-edn/user.clj:
--------------------------------------------------------------------------------
1 | (ns user
2 | (:require [babashka.process :as p]
3 | [clojure.string :as str]))
4 |
5 | (defn bash [& args]
6 | ;; (prn :cmd *command-line-args*)
7 | (-> (p/process ["bash" "-c" (str/join " " args)]
8 | {:inherit true})
9 | p/check)
10 | nil)
11 |
--------------------------------------------------------------------------------
/test-resources/bb_in_root_script_in_other_dir/bb.edn:
--------------------------------------------------------------------------------
1 | {:deps {medley/medley {:mvn/version "1.3.0"}}}
2 |
3 |
--------------------------------------------------------------------------------
/test-resources/bb_in_root_script_in_other_dir/dir/script.clj:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bb
2 |
3 | (ns script
4 | (:require [medley.core :as medley]))
5 |
6 | (prn (medley/index-by :id [{:id 1}]))
7 |
--------------------------------------------------------------------------------
/test-resources/break_iterator_test.clj:
--------------------------------------------------------------------------------
1 | (ns break-iterator-test
2 | (:import [java.text BreakIterator]))
3 |
4 | (defn count-characters
5 | [^String text]
6 | (let [it (BreakIterator/getCharacterInstance)]
7 | (.setText it text)
8 | (loop [count 0]
9 | (if (= (.next it) BreakIterator/DONE)
10 | count
11 | (recur (inc count))))))
12 |
13 | (prn
14 | (count-characters "🇨🇦"))
15 |
--------------------------------------------------------------------------------
/test-resources/bytechannel_and_related_classes.bb:
--------------------------------------------------------------------------------
1 | (ns bytechannel-and-related-classes
2 | (:require [clojure.java.io :as io])
3 | (:import (java.nio.file OpenOption
4 | StandardOpenOption)
5 | (java.nio.channels ByteChannel
6 | FileChannel
7 | ReadableByteChannel
8 | WritableByteChannel
9 | Channels)))
10 |
11 | (when (and (let [ch (-> (.getBytes "Hello")
12 | (java.io.ByteArrayInputStream.)
13 | (Channels/newChannel))]
14 | (instance? ReadableByteChannel ch))
15 | (let [ch (-> (java.io.ByteArrayOutputStream.)
16 | (Channels/newChannel))]
17 | (instance? WritableByteChannel ch))
18 | (with-open [ch (FileChannel/open (-> (io/file "README.md")
19 | (.toPath))
20 | (into-array OpenOption [StandardOpenOption/READ]))]
21 | (instance? ByteChannel ch)))
22 | (println :success))
23 |
--------------------------------------------------------------------------------
/test-resources/clojure-dir-test/deps.edn:
--------------------------------------------------------------------------------
1 | {:deps {medley/medley {:mvn/version "1.3.0"}}}
2 |
--------------------------------------------------------------------------------
/test-resources/coffee-tasks.edn:
--------------------------------------------------------------------------------
1 | {:tasks
2 | {coffeep {:depends [groundsp hot-waterp filterp mugp]
3 | :task (do (Thread/sleep 300)
4 | [:made-coffee [groundsp hot-waterp filterp mugp]])}
5 | groundsp {:depends [beansp]
6 | :task (do
7 | (Thread/sleep 200)
8 | [:ground-beans [beansp]])}
9 | hot-waterp {:depends [waterp]
10 | :task (do (Thread/sleep 200)
11 | [:heated-water [waterp]])}
12 | filterp {:task (do
13 | (Thread/sleep 100)
14 | :filter)}
15 | mugp {:task (do
16 | (Thread/sleep 100)
17 | :mug)}
18 | waterp {:task (do
19 | (Thread/sleep 100)
20 | :poured-water)}
21 | beansp {:task (do
22 | (Thread/sleep 100)
23 | :measured-beans)}}}
24 |
--------------------------------------------------------------------------------
/test-resources/divide_by_zero.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/divide_by_zero.jar
--------------------------------------------------------------------------------
/test-resources/domain_sockets.bb:
--------------------------------------------------------------------------------
1 | (import java.net.UnixDomainSocketAddress
2 | java.net.StandardProtocolFamily
3 | [java.nio.channels ServerSocketChannel SocketChannel])
4 |
5 | (require '[clojure.java.io :as io]
6 | '[babashka.fs])
7 |
8 | (def sockaddr (UnixDomainSocketAddress/of
9 | (-> (doto (fs/file (fs/temp-dir) "server.socket")
10 | (.deleteOnExit))
11 | str)))
12 |
13 | ;; server
14 | (def server
15 | (future
16 | (let [ch (ServerSocketChannel/open StandardProtocolFamily/UNIX)]
17 | (.bind ch sockaddr)
18 | (.accept ch))))
19 |
20 | (Thread/sleep 100)
21 |
22 | ;; client
23 | (let [ch (SocketChannel/open StandardProtocolFamily/UNIX)
24 | ch (loop [retry 0]
25 | (let [v (try (.connect ch sockaddr)
26 | (catch Exception e e))]
27 | (if (instance? Exception v)
28 | (if (< retry 10)
29 | (do (Thread/sleep 100)
30 | (recur (inc retry)))
31 | (throw v))
32 | v)))]
33 | #_(prn :ch ch)
34 | #_(.close ch))
35 |
36 | @server
37 |
38 | (when-not (System/getProperty "babashka.version")
39 | (shutdown-agents))
40 |
41 | :success
42 |
--------------------------------------------------------------------------------
/test-resources/extended-attributes.txt:
--------------------------------------------------------------------------------
1 | 42
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/default-reader.edn:
--------------------------------------------------------------------------------
1 | {:date-str "2013-07-09T18:05:53.231-00:00"
2 | :date #inst ^:ref [:date-str]}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/empty-config.edn:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/aero/empty-config.edn
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/hosts.edn:
--------------------------------------------------------------------------------
1 | {:color #hostname {"emerald" "green"
2 | #{"diamond"} "white"
3 | :default "black"}
4 | :weight #hostname {"emerald" 10}}
5 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/included.edn:
--------------------------------------------------------------------------------
1 | {:greeting ^:ref [:hello 1]
2 | :hello [:world "str"]}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/includes.edn:
--------------------------------------------------------------------------------
1 | #include #profile {:relative "sub/includes.edn"
2 | :relative-abs #join [#env "PWD" "/test-resources/lib_tests/aero/sub/includes.edn"]
3 | :resource "aero/sub/includes.edn"
4 | :file "test-resources/lib_tests/aero/sub/includes.edn"
5 | :file-does-not-exist "goodluck.edn"
6 | :map :sub-includes}
7 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/long_prop.edn:
--------------------------------------------------------------------------------
1 | {:long-prop #long #prop "FOO"}
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/lumo_test.cljs:
--------------------------------------------------------------------------------
1 | (ns aero.lumo-test
2 | (:require
3 | aero.core-test
4 | [cljs.test :refer-macros [deftest is testing run-tests]]))
5 |
6 | (def resolve-p (atom nil))
7 |
8 | (def p (new js/Promise (fn [resolve reject]
9 | (reset! resolve-p resolve))))
10 |
11 | (defmethod cljs.test/report [:cljs.test/default :end-run-tests]
12 | [m]
13 | (@resolve-p m))
14 |
15 | (defn -main [& argv]
16 | (println "Testing with lumo")
17 | (run-tests 'aero.core-test)
18 | (-> p
19 | (.then (fn [m]
20 | (.exit (js/require "process")
21 | (if (cljs.test/successful? m)
22 | 0
23 | 1))))))
24 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/sub/includes.edn:
--------------------------------------------------------------------------------
1 | #include #profile {:relative "../valid.edn"
2 | :relative-abs "../valid.edn"
3 | :resource "aero/valid.edn"
4 | :file "test-resources/lib_tests/aero/valid.edn"
5 | :map :valid-file}
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/aero/valid.edn:
--------------------------------------------------------------------------------
1 | true
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/babashka/curl_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.curl-test
2 | (:require [babashka.curl :as curl]
3 | [cheshire.core :as json]
4 | [clojure.test :as t :refer [deftest]]))
5 |
6 | (deftest curl-test
7 | (require '[babashka.curl :as curl] :reload-all)
8 |
9 | (prn (:status (curl/get "https://www.clojure.org")))
10 |
11 | (prn (:status (curl/get "https://postman-echo.com/get?foo1=bar1&foo2=bar2")))
12 |
13 | (prn (:status (curl/post "https://postman-echo.com/post")))
14 |
15 | (prn (:status (curl/post "https://postman-echo.com/post"
16 | {:body (json/generate-string {:a 1})
17 | :headers {"X-Hasura-Role" "admin"}
18 | :content-type :json
19 | :accept :json})))
20 |
21 | (prn (:status (curl/put "https://postman-echo.com/put"
22 | {:body (json/generate-string {:a 1})
23 | :headers {"X-Hasura-Role" "admin"}
24 | :content-type :json
25 | :accept :json}))))
26 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/better_cond/core_test.cljc:
--------------------------------------------------------------------------------
1 | (ns better-cond.core-test
2 | (:refer-clojure :exclude [cond if-let when-let if-some when-some])
3 | (:require [better-cond.core :refer [cond]]
4 | [clojure.test :refer [deftest are]]))
5 |
6 | (deftest better-cond
7 | (are [x y] (= x y)
8 | 2 (cond (even? 3) 5
9 | (odd? 3) 2)
10 | 2 (cond (even? 3) 5
11 | :else 2)
12 | 2 (cond
13 | :let [x 2]
14 | x)
15 | 2 (cond
16 | :when-let [x 2]
17 | x)
18 | 2 (cond
19 | :when-some [x 2]
20 | x)
21 | nil (cond
22 | :when-let [x false]
23 | 2)
24 | 2 (cond
25 | :when-let [x true]
26 | 2)
27 | nil (cond
28 | :when-let [x nil]
29 | 2)
30 | 2 (cond
31 | :when-some [x false]
32 | 2)
33 | 2 (cond
34 | :when (even? 4)
35 | 2)
36 | nil (cond
37 | :when (even? 3)
38 | 2)))
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/bond/target_data.clj:
--------------------------------------------------------------------------------
1 | (ns bond.target-data
2 | "Reference def targets for bond to test against."
3 | {:clj-kondo/config {:linters {:unused-binding {:level :off}
4 | :unused-private-var {:level :off}}}})
5 |
6 | (defn foo
7 | [x]
8 | (* 2 x))
9 |
10 | (defn- private-foo
11 | [x]
12 | (* 2 x))
13 |
14 | (defn foo-caller [x]
15 | (foo x))
16 |
17 | (defn bar
18 | [x]
19 | (println "bar!") (* 2 x))
20 |
21 | (defn quux
22 | [a b & c]
23 | c)
24 |
25 | (defn quuk
26 | [a b & c]
27 | c)
28 |
29 | (defmacro baz
30 | [x]
31 | `(* ~x 2))
32 |
33 | (def without-arglists
34 | (fn [x]
35 | (* 2 x)))
36 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/bond/test/target.cljc:
--------------------------------------------------------------------------------
1 | (ns bond.test.target)
2 |
3 | (defn foo
4 | [x]
5 | (* 2 x))
6 |
7 | (defn- private-foo
8 | [x]
9 | (* 2 x))
10 |
11 | (defn foo-caller [x]
12 | (foo x))
13 |
14 | (defn bar
15 | [x]
16 | (println "bar!") (* 2 x))
17 |
18 | (defn quux
19 | [a b & c]
20 | c)
21 |
22 | (defn quuk
23 | [a b & c]
24 | c)
25 |
26 | (defmacro baz
27 | [x]
28 | `(* ~x 2))
29 |
30 | (def without-arglists
31 | (fn [x]
32 | (* 2 x)))
33 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/borkdude/deps/smoke_test.clj:
--------------------------------------------------------------------------------
1 | (ns borkdude.deps.smoke-test
2 | (:require [clojure.test :as t :refer [deftest is]]
3 | [clojure.java.io :as io]
4 | [clojure.string :as str]
5 | [babashka.curl :as curl]))
6 |
7 |
8 | (def windows? (-> (System/getProperty "os.name")
9 | (str/lower-case)
10 | (str/includes? "win")))
11 |
12 | (deftest basic-test
13 | (spit "deps_test.clj"
14 | (:body (curl/get "https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj"
15 | (if windows? {:compressed false} {}))))
16 |
17 | (binding [*command-line-args* ["-Sdescribe"]]
18 | (load-file "deps_test.clj"))
19 |
20 | (.delete (io/file "deps_test.clj")))
21 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/camel_snake_kebab/extras_test.cljc:
--------------------------------------------------------------------------------
1 | (ns camel-snake-kebab.extras-test
2 | (:require [camel-snake-kebab.core :as csk]
3 | [camel-snake-kebab.extras :refer [transform-keys]]
4 | #?(:clj [clojure.test :refer :all]
5 | :cljs [cljs.test :refer-macros [deftest testing is are]])))
6 |
7 | (deftest transform-keys-test
8 | (are [x y] (= x (transform-keys csk/->kebab-case-keyword y))
9 | nil nil
10 | {} {}
11 | [] []
12 | {:total-books 0 :all-books []} {'total_books 0 "allBooks" []}
13 | [{:the-author "Dr. Seuss" :the-title "Green Eggs and Ham"}]
14 | [{'the-Author "Dr. Seuss" "The_Title" "Green Eggs and Ham"}]
15 | {:total-books 1 :all-books [{:the-author "Dr. Seuss" :the-title "Green Eggs and Ham"}]}
16 | {'total_books 1 "allBooks" [{'THE_AUTHOR "Dr. Seuss" "the_Title" "Green Eggs and Ham"}]}))
17 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/camel_snake_kebab/test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns camel-snake-kebab.test-runner
2 | (:require [cljs.test :as test]
3 | [doo.runner :refer-macros [doo-all-tests doo-tests]]
4 | [camel-snake-kebab.core-test]
5 | [camel-snake-kebab.extras-test]
6 | [camel-snake-kebab.internals.string-separator-test]))
7 |
8 | (doo-tests 'camel-snake-kebab.core-test
9 | 'camel-snake-kebab.extras-test
10 | 'camel-snake-kebab.internals.string-separator-test)
11 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cheshire/test/multi.json:
--------------------------------------------------------------------------------
1 | {"one":1,"foo":"bar"}
2 | {"two":2,"foo":"bar"}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/core_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.core-test
2 | (:require
3 | ;; BB-TEST-PATCH: require clojure.string for split-lines patch below
4 | [clojure.string :as str]
5 | [clojure.test :refer [deftest testing is]]
6 | [clojure.java.io :as io]
7 | [clarktown.core :as core]))
8 |
9 |
10 | (deftest overall-test
11 | (testing "Overall"
12 | ;; BB-TEST-PATCH: library uses hard-coded \n, so using split-lines for platform-agnostic testing
13 | ;; BB-TEST-PATCH: change file paths to match bb folder structure (and copy resource files)
14 | (is (= (str/split-lines (core/render (slurp (io/file (io/resource "clarktown/core.md")))))
15 | (str/split-lines (slurp (io/file (io/resource "clarktown/core_result.html"))))))))
16 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/bold_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.bold-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.bold :as bold]))
5 |
6 |
7 | (deftest bold-test
8 | (testing "Creating bold text with two surrounding asterisk characters"
9 | (is (= "<strong>This is bold.</strong>"
10 | (bold/render "**This is bold.**" nil))))
11 |
12 | (testing "Creating bold text with two surrounding underscore characters"
13 | (is (= "<strong>This is bold.</strong>"
14 | (bold/render "__This is bold.__" nil))))
15 |
16 | (testing "Creating bold text with both underscores and asterisks mixed"
17 | (is (= "Hi, my name is <strong>John</strong>, what is <strong>your name?</strong>"
18 | (bold/render "Hi, my name is **John**, what is __your name?__" nil)))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/code_block.md:
--------------------------------------------------------------------------------
1 | ```javascript
2 | // Detect horizontal line block
3 | function isHorizontalLineBlock(block) {
4 | return block === "***";
5 | }
6 |
7 | // Render horizontal line block
8 | function horizontalLineBlock(block) {
9 | return `<hr>`;
10 | }
11 |
12 | // Compose an array of parsers
13 | const parsers = [{
14 | matcher: isHorizontalLineBlock,
15 | renderers: [horizontalLineBlock]
16 | }];
17 |
18 | // And finally, our parser itself
19 | function markdownToHTML(markdown) {
20 | // Create blocks
21 | const blocks = content.split(/\n\n/);
22 |
23 | // Parse blocks
24 | const parsedBlocks = blocks.map((block) => {
25 | // Let's find a parser that has a matcher that matches
26 | const parser = parsers.find((parser) => parser.matcher(block));
27 |
28 | // If match was found, let's run our renderers over `block`
29 | if (parser) {
30 | for (const renderer of match.renderers) {
31 | block = renderer(block);
32 | }
33 | }
34 |
35 | return block;
36 | });
37 |
38 | // And at last, join the blocks together for one big block.
39 | return parsedBlocks.join("");
40 | }
41 | ```
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/code_block_no_language.md:
--------------------------------------------------------------------------------
1 | ```
2 | // Detect horizontal line block
3 | function isHorizontalLineBlock(block) {
4 | return block === "***";
5 | }
6 |
7 | // Render horizontal line block
8 | function horizontalLineBlock(block) {
9 | return `<hr>`;
10 | }
11 |
12 | // Compose an array of parsers
13 | const parsers = [{
14 | matcher: isHorizontalLineBlock,
15 | renderers: [horizontalLineBlock]
16 | }];
17 |
18 | // And finally, our parser itself
19 | function markdownToHTML(markdown) {
20 | // Create blocks
21 | const blocks = content.split(/\n\n/);
22 |
23 | // Parse blocks
24 | const parsedBlocks = blocks.map((block) => {
25 | // Let's find a parser that has a matcher that matches
26 | const parser = parsers.find((parser) => parser.matcher(block));
27 |
28 | // If match was found, let's run our renderers over `block`
29 | if (parser) {
30 | for (const renderer of match.renderers) {
31 | block = renderer(block);
32 | }
33 | }
34 |
35 | return block;
36 | });
37 |
38 | // And at last, join the blocks together for one big block.
39 | return parsedBlocks.join("");
40 | }
41 | ```
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/code_block_no_language_result.html:
--------------------------------------------------------------------------------
1 | <pre><code>// Detect horizontal line block
2 | function isHorizontalLineBlock(block) {
3 | return block === "***";
4 | }
5 |
6 | // Render horizontal line block
7 | function horizontalLineBlock(block) {
8 | return `<hr>`;
9 | }
10 |
11 | // Compose an array of parsers
12 | const parsers = [{
13 | matcher: isHorizontalLineBlock,
14 | renderers: [horizontalLineBlock]
15 | }];
16 |
17 | // And finally, our parser itself
18 | function markdownToHTML(markdown) {
19 | // Create blocks
20 | const blocks = content.split(/\n\n/);
21 |
22 | // Parse blocks
23 | const parsedBlocks = blocks.map((block) => {
24 | // Let's find a parser that has a matcher that matches
25 | const parser = parsers.find((parser) => parser.matcher(block));
26 |
27 | // If match was found, let's run our renderers over `block`
28 | if (parser) {
29 | for (const renderer of match.renderers) {
30 | block = renderer(block);
31 | }
32 | }
33 |
34 | return block;
35 | });
36 |
37 | // And at last, join the blocks together for one big block.
38 | return parsedBlocks.join("");
39 | }</code></pre>
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/code_block_result.html:
--------------------------------------------------------------------------------
1 | <pre><code class="language-javascript">// Detect horizontal line block
2 | function isHorizontalLineBlock(block) {
3 | return block === "***";
4 | }
5 |
6 | // Render horizontal line block
7 | function horizontalLineBlock(block) {
8 | return `<hr>`;
9 | }
10 |
11 | // Compose an array of parsers
12 | const parsers = [{
13 | matcher: isHorizontalLineBlock,
14 | renderers: [horizontalLineBlock]
15 | }];
16 |
17 | // And finally, our parser itself
18 | function markdownToHTML(markdown) {
19 | // Create blocks
20 | const blocks = content.split(/\n\n/);
21 |
22 | // Parse blocks
23 | const parsedBlocks = blocks.map((block) => {
24 | // Let's find a parser that has a matcher that matches
25 | const parser = parsers.find((parser) => parser.matcher(block));
26 |
27 | // If match was found, let's run our renderers over `block`
28 | if (parser) {
29 | for (const renderer of match.renderers) {
30 | block = renderer(block);
31 | }
32 | }
33 |
34 | return block;
35 | });
36 |
37 | // And at last, join the blocks together for one big block.
38 | return parsedBlocks.join("");
39 | }</code></pre>
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/code_block_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.code-block-test
2 | (:require
3 | ;; require clojure.string to accomodate line break hack below
4 | [clojure.string :as str]
5 | [clojure.test :refer [deftest testing is]]
6 | [clojure.java.io :as io]
7 | [clarktown.parsers.code-block :as code-block]))
8 |
9 | ;; BB-TEST-PATCH: change paths to match folder structure (and copy resource files)
10 | ;; BB-TEST-PATCH: use split-lines to make tests platform-agnostic
11 | (deftest code-block-test
12 | (testing "Code block with language specification"
13 | (is (= (str/split-lines (slurp (io/file (io/resource "clarktown/parsers/code_block_result.html"))))
14 | (str/split-lines (code-block/render (slurp (io/file (io/resource "clarktown/parsers/code_block.md"))) nil)))))
15 |
16 | (testing "Code block with NO language specification"
17 | (is (= (str/split-lines (slurp (io/file (io/resource "clarktown/parsers/code_block_no_language_result.html"))))
18 | (str/split-lines (code-block/render (slurp (io/file (io/resource "clarktown/parsers/code_block_no_language.md"))) nil))))))
19 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/empty_block_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.empty-block-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.empty-block :as empty-block]))
5 |
6 |
7 | (deftest empty-block-test
8 | (testing "Rendering an empty block"
9 | (is (= (empty-block/render "" nil)
10 | "")))
11 |
12 | (testing "Checking an empty block"
13 | (is (true? (empty-block/is? "")))
14 | (is (true? (empty-block/is? " ")))))
15 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/horizontal_line_block_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.horizontal-line-block-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.horizontal-line-block :as horizontal-line-block]))
5 |
6 |
7 | (deftest horizontal-line-block-test
8 | (testing "Creating a horizontal line"
9 | (is (= "<hr>"
10 | (horizontal-line-block/render "***" nil)))
11 |
12 | (is (= "<hr>"
13 | (horizontal-line-block/render "---" nil))))
14 |
15 | (testing "Is a horizontal line block"
16 | (is (true? (horizontal-line-block/is? "***")))
17 | (is (true? (horizontal-line-block/is? " ***")))
18 | (is (false? (horizontal-line-block/is? "Test *** 123")))
19 | (is (true? (horizontal-line-block/is? "---")))
20 | (is (true? (horizontal-line-block/is? " ---")))
21 | (is (false? (horizontal-line-block/is? "Test --- 123")))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/inline_code_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.inline-code-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.inline-code :as inline-code]))
5 |
6 |
7 | (deftest inline-code-test
8 | (testing "Creating inline code text"
9 | (is (= "<code>This is inline code.</code>"
10 | (inline-code/render "`This is inline code.`" nil))))
11 |
12 | (testing "Creating inline-code text in the middle of regular text"
13 | (is (= "This is regular text, mixed with <code>some inline code.</code>, and it's great."
14 | (inline-code/render "This is regular text, mixed with `some inline code.`, and it's great." nil)))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/italic_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.italic-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.italic :as italic]))
5 |
6 |
7 | (deftest italic-test
8 | (testing "Creating italic text with one surrounding asterisk character"
9 | (is (= "<em>This is italic.</em>"
10 | (italic/render "*This is italic.*" nil))))
11 |
12 | (testing "Creating italic text with one surrounding underscore character"
13 | (is (= "<em>This is italic.</em>"
14 | (italic/render "_This is italic._" nil))))
15 |
16 | (testing "Creating italic text with both underscores and asterisks mixed"
17 | (is (= "Hi, my name is <em>John</em>, what is <em>your name?</em>"
18 | (italic/render "Hi, my name is *John*, what is _your name?_" nil)))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/link_and_image_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.link-and-image-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.link-and-image :as link-and-image]))
5 |
6 |
7 | (deftest link-test
8 | (testing "Creating a link"
9 | (is (= (link-and-image/render "[This is a link](https://example.com)" nil)
10 | "<a href=\"https://example.com\">This is a link</a>"))
11 |
12 | (is (= (link-and-image/render "[This-is-a-link](https://example.com)" nil)
13 | "<a href=\"https://example.com\">This-is-a-link</a>"))
14 |
15 | (is (= (link-and-image/render "[x] [label](link)" nil)
16 | "[x] <a href=\"link\">label</a>"))
17 |
18 | (is (= (link-and-image/render "[ ] [label](link)" nil)
19 | "[ ] <a href=\"link\">label</a>")))
20 |
21 | (testing "Creating an image"
22 | (is (= (link-and-image/render "" nil)
23 | "<img src=\"https://example.com\" alt=\"This is an image\">"))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/quote_block_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.quote-block-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.quote-block :as quote-block]))
5 |
6 |
7 | (deftest quote-block-block-test
8 | (testing "Creating a quote block line"
9 | (is (= (quote-block/render "> First line\n> second line" nil)
10 | "<blockquote>First line\nsecond line</blockquote>")))
11 |
12 | (testing "Checking a quote block"
13 | (is (true? (quote-block/is? "> Test")))
14 | (is (true? (quote-block/is? " > Test")))
15 | (is (true? (quote-block/is? ">")))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/clarktown/parsers/strikethrough_test.clj:
--------------------------------------------------------------------------------
1 | (ns clarktown.parsers.strikethrough-test
2 | (:require
3 | [clojure.test :refer [deftest testing is]]
4 | [clarktown.parsers.strikethrough :as strikethrough]))
5 |
6 |
7 | (deftest strikethrough-test
8 | (testing "Creating strikethrough text"
9 | (is (= (strikethrough/render "~~This is strikethrough text.~~" nil)
10 | "<del>This is strikethrough text.</del>")))
11 |
12 | (testing "Creating strikethrough text mixed with regular text"
13 | (is (= (strikethrough/render "Some other text, ~~This is strikethrough text.~~ And more text." nil)
14 | "Some other text, <del>This is strikethrough text.</del> And more text."))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/edn_simple.edn:
--------------------------------------------------------------------------------
1 | {:list [1 2 "hi"]
2 | :intval 100
3 | :strval "good"}
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/json_simple.json:
--------------------------------------------------------------------------------
1 | {
2 | "list": [1, 2, "hi"],
3 | "intval": 100,
4 | "strval": "good"
5 | }
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/three_lines.txt:
--------------------------------------------------------------------------------
1 | L1
2 | Line2
3 | line 3
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/utils_convert_config_test.cljc:
--------------------------------------------------------------------------------
1 | (ns cli-matic.utils-convert-config-test
2 | (:require [clojure.test :refer [is are deftest testing]]
3 | [cli-matic.optionals :as OPT]
4 |
5 | [cli-matic.utils-convert-config
6 | :refer [unmangle-fn-name
7 | unmangle-fn
8 | fn->className]]))
9 |
10 |
11 | ;
12 | ; Some example fns
13 | ;
14 |
15 |
16 | (defn add_numbers [x] x)
17 | (defn add-numbers [y] (inc y))
18 |
19 |
20 | ;
21 | ; Tests
22 | ;
23 |
24 |
25 | (deftest ^:skip-bb unmangle-fn-name-test
26 | (are [i o]
27 | (= o (unmangle-fn-name i))
28 |
29 | ;; A moderately complex name
30 | "cli_matic.utils_v2$convert_config_v1__GT_v2"
31 | "cli-matic.utils-v2/convert-config-v1->v2"))
32 |
33 | (deftest ^:skip-bb unmangle-fn-test
34 | (are [i o]
35 | (= o (unmangle-fn i))
36 |
37 | ;; A moderately complex name
38 | add-numbers
39 | 'cli-matic.utils-convert-config-test/add-numbers
40 |
41 | ; add-numbers
42 | ; "cli-matic.utils-convert-config-test/add-numbers"
43 | ))
44 |
45 | (OPT/orchestra-instrument)
46 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/yaml_full.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | invoice: 34843
3 | date : 2001-01-23
4 | bill-to: &id001
5 | given : Chris
6 | family : Dumars
7 | address:
8 | lines: |
9 | 458 Walkman Dr.
10 | Suite #292
11 | city : Royal Oak
12 | state : MI
13 | postal : 48046
14 | ship-to: *id001
15 | product:
16 | - sku : BL394D
17 | quantity : 4
18 | description : Basketball
19 | price : 450.00
20 | - sku : BL4438H
21 | quantity : 1
22 | description : Super Hoop
23 | price : 2392.00
24 | tax : 251.42
25 | total: 4443.52
26 | comments: >
27 | Late afternoon is best.
28 | Backup contact is Nancy
29 | Billsmer @ 338-4338.
30 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cli_matic/yaml_simple.yaml:
--------------------------------------------------------------------------------
1 | list: [1, 2, "hi"]
2 | intval: 100
3 | strval: "good"
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clj_commons/digest_test.clj:
--------------------------------------------------------------------------------
1 | (ns clj-commons.digest-test
2 | (:require [clj-commons.digest]
3 | [clojure.java.io :as io]
4 | [clojure.test :refer [deftest is]]))
5 |
6 | (def examples
7 | {"clojure" {'sha-256 "4f3ea34e0a3a6196a18ec24b51c02b41d5f15bd04b4a94aa29e4f6badba0f5b0"
8 | 'md5 "32c0d97f82a20e67c6d184620f6bd322"
9 | 'sha-1 "49c91cf925f70570a72cf406e9b112ce9e32250c"}
10 | nil {'sha-256 nil 'md5 nil 'sha-1 nil}
11 | (io/file "test-resources/babashka/empty.clj") {'sha-256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
12 | 'md5 "d41d8cd98f00b204e9800998ecf8427e"
13 | 'sha-1 "da39a3ee5e6b4b0d3255bfef95601890afd80709"}})
14 |
15 | (deftest digest-examples-test
16 | (doseq [[input algo-result] examples
17 | [algo expected] algo-result]
18 | (is (= ((ns-resolve 'clj-commons.digest algo) input) expected))))
19 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clj_http/lite/test_runner.clj:
--------------------------------------------------------------------------------
1 | (ns clj-http.lite.test-runner
2 | (:require [clj-http.lite.client-test]
3 | [clojure.test :as t]))
4 |
5 | (defn -main [& _]
6 | (let [{:keys [fail error]} (t/run-tests 'clj-http.lite.client-test)]
7 | (System/exit (if (or (pos? fail)
8 | (pos? error))
9 | 1 0))))
10 |
11 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clj_stacktrace/repl_test.clj:
--------------------------------------------------------------------------------
1 | (ns clj-stacktrace.repl-test
2 | (:use clojure.test)
3 | (:use clj-stacktrace.utils)
4 | (:use clj-stacktrace.repl))
5 |
6 | (defmacro with-cascading-exception
7 | "Execute body in the context of a variable bound to an exception instance
8 | that includes a caused-by cascade."
9 | [binding-sym & body]
10 | `(try (first (lazy-seq (cons (/) nil)))
11 | (catch Exception e#
12 | (let [~binding-sym e#]
13 | ~@body))))
14 |
15 | (deftest test-pst
16 | (with-cascading-exception e
17 | (is (with-out-str (pst e)))
18 | (binding [*e e]
19 | (is (with-out-str (pst))))))
20 |
21 | (deftest test-pst-str
22 | (with-cascading-exception e
23 | (is (pst-str e))
24 | (binding [*e e]
25 | (is (pst-str)))))
26 |
27 | (deftest test-pst+
28 | (with-cascading-exception e
29 | (is (with-out-str (pst+ e)))
30 | (binding [*e e]
31 | (is (with-out-str (pst+))))))
32 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clojure/data/generators_test.clj:
--------------------------------------------------------------------------------
1 | (ns clojure.data.generators-test
2 | (:require [clojure.data.generators :as gen]
3 | [clojure.test :refer (deftest is)]))
4 |
5 | (defn print-read-roundtrip
6 | [o]
7 | (binding [*print-length* nil
8 | *print-level* nil]
9 | (-> o pr-str read-string)))
10 |
11 | (defn check-print-read-roundtrip
12 | [o]
13 | (let [o2 (print-read-roundtrip o)]
14 | (when-not (= o o2)
15 | (throw (ex-info "Value cannot roundtrip, see ex-data" {:value o :roundtrip o2})))))
16 |
17 | (deftest test-print-read-roundtrip
18 | (dotimes [_ 50]
19 | (check-print-read-roundtrip (gen/anything))))
20 |
21 | (deftest test-shuffle
22 | (dotimes [_ 50]
23 | (let [coll (gen/vec gen/anything)
24 | shuf (gen/shuffle coll)]
25 | (is (= (into #{} coll)
26 | (into #{} shuf))))))
27 |
28 | (deftest test-reservoir-sample-consistency
29 | (dotimes [n 50]
30 | (let [coll (range 100)
31 | sample-1 (binding [gen/*rnd* (java.util.Random. n)]
32 | (gen/reservoir-sample 10 coll))
33 | sample-2 (binding [gen/*rnd* (java.util.Random. n)]
34 | (gen/reservoir-sample 10 coll))]
35 | (is (= sample-1 sample-2)))))
36 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clojure/data/zip_test.clj:
--------------------------------------------------------------------------------
1 | (ns clojure.data.zip-test
2 | (:require [clojure.test :as t :refer [deftest is]]
3 | [clojure.data.xml :as xml]
4 | [clojure.zip :as zip]
5 | [clojure.data.zip.xml :refer [attr attr= xml1->]]))
6 |
7 | (def data (str "<root>"
8 | " <character type=\"person\" name=\"alice\" />"
9 | " <character type=\"animal\" name=\"march hare\" />"
10 | "</root>"))
11 |
12 | (deftest xml1-test
13 | (let [xml (zip/xml-zip (xml/parse (java.io.StringReader. data)))]
14 | (is (= "person"
15 | (xml1-> xml :character [(attr= :name "alice")] (attr :type))))
16 | (is (= "march hare"
17 | (xml1-> xml :character [(attr= :type "animal")] (attr :name))))))
18 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/clojure/term/colors_test.clj:
--------------------------------------------------------------------------------
1 | (ns clojure.term.colors-test
2 | (:require [clojure.test :refer :all]
3 | [clojure.term.colors :refer :all]))
4 |
5 | (defn get-fn
6 | "get function from symbol in clojure.term.colors package"
7 | [fname]
8 | (ns-resolve (the-ns 'clojure.term.colors)
9 | (-> fname name symbol)))
10 |
11 | (defn test-colors-from-map
12 | "test print colors from a color map"
13 | [colormap & more]
14 | (eval
15 | `(do ~@(map (fn [[color _]]
16 | `(println ((get-fn ~color)
17 | (name ~color) (str ~@more))))
18 | colormap))))
19 |
20 | (deftest color-test
21 | (testing "Testing colors."
22 | (test-colors-from-map *colors* " foreground.")
23 | (test-colors-from-map *highlights* " background.")
24 | (test-colors-from-map *attributes* " attributes."))
25 |
26 | (testing "Testing disable colors."
27 | (binding [*disable-colors* true]
28 | (println \newline "When disabled-colors is set ...")
29 | (test-colors-from-map *colors* " foreground."))))
30 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/rpl/specter/cljs_test_helpers.clj:
--------------------------------------------------------------------------------
1 | (ns com.rpl.specter.cljs-test-helpers)
2 |
3 | ;; it seems like gen/bind and gen/return are a monad (hence the names)
4 | (defmacro for-all+ [bindings & body]
5 | (let [parts (partition 2 bindings)
6 | vars (vec (map first parts))
7 | genned (reduce
8 | (fn [curr [v code]]
9 | `(clojure.test.check.generators/bind ~code (fn [~v] ~curr)))
10 | `(clojure.test.check.generators/return ~vars)
11 | (reverse parts))]
12 | `(clojure.test.check.properties/for-all [~vars ~genned]
13 | ~@body)))
14 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/rpl/specter/cljs_test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns com.rpl.specter.cljs-test-runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [com.rpl.specter.core-test]
4 | [com.rpl.specter.zipper-test]))
5 |
6 | (doo-tests 'com.rpl.specter.core-test
7 | 'com.rpl.specter.zipper-test)
8 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/wsscode/misc/macros_test.clj:
--------------------------------------------------------------------------------
1 | (ns com.wsscode.misc.macros-test
2 | (:require
3 | [clojure.test :refer [deftest is are run-tests testing]]
4 | [com.wsscode.misc.macros :as macros]))
5 |
6 | (deftest full-symbol-test
7 | (is (= (macros/full-symbol
8 | 'known/foo
9 | "bar")
10 | 'known/foo))
11 | (is (= (macros/full-symbol
12 | 'foo
13 | "bar")
14 | 'bar/foo)))
15 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/wsscode/misc/math_test.cljc:
--------------------------------------------------------------------------------
1 | (ns com.wsscode.misc.math-test
2 | (:require
3 | [clojure.test :refer [deftest is are run-tests testing]]
4 | [com.wsscode.misc.math :as math]))
5 |
6 | (deftest floor-test
7 | (is (= (math/floor 30.2) 30))
8 | (is (= (math/floor 30.9) 30)))
9 |
10 | (deftest round-test
11 | (is (= (math/round 30.2) 30))
12 | (is (= (math/round 30.6) 31)))
13 |
14 | (deftest ceil-test
15 | (is (= (math/ceil 30.2) 31))
16 | (is (= (math/ceil 30.9) 31)))
17 |
18 | (deftest divmod-test
19 | (is (= (math/divmod 10 3)
20 | [3 1])))
21 |
22 | (deftest parse-long-test
23 | (is (= (math/parse-long "21")
24 | 21)))
25 |
26 | (deftest parse-double-test
27 | (is (= (math/parse-double "21.3")
28 | 21.3)))
29 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/wsscode/misc/refs_test.cljc:
--------------------------------------------------------------------------------
1 | (ns com.wsscode.misc.refs-test
2 | (:require
3 | [clojure.test :refer [deftest is are run-tests testing]]
4 | [com.wsscode.misc.refs :refer [atom?] :as refs]))
5 |
6 | (deftest kw-identical?-test
7 | (is (not (refs/kw-identical? :foo :bar)))
8 | (is (not (refs/kw-identical? :foo "foo")))
9 | (is (refs/kw-identical? :foo :foo))
10 | (is (refs/kw-identical? :foo (keyword "foo"))))
11 |
12 | (deftest atom?-test
13 | (is (true? (atom? (atom "x"))))
14 | (is (false? (atom? "x"))))
15 |
16 | (deftest greset!-test
17 | (let [x (atom nil)]
18 | (refs/greset! x "val")
19 | (is (= @x "val")))
20 |
21 | (let [x (volatile! nil)]
22 | (refs/greset! x "val")
23 | (is (= @x "val"))))
24 |
25 | (deftest gswap!-test
26 | (let [x (atom 10)]
27 | (refs/gswap! x inc)
28 | (is (= @x 11)))
29 |
30 | (let [x (volatile! 10)]
31 | (refs/gswap! x inc)
32 | (is (= @x 11)))
33 |
34 | (let [x (volatile! 10)]
35 | (refs/gswap! x + 1 2 3 4 5)
36 | (is (= @x 25))))
37 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/com/wsscode/misc/uuid_test.cljc:
--------------------------------------------------------------------------------
1 | (ns com.wsscode.misc.uuid-test
2 | (:require
3 | [clojure.test :refer [deftest is are run-tests testing]]
4 | [com.wsscode.misc.uuid :as uuid]))
5 |
6 | (deftest cljc-random-uuid-test
7 | (is (uuid? (uuid/cljc-random-uuid))))
8 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/comb/test/template.clj:
--------------------------------------------------------------------------------
1 | (ns comb.test.template
2 | (:use clojure.test)
3 | (:require [comb.template :as t] :reload))
4 |
5 | (deftest eval-test
6 | (is (= (t/eval "foo") "foo"))
7 | (is (= (t/eval "<%= 10 %>") "10"))
8 | (is (= (t/eval "<%= x %>" {:x "foo"}) "foo"))
9 | (is (= (t/eval "<%=x%>" {:x "foo"}) "foo"))
10 | (is (= (t/eval "<% (doseq [x xs] %>foo<%= x %> <% ) %>" {:xs [1 2 3]})
11 | "foo1 foo2 foo3 ")))
12 |
13 | (deftest fn-test
14 | (is (= ((t/fn [x] "foo<%= x %>") "bar")
15 | "foobar")))
16 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/contajners/core_test.clj:
--------------------------------------------------------------------------------
1 | (ns contajners.core-test
2 | (:require [clojure.test :as t]
3 | [contajners.core :as c]))
4 |
5 | (t/deftest docker-tests
6 | (let [image "busybox:musl"
7 | client (c/client {:engine :docker
8 | :version "v1.41"
9 | :category :images
10 | :conn {:uri "unix:///var/run/docker.sock"}})]
11 | (t/testing "pull an image"
12 | (c/invoke client
13 | {:op :ImageCreate
14 | :params {:fromImage image}})
15 | (let [images (c/invoke client {:op :ImageList})]
16 | (t/is (contains? (->> images
17 | (mapcat :RepoTags)
18 | (into #{}))
19 | image)))
20 | (c/invoke client
21 | {:op :ImageDelete
22 | :params {:name image}}))))
23 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/cprop/smoke_test.clj:
--------------------------------------------------------------------------------
1 | (ns cprop.smoke-test
2 | (:require [clojure.test :as t :refer [deftest is]]
3 | [cprop.core]
4 | [cprop.source :refer [from-env]]))
5 |
6 | (deftest from-env-test
7 | (println (:cprop-env (from-env))))
8 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/crispin/core_test.clj:
--------------------------------------------------------------------------------
1 | (ns crispin.core-test
2 | (:require [clojure.test :refer [deftest is testing]]
3 | [crispin.core :as cfg]))
4 |
5 | (deftest crispin.core-test
6 | (testing "config from multiple sources"
7 | (do
8 | (cfg/load-custom-cfg! "test-resources/lib_tests/crispin" "crispin-test-custom-cfg.edn")
9 | (System/setProperty "crispintest.value" "yes")
10 | (System/setProperty "crispin" "test-resources/lib_tests/crispin/crispin-test-cfg.edn")
11 | (let [c (cfg/cfg)]
12 | ; something from the environment
13 | (is (not-empty (cfg/sget c :path)))
14 | ; things from the resource named by the :crispin property
15 | (is (= "pina colada" (cfg/sget-in c [:likes 0])))
16 | (is (= 3.14 (cfg/nget-in c [:crispintest :pi])))
17 | ; something from system properties
18 | (is (true? (cfg/bget-in c [:crispintest :value])))
19 | ; something from load-custom-cfg! file
20 | (is (= :bar (:foo c))))
21 | (System/clearProperty "crispintest.value")
22 | (System/clearProperty "crispin"))))
23 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/crispin/crispin-test-cfg.edn:
--------------------------------------------------------------------------------
1 | {:crispintest {:pi 3.14}
2 | :likes ["pina colada" "getting caught in the rain"]}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/crispin/crispin-test-custom-cfg.edn:
--------------------------------------------------------------------------------
1 | {:foo :bar}
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/datalog/parser/test/util.cljc:
--------------------------------------------------------------------------------
1 | (ns datalog.parser.test.util
2 | (:require [#?(:clj clojure.test :cljs cljs.test) :as test]))
3 |
4 | #?(:clj
5 | (defmethod test/assert-expr 'thrown-msg? [msg form]
6 | (let [[_ match & body] form]
7 | `(try ~@body
8 | (test/do-report {:type :fail, :message ~msg, :expected '~form, :actual nil})
9 | (catch Throwable e#
10 | (let [m# (.getMessage e#)]
11 | (test/do-report
12 | {:type (if (= ~match m#) :pass :fail)
13 | :message ~msg
14 | :expected '~form
15 | :actual e#}))
16 | e#)))))
17 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/datalog/unparser_test.clj:
--------------------------------------------------------------------------------
1 | (ns datalog.unparser-test
2 | (:require [datalog.unparser :refer [unparse]]
3 | [datalog.parser :refer [parse]]
4 | [clojure.test :refer [deftest testing is] :as test])
5 | (:use [datalog.unparser]))
6 |
7 | (let [q '[:find (sum ?balance-before) ?balance-before
8 | :in $before $after $txn $txs
9 | :where
10 | [(= ?balance-before 42)]]]
11 | (deftest unparse-roundtrip-test
12 | (testing "Datahike query unparsing."
13 | (is (= q (unparse (parse q)))))))
14 |
15 |
16 |
17 | (comment ;; TODO
18 | (let [q '[:find ?foo ?baz
19 | :in $before $after
20 | :where
21 | [(= ?balance-before 42)]
22 | (not [?foo :bar ?baz])]]
23 | (deftest unparse-roundtrip-test
24 | (testing "Datahike query unparsing."
25 | (is (= q (unparse (parse q))))))))
26 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/doric/test/readme.clj:
--------------------------------------------------------------------------------
1 | (ns doric.test.readme
2 | (:use [clojure.test]
3 | [doric.test.doctest]))
4 |
5 | (deftest readme
6 | (run-doctests markdown-tests "README.md"))
7 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/environ/test/runner.cljs:
--------------------------------------------------------------------------------
1 | (ns environ.test.runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [environ.core-test]))
4 |
5 | (doo-tests 'environ.core-test)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/exoscale/coax_cljs_test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns exoscale.coax.cljs-test-runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [exoscale.coax-test]))
4 |
5 | (doo-tests 'exoscale.coax-test)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/expound/print_length_test.cljc:
--------------------------------------------------------------------------------
1 | (ns expound.print-length-test
2 | (:require [clojure.test :as ct :refer [is deftest testing]]
3 | [clojure.spec.alpha :as s]
4 | [expound.alpha]
5 | [clojure.string :as string]))
6 |
7 | (def the-value (range 10))
8 | ;; Fails on the last element of the range
9 | (def the-spec (s/coll-of #(< % 9)))
10 | (def the-explanation (s/explain-data the-spec the-value))
11 |
12 | (deftest print-length-test
13 | (testing "Expound works even in face of a low `*print-length*` and `*print-level*`, without throwing exceptions.
14 | See https://github.com/bhb/expound/issues/217"
15 | (doseq [length [1 5 100 *print-length*]
16 | level [1 5 100 *print-level*]
17 | ;; Note that the `is` resides outside of the `binding`. Else test output itself can be affected.
18 | :let [v (binding [*print-length* length
19 | *print-level* level]
20 | (with-out-str
21 | (expound.alpha/printer the-explanation)))]]
22 | ;; Don't make a particularly specific test assertion, since a limited print-length isn't necessarily realistic/usual:
23 | (is (not (string/blank? v))))))
24 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/expound/problems_test.cljc:
--------------------------------------------------------------------------------
1 | (ns expound.problems-test
2 | (:require [clojure.test :as ct :refer [is deftest use-fixtures]]
3 | [clojure.spec.alpha :as s]
4 | [expound.problems :as problems]
5 | [expound.test-utils :as test-utils]))
6 |
7 | (use-fixtures :once
8 | test-utils/check-spec-assertions
9 | test-utils/instrument-all)
10 |
11 | (s/def :highlighted-value/nested-map-of (s/map-of keyword? (s/map-of keyword? keyword?)))
12 |
13 | (s/def :highlighted-value/city string?)
14 | (s/def :highlighted-value/address (s/keys :req-un [:highlighted-value/city]))
15 | (s/def :highlighted-value/house (s/keys :req-un [:highlighted-value/address]))
16 |
17 | (s/def :annotate-test/div-fn (s/fspec
18 | :args (s/cat :x int? :y pos-int?)))
19 | (defn my-div [x y]
20 | (assert (pos? (/ x y))))
21 |
22 | (deftest annotate-test
23 | (is (= {:expound/in [0]
24 | :val '(0 1)
25 | :reason "Assert failed: (pos? (/ x y))"}
26 | (-> (s/explain-data (s/coll-of :annotate-test/div-fn) [my-div])
27 | problems/annotate
28 | :expound/problems
29 | first
30 | (select-keys [:expound/in :val :reason])))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/expound/specs_test.cljc:
--------------------------------------------------------------------------------
1 | (ns expound.specs-test
2 | (:require [expound.specs]
3 | [clojure.spec.alpha :as s]
4 | [clojure.test :as ct :refer [is deftest use-fixtures]]
5 | [expound.test-utils :as test-utils]
6 | [expound.alpha :as expound]))
7 |
8 | (use-fixtures :once
9 | test-utils/check-spec-assertions
10 | test-utils/instrument-all)
11 |
12 | (deftest provided-specs
13 | (binding [s/*explain-out* (expound/custom-printer {:print-specs? false})]
14 | (is (= "-- Spec failed --------------------
15 |
16 | 1
17 |
18 | should be a keyword with no namespace
19 |
20 | -------------------------
21 | Detected 1 error
22 | "
23 | (s/explain-str :expound.specs/simple-kw 1)))
24 | (doseq [kw expound.specs/public-specs]
25 | (is (some? (s/get-spec kw)) (str "Failed to find spec for keyword " kw))
26 | (is (some? (expound/error-message kw)) (str "Failed to find error message for keyword " kw)))))
27 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/expound/test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns expound.test-runner
2 | (:require [jx.reporter.karma :refer-macros [#_run-tests #_run-all-tests]]
3 | [expound.alpha-test]
4 | [expound.paths-test]
5 | [expound.printer-test]
6 | [expound.print-length-test]
7 | [expound.problems-test]
8 | [expound.test-utils]
9 | [expound.specs-test]
10 | [expound.spell-spec-test]))
11 |
12 | (enable-console-print!)
13 |
14 | ;; runs all tests in all namespaces
15 | ;; This is what runs by default
16 | (defn ^:export run-all [karma]
17 | (jx.reporter.karma/run-all-tests karma))
18 |
19 | ;; runs all tests in all namespaces - only namespaces with names matching
20 | ;; the regular expression will be tested
21 | ;; You can use this by changing client.args in karma.conf.js
22 | #_(defn ^:export run-all-regex [karma]
23 | (run-all-tests karma #".*-testquot;))
24 |
25 | ;; runs all tests in the given namespaces
26 | ;; You can use this by changing client.args in karma.conf.js
27 | #_(defn ^:export run [karma]
28 | (run-tests karma 'expound.alpha-test))
29 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/failjure/runner.cljs:
--------------------------------------------------------------------------------
1 | (ns failjure.runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [failjure.test-core]))
4 |
5 | (doo-tests 'failjure.test-core)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/helins/binf/test/float.cljc:
--------------------------------------------------------------------------------
1 | ;; This Source Code Form is subject to the terms of the Mozilla Public
2 | ;; License, v. 2.0. If a copy of the MPL was not distributed with this
3 | ;; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4 |
5 |
6 | (ns helins.binf.test.float
7 |
8 | {:author "Adam Helins"}
9 |
10 | (:require [clojure.test.check.clojure-test :as tc.ct]
11 | [clojure.test.check.generators :as tc.gen]
12 | [clojure.test.check.properties :as tc.prop]
13 | [helins.binf.float :as binf.float]))
14 |
15 |
16 | ;;;;;;;;;;
17 |
18 |
19 | (defn nan?
20 |
21 | ""
22 |
23 | [x]
24 |
25 | #?(:clj (Double/isNaN x)
26 | :cljs (js/isNaN x)))
27 |
28 |
29 |
30 | (defn f=
31 |
32 | ""
33 |
34 | [x-1 x-2]
35 |
36 | (if (nan? x-1)
37 | (nan? x-2)
38 | (= x-1
39 | x-2)))
40 |
41 |
42 | ;;;;;;;;;;
43 |
44 |
45 | #?(:clj (tc.ct/defspec f32
46 |
47 | (tc.prop/for-all [x (tc.gen/fmap unchecked-float
48 | tc.gen/double)]
49 | (f= x
50 | (binf.float/from-b32 (binf.float/b32 x))))))
51 |
52 |
53 |
54 | (tc.ct/defspec f64
55 |
56 | (tc.prop/for-all [x tc.gen/double]
57 | (f= x
58 | (binf.float/from-b64 (binf.float/b64 x)))))
59 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/helins/binf/test/string.cljc:
--------------------------------------------------------------------------------
1 | ;; This Source Code Form is subject to the terms of the Mozilla Public
2 | ;; License, v. 2.0. If a copy of the MPL was not distributed with this
3 | ;; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4 |
5 |
6 | (ns helins.binf.test.string
7 |
8 | ""
9 |
10 | {:author "Adam Helinski"}
11 |
12 | (:require [clojure.test :as t]
13 | #?@(:bb [] :clj [clojure.test.check.clojure-test :as tc.ct])
14 | [clojure.test.check.generators :as tc.gen]
15 | [clojure.test.check.properties :as tc.prop]
16 | [helins.binf.string :as binf.string]))
17 |
18 |
19 | ;;;;;;;;;;
20 |
21 |
22 | (def string
23 | "²é&\"'(§è!çà)-aertyuiopqsdfhgklmwcvbnùµ,;:=")
24 |
25 |
26 |
27 | (t/deftest main
28 |
29 | (t/is (= string
30 | (-> string
31 | binf.string/encode
32 | binf.string/decode))))
33 |
34 |
35 |
36 | #_(tc.ct/defspec gen
37 |
38 | (tc.prop/for-all [string tc.gen/string]
39 | (= string
40 | (-> string
41 | binf.string/encode
42 | binf.string/decode))))
43 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/hugsql/babashka_test.clj:
--------------------------------------------------------------------------------
1 | (ns hugsql.babashka-test
2 | (:require [babashka.fs :as fs]
3 | [clojure.test :as t :refer [deftest is]]
4 | [hugsql.core :as hugsql]))
5 |
6 | (def sql-file (fs/file (fs/parent *file*) "characters.sql"))
7 | (hugsql/def-db-fns sql-file)
8 | (hugsql/def-sqlvec-fns sql-file)
9 |
10 | (declare characters-by-ids-specify-cols-sqlvec)
11 |
12 | (deftest sqlvec-test
13 | (is (= ["select name, specialty from characters\nwhere id in (?,?)" 1 2]
14 | (characters-by-ids-specify-cols-sqlvec {:ids [1 2], :cols ["name" "specialty"]}))))
15 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/jasentaa/collections_test.cljc:
--------------------------------------------------------------------------------
1 | (ns jasentaa.collections-test
2 | (:require
3 | #?(:clj [clojure.test :refer :all]
4 | :cljs [cljs.test :refer-macros [deftest is testing]])
5 | [jasentaa.collections :refer [join]]
6 | [jasentaa.position :refer [augment-location]]))
7 |
8 | (deftest check-join-on-lists
9 | (is (= [1 2] (join 1 2)))
10 | (is (= [3 4] (join [3] 4)))
11 | (is (= [5 6] (join 5 [6])))
12 | (is (= [7 8] (join [7] [8])))
13 | (is (= [9] (join 9 nil)))
14 | (is (= [0] (join nil 0)))
15 | (is (= [] (join nil nil))))
16 |
17 | (deftest check-join-on-records
18 | (let [[a b] (augment-location "ab")]
19 | (is (= [a] (join a nil)))
20 | (is (= [b] (join nil b)))
21 | (is (= [a b] (join a b)))))
22 |
23 | (deftest check-join-on-strings
24 | (is (= "ab" (join "a" "b")))
25 | (is (= "a" (join "a" nil)))
26 | (is (= "b" (join nil "b"))))
27 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/jasentaa/runner.cljs:
--------------------------------------------------------------------------------
1 | (ns jasentaa.runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [jasentaa.parser.basic-test]
4 | [jasentaa.parser.combinators-test]
5 | [jasentaa.collections-test]
6 | [jasentaa.position-test]
7 | [jasentaa.worked-example-1]
8 | [jasentaa.worked-example-2]))
9 |
10 | (doo-tests 'jasentaa.parser.basic-test
11 | 'jasentaa.parser.combinators-test
12 | 'jasentaa.collections-test
13 | 'jasentaa.position-test
14 | 'jasentaa.worked-example-1
15 | 'jasentaa.worked-example-2)
16 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/jasentaa/test_helpers.cljc:
--------------------------------------------------------------------------------
1 | (ns jasentaa.test-helpers
2 | (:require [jasentaa.monad :as m]
3 | [jasentaa.position :as p]))
4 |
5 | (defn test-harness [parser input]
6 | (let [result (first (parser (p/augment-location input)))]
7 | (if (empty? result)
8 | (m/failure)
9 | (list [(if (char? (-> result first :char))
10 | (-> result first :char)
11 | (mapv :char (first result)))
12 | (p/strip-location (fnext result))]))))
13 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/lambdaisland/regal/malli_test.cljc:
--------------------------------------------------------------------------------
1 | (ns lambdaisland.regal.malli-test
2 | (:require [clojure.test :refer [deftest is ]]
3 | [malli.core :as m]
4 | [malli.error :as me]
5 | [lambdaisland.regal.malli :as regal-malli]))
6 |
7 | (def malli-opts {:registry {:regal regal-malli/regal-schema}})
8 |
9 | (def form [:+ "y"])
10 |
11 | (def schema (m/schema [:regal form] malli-opts))
12 |
13 | (deftest regal-malli-test
14 | (is (= [:regal [:+ "y"]] (m/form schema)))
15 | (is (= :regal (m/type schema)))
16 | (is (= true (m/validate schema "yyy")))
17 | (is (= ["Pattern does not match"] (me/humanize (m/explain schema "xxx")))))
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/lambdaisland/regal/parse_test.cljc:
--------------------------------------------------------------------------------
1 | (ns lambdaisland.regal.parse-test
2 | (:require [clojure.test :refer [deftest testing is are]]
3 | [lambdaisland.regal :as regal]
4 | [lambdaisland.regal.parse :as parse]))
5 |
6 | (deftest parse-whitespace-test
7 | (is (= [:class " " :tab :newline :vertical-tab :form-feed :return]
8 | (regal/with-flavor :java
9 | (parse/parse-pattern "\\s"))))
10 |
11 | (is (= :whitespace
12 | (regal/with-flavor :ecma
13 | (parse/parse-pattern "\\s"))))
14 |
15 | (is (= [:not " " :tab :newline :vertical-tab :form-feed :return]
16 | (regal/with-flavor :java
17 | (parse/parse-pattern "\\S"))))
18 |
19 | (is (= :non-whitespace
20 | (regal/with-flavor :ecma
21 | (parse/parse-pattern "\\S")))))
22 |
23 | (deftest ^{:kaocha/pending
24 | "Needs a special case in the regex generation code"}
25 | whitespace-round-trip
26 | (is (= "\\s"
27 | (regal/with-flavor :java
28 | (regal/pattern
29 | (parse/parse-pattern "\\s"))))))
30 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/loom/test/label.cljc:
--------------------------------------------------------------------------------
1 | (ns loom.test.label
2 | (:require [loom.graph :as g]
3 | [loom.label :as lbl]
4 | #?@(:clj [[clojure.test :refer (deftest is)]]))
5 | #?@(:cljs [(:require-macros [cljs.test :refer (deftest is)])]))
6 |
7 | (deftest labeled-graph-test
8 | (let [g (g/digraph [1 2] [2 3] [2 4] [3 5] [4 5])
9 | lg1 (-> g
10 | (lbl/add-label 1 "node label")
11 | (lbl/add-label 2 3 "edge label"))
12 | lg2 (-> (g/digraph)
13 | (lbl/add-labeled-nodes
14 | 1 "node label 1"
15 | 2 "node label 2")
16 | (lbl/add-labeled-edges
17 | [1 2] "edge label 1"
18 | [2 3] "edge label 2"))]
19 | (is (= "node label" (lbl/label lg1 1)))
20 | (is (= "edge label" (lbl/label lg1 2 3)))
21 | (is (= #{1 2 3} (set (g/nodes lg2))))
22 | (is (= #{[1 2] [2 3]} (set (g/edges lg2))))
23 | (is (= "node label 1" (lbl/label lg2 1)))
24 | (is (= "node label 2" (lbl/label lg2 2)))
25 | (is (= "edge label 1" (lbl/label lg2 1 2)))
26 | (is (= "edge label 2" (lbl/label lg2 2 3)))))
27 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/loom/test/runner.cljs:
--------------------------------------------------------------------------------
1 | (ns loom.test.runner
2 | (:require [cljs.test :as test]
3 | [doo.runner :refer-macros [doo-all-tests doo-tests]]
4 | loom.test.alg
5 | loom.test.alg-generic
6 | loom.test.attr
7 | loom.test.derived
8 | loom.test.flow
9 | loom.test.graph
10 | loom.test.label))
11 |
12 | (doo-all-tests)
13 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/markdown/nbb_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns nbb-runner
2 | (:require [clojure.string :as str]
3 | [clojure.test :refer [run-tests]]
4 | [nbb.classpath :as cp]))
5 |
6 | (cp/add-classpath (str/join ":" ["src/cljs" "src/cljc" "test"]))
7 |
8 | (require '[markdown.md-test])
9 |
10 | (run-tests 'markdown.md-test)
11 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/markdown/runner.cljs:
--------------------------------------------------------------------------------
1 | (ns markdown.runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [markdown.md-test]))
4 |
5 | (doo-tests 'markdown.md-test)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/bar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/bar
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/bbb.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/bbb.bz2
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/foo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/foo
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/ggg.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/ggg.gz
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/ggg.tar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/ggg.tar
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/ggg.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/ggg.zip
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/xxx.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/xxx.xz
--------------------------------------------------------------------------------
/test-resources/lib_tests/me/raynes/testfiles/zip-slip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/me/raynes/testfiles/zip-slip.zip
--------------------------------------------------------------------------------
/test-resources/lib_tests/medley/test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns medley.test-runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [medley.core-test]))
4 |
5 | (doo-tests 'medley.core-test)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/meta_merge/test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns meta-merge.test-runner
2 | (:require [doo.runner :refer-macros [doo-tests]]
3 | [meta-merge.core-test]))
4 |
5 | (doo-tests 'meta-merge.core-test)
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/missing/test/assertions_test.cljc:
--------------------------------------------------------------------------------
1 | (ns missing.test.assertions-test
2 | (:require
3 | [clojure.test :refer [deftest testing is] :as t]
4 | [missing.test.old-methods]
5 | [missing.test.assertions]))
6 |
7 | (deftest a-test
8 | (testing "FIXME, I fail."
9 | 1))
10 |
11 | (deftest another-test
12 | (testing (is 1)))
13 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/missing/test/old_methods.cljc:
--------------------------------------------------------------------------------
1 | (ns missing.test.old-methods
2 | (:require [clojure.test :as t]
3 | [missing.test.assertions :refer [register!]]))
4 |
5 | (defmethod t/report #?(:clj :begin-test-var
6 | :cljs [::t/default :begin-test-var]) [_]
7 | ;; BB-TEST-PATCH: remove message to not disturb test output for other libs
8 | #_(println "Begin test var."))
9 |
10 | (defmethod t/report #?(:clj :end-test-var
11 | :cljs [::t/default :end-test-var]) [_]
12 | ;; BB-TEST-PATCH: remove message to not disturb test output for other libs
13 | #_(println "End test var."))
14 |
15 | (register! {:throw? false})
16 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/multigrep/core_test.clj:
--------------------------------------------------------------------------------
1 | (ns multigrep.core-test
2 | (:require [clojure.java.io :as io]
3 | [clojure.test :refer [deftest is testing]]
4 | [multigrep.core :as grep])
5 | (:import (java.io StringReader)))
6 |
7 | (def lorem-ipsum "Lorem ipsum dolor sit amet, consectetur adipiscing
8 | elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
9 | Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
10 | aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
11 | in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
12 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
13 | officia deserunt mollit anim id est laborum.")
14 |
15 | (deftest single-regex-test
16 | (testing "single regex, single text source"
17 | (let [result (grep/grep #"t[,.]" (StringReader. lorem-ipsum))]
18 | (is (= [1 2 4 6] (mapv :line-number result))))))
19 |
20 | (deftest multi-regex-test
21 | (testing "multiple regexes, multiple text sources"
22 | (let [result (grep/grep [#"t[,.]" #"s\s"] [(StringReader. lorem-ipsum) (io/resource "multigrep/haiku.txt")])]
23 | (is (= 8 (count result))))))
24 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/multigrep/haiku.txt:
--------------------------------------------------------------------------------
1 | haikus are easy
2 | but sometimes they make no sense
3 | refrigerator
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/orchestra/expound_test.cljc:
--------------------------------------------------------------------------------
1 | (ns orchestra.expound-test
2 | (:require #?@(:clj [[clojure.test :refer :all]
3 | [clojure.spec.alpha :as s]
4 | [orchestra.spec.test :as st]
5 | [orchestra.core :refer [defn-spec]]]
6 |
7 | :cljs [[cljs.test
8 | :refer-macros [deftest testing is use-fixtures]]
9 | [cljs.spec.alpha :as s]
10 | [orchestra-cljs.spec.test :as st]
11 | [orchestra.core :refer-macros [defn-spec]]])
12 |
13 | [expound.alpha :as expound]))
14 |
15 | (defn-spec instrument-fixture any?
16 | [f fn?]
17 | (st/unstrument)
18 | (st/instrument)
19 | (binding [s/*explain-out* expound/printer]
20 | (f)))
21 | (use-fixtures :each instrument-fixture)
22 |
23 | (defn-spec expound' true?
24 | [blah string?]
25 | true)
26 |
27 | (deftest expound
28 | (testing "Pretty printed"
29 | (try
30 | (expound' 42)
31 | (catch #?(:clj RuntimeException :cljs :default) e
32 | (is (some? (-> (ex-data e)
33 | s/explain-out
34 | with-out-str
35 | (clojure.string/includes? "-- Spec failed --"))))))))
36 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/orchestra/make_fns.cljc:
--------------------------------------------------------------------------------
1 | (ns orchestra.make-fns
2 | (:require #?@(:clj [[clojure.spec.alpha :as s]]
3 | :cljs [[cljs.spec.alpha :as s]])))
4 |
5 | #?(:clj (defmacro make-fns [fn-count]
6 | (let [cljs? (-> &env :ns some?)]
7 | `(do
8 | ~@(for [i (range fn-count)]
9 | (let [fn-name (symbol (str "fn-" i))]
10 | `(do
11 | (defn ~fn-name []
12 | (str ~fn-name))
13 | (~(if cljs?
14 | 'cljs.spec.alpha/fdef
15 | 's/fdef) ~fn-name))))))))
16 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/orchestra/many_fns.cljc:
--------------------------------------------------------------------------------
1 | (ns orchestra.many-fns
2 | (:require #?@(:clj [[clojure.test :refer :all]
3 | [clojure.spec.alpha :as s]
4 | [orchestra.spec.test :as st]
5 | [orchestra.core :refer [defn-spec]]
6 | [orchestra.make-fns :refer [make-fns]]]
7 |
8 | :cljs [[cljs.test
9 | :refer-macros [deftest testing is use-fixtures]]
10 | [cljs.spec.alpha :as s]
11 | [orchestra-cljs.spec.test :as st]
12 | [orchestra.core :refer-macros [defn-spec]]
13 | [orchestra.make-fns :refer-macros [make-fns]]])))
14 |
15 | (make-fns 2000)
16 |
17 | (deftest many-fns
18 | (st/instrument))
19 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/orchestra/reload_test.cljc:
--------------------------------------------------------------------------------
1 | (ns orchestra.reload-test
2 | (:require [clojure.test :refer :all]
3 | [clojure.spec.alpha :as s]
4 | [orchestra.spec.test :refer :all]))
5 |
6 | (deftest in-place-reload
7 | (testing "Positive"
8 | (dotimes [_ 5]
9 | (require 'orchestra.spec.test :reload-all))))
10 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/bench.cljc:
--------------------------------------------------------------------------------
1 | (ns portal.bench
2 | #?(:cljs (:refer-clojure :exclude [simple-benchmark]))
3 | #?(:cljs (:require-macros portal.bench)))
4 |
5 | (defn now []
6 | #?(:clj (System/currentTimeMillis)
7 | :cljs (.now js/Date)))
8 |
9 | (defmacro simple-benchmark
10 | [bindings expr iterations & {:keys [print-fn] :or {print-fn 'println}}]
11 | (let [expr-str (pr-str expr)]
12 | `(let ~bindings
13 | (dotimes [_# ~iterations] ~expr)
14 | (let [start# (now)
15 | ret# (dotimes [_# ~iterations] ~expr)
16 | end# (now)
17 | elapsed# (- end# start#)]
18 | (~print-fn (str ~iterations " runs, " elapsed# " msecs, " ~expr-str))))))
19 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/e2e.clj:
--------------------------------------------------------------------------------
1 | (ns portal.e2e
2 | (:require [portal.colors :as c]))
3 |
4 | (defn step [code]
5 | (binding [*out* *err*]
6 | (println "\n==> Enter to execute:" code "\n"))
7 | (read-line)
8 | (prn code))
9 |
10 | (def pane-titles '("Alice" "Mad Hatter" "The Cake is a Lie"))
11 |
12 | (defn options []
13 | {:portal.colors/theme
14 | (rand-nth (keys (dissoc c/themes ::c/vs-code-embedded)))
15 | :portal.launcher/window-title
16 | (rand-nth pane-titles)})
17 |
18 | (defn -main [& args]
19 | (if (= (first args) "web")
20 | (step '(require '[portal.web :as p]))
21 | (step '(require '[portal.api :as p])))
22 | (step `(do (add-tap #'p/submit)
23 | (p/open ~(options))))
24 | (step '(tap> :hello-world))
25 | (step '(p/clear))
26 | (step '(require '[examples.data :refer [data]]))
27 | (step '(tap> data))
28 | (step '(p/clear))
29 | (step '(remove-tap #'p/submit))
30 | (step '(tap> :hello-world))
31 | (step '(p/eval-str "(js/alert 1)"))
32 | (step '(p/close)))
33 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/jvm_test.clj:
--------------------------------------------------------------------------------
1 | (ns portal.jvm-test
2 | (:require [clojure.test :refer [deftest is]]
3 | [portal.api :as p]
4 | [portal.runtime.browser :as browser]
5 | [portal.runtime.index :as index]
6 | [portal.runtime.jvm.client :as client]))
7 |
8 | (defn- headless-chrome-flags [url]
9 | ["--headless" "--disable-gpu" url])
10 |
11 | (defn- open [f]
12 | (with-redefs [browser/flags f] (p/open)))
13 |
14 | (deftest e2e-jvm
15 | (reset! index/testing? true)
16 | (when-let [portal (open headless-chrome-flags)]
17 | (with-redefs [client/timeout 60000]
18 | (reset! portal 0)
19 | (is (= @portal 0))
20 | (swap! portal inc)
21 | (is (= @portal 1))))
22 | (p/close))
23 |
24 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/runtime/fs_test.cljc:
--------------------------------------------------------------------------------
1 | (ns portal.runtime.fs-test
2 | (:require [clojure.test :refer [deftest is]]
3 | [portal.runtime.fs :as fs]))
4 |
5 | (deftest fs
6 | (is (some? (fs/slurp "deps.edn")))
7 | (let [deps (fs/join (fs/cwd) "deps.edn")]
8 | (is (= (fs/exists deps) deps)))
9 | (is (some? (fs/home)))
10 | (is (some? (seq (fs/paths))))
11 | (is (contains?
12 | (into #{} (fs/list (fs/cwd)))
13 | (fs/join (fs/cwd) "deps.edn")))
14 | (let [dir (str "target/" (gensym))
15 | file (str dir "/" (gensym))]
16 | (fs/mkdir dir)
17 | (fs/spit file "hello")
18 | (is (= (fs/slurp file) "hello"))
19 | (fs/rm dir)
20 | (is (nil? (fs/exists file)))
21 | (is (nil? (fs/exists dir)))))
22 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/test_planck.cljs:
--------------------------------------------------------------------------------
1 | (ns portal.test-planck
2 | (:require [cljs.test :refer [run-tests]]
3 | [planck.core :refer [exit]]
4 | [portal.runtime.cson-test]))
5 |
6 | (defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
7 | (when-not (cljs.test/successful? m)
8 | (exit 1)))
9 |
10 | (defn -main []
11 | (run-tests 'portal.runtime.cson-test))
12 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/test_runner.clj:
--------------------------------------------------------------------------------
1 | (ns portal.test-runner
2 | (:require [clojure.test :refer [run-tests]]
3 | [portal.jvm-test]
4 | [portal.runtime.cson-test]
5 | [portal.runtime.fs-test]))
6 |
7 | (defn -main []
8 | (let [{:keys [fail error]}
9 | (run-tests 'portal.jvm-test
10 | 'portal.runtime.cson-test
11 | 'portal.runtime.fs-test)]
12 | (shutdown-agents)
13 | (System/exit (+ fail error))))
14 |
15 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/portal/test_runner.cljs:
--------------------------------------------------------------------------------
1 | (ns portal.test-runner
2 | (:require [cljs.test :refer [run-tests]]
3 | [portal.runtime.cson-test]
4 | [portal.runtime.fs-test]))
5 |
6 | (defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
7 | (when-not (cljs.test/successful? m)
8 | (.exit js/process 1)))
9 |
10 | (defn -main []
11 | (run-tests 'portal.runtime.cson-test
12 | 'portal.runtime.fs-test))
13 |
14 | (-main)
15 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/selmer/benchmark.clj:
--------------------------------------------------------------------------------
1 | (ns selmer.benchmark)
2 |
3 | (def user (repeat 10 [{:name "test"}]))
4 |
5 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/slingshot/test_test.clj:
--------------------------------------------------------------------------------
1 | (ns slingshot.test-test
2 | (:require [clojure.test :refer :all]
3 | [slingshot.slingshot :refer [throw+]]
4 | [slingshot.test]))
5 |
6 | (deftest test-slingshot-test-macros
7 | (is (thrown+? string? (throw+ "test")))
8 | (is (thrown+-with-msg? string? #"th" (throw+ "test" "hi there"))))
9 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/spartan/spec_test.clj:
--------------------------------------------------------------------------------
1 | (ns spartan.spec-test
2 | (:require [clojure.test :as t :refer [deftest is]]))
3 |
4 | (time (require '[spartan.spec]))
5 | (require '[clojure.spec.alpha :as s])
6 |
7 | (deftest spec-test
8 | (time (s/explain (s/cat :i int? :s string?) [1 :foo]))
9 | (is (time (s/conform (s/cat :i int? :s string?) [1 "foo"]))))
10 |
11 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/swirrl/dogstatsd_test.clj:
--------------------------------------------------------------------------------
1 | (ns swirrl.dogstatsd-test
2 | (:require [swirrl.dogstatsd :as sut]
3 | [swirrl.dogstatsd.specs]
4 | [clojure.test :refer [deftest is testing]]
5 | [clojure.spec.test.alpha :as st]))
6 |
7 | (st/instrument)
8 |
9 | (deftest basic-invocation-tests
10 | (testing "Basic metric procedure calls run without error"
11 | (let [client (sut/configure {:endpoint "localhost:8111"})]
12 |
13 | (sut/increment! client ::increment)
14 | (sut/increment! client ::increment 10)
15 | (sut/decrement! client ::decrement)
16 |
17 | (sut/histogram! client ::histogram 10)
18 | (sut/distribution! client ::distribution 10)
19 | (sut/set! client ::set "a-value")
20 | (sut/event! client "event title" "some text here" {})
21 |
22 | (is true))))
23 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/table/width_test.clj:
--------------------------------------------------------------------------------
1 | (ns table.width-test
2 | (:require [clojure.test :refer :all]
3 | [table.width :refer :all]))
4 |
5 | (defn auto-resize [widths]
6 | (binding [*width* (delay 238)] (auto-resize-widths widths)))
7 |
8 | ; for max width of 238, 76 is the max-width-per-field for 3 fields
9 | (deftest test-auto-resize-allows-over-max-field-to-get-width-from-under-max-fields
10 | (is
11 | (=
12 | [74 74 80]
13 | (auto-resize [74 74 88]))))
14 |
15 | (deftest test-auto-resize-leaves-under-max-fields-alone
16 | (is
17 | (=
18 | [10 10 15]
19 | (auto-resize [10 10 15]))))
20 |
21 | (deftest test-auto-resize-reduces-all-max-fields
22 | (is
23 | (=
24 | [76 76 76]
25 | (auto-resize [80 100 94]))))
26 |
27 | (deftest ensure-valid-width-when-getting-zero-from-stty-detect
28 | (is (= 100 (table.width/ensure-valid-width 0))))
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/any.html:
--------------------------------------------------------------------------------
1 | {% for p in products %}
2 | {% if any p.a p.b p.c p.d p.e p.f p.g %}{% endif %}
3 | {% endfor %}
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/base-custom.html:
--------------------------------------------------------------------------------
1 | Base template.
2 | [# block body #]
3 | [# block content #][# endblock #]
4 | [# endblock #]
5 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/base.html:
--------------------------------------------------------------------------------
1 | Base template.
2 | {% block body %}
3 | {% block content %}{% endblock %}
4 | {% endblock %}
5 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/child-custom.html:
--------------------------------------------------------------------------------
1 | [# extends "templates/base-custom.html" #]
2 |
3 | [# block content #]
4 | <p>[(content)]</p>
5 | [# endblock content #]
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/child.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/base.html" %}
2 |
3 | {% block content %}
4 | <p>{{content}}</p>
5 | {% endblock content %}
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/elif.html:
--------------------------------------------------------------------------------
1 | {% if foo %} foo!
2 | {% elif bar %} bar!
3 | {% elif baz %} baz!
4 | {% else %} else!
5 | {% endif %}
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/if.html:
--------------------------------------------------------------------------------
1 | {% if foo %}
2 | <h1>FOO!</h1>
3 | {% endif %}
4 |
5 |
6 | {% if bar %}
7 | <h1>BAR!</h1>
8 | {% else %}
9 | <h1>NOT BAR!</h1>
10 | {% endif %}
11 |
12 | {% if user-id %}
13 | "foo"
14 | {% else %}
15 | "bar"
16 | {% endif %}
17 |
18 | {% if nested %}
19 | {% if inner %}
20 | inner
21 | {% endif %}
22 | {% endif %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/ifequal.html:
--------------------------------------------------------------------------------
1 | {% ifequal foo "bar" %}
2 | <h1>equal!</h1>
3 | {% endifequal %}
4 |
5 | {% ifequal foo bar %}
6 | <h1>equal!</h1>
7 | {% endifequal %}
8 |
9 | {% ifequal baz "test" %}
10 | <h1>equal!</h1>
11 | {% else %}
12 | <p>not equal</p>
13 | {% endifequal %}
14 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/include.html:
--------------------------------------------------------------------------------
1 | {% include "templates/snippet.html" with url="/page?name=foo" gridid="abc" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/another-parent.html:
--------------------------------------------------------------------------------
1 | <div>{% block content %}{% endblock %}</div>
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/base.html:
--------------------------------------------------------------------------------
1 | <html>
2 | <body>{% block header %}
3 | original header
4 | {% endblock %}
5 |
6 | <div>{% block content %}{% endblock %}</div>
7 |
8 | {% block footer %}
9 | {% endblock %}</body>
10 | </html>
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/blocks.html:
--------------------------------------------------------------------------------
1 | {% block foo %}Here's the default text of foo {{foo}}{% endblock %}
2 | {% block bar %}Here's the default text of bar {{bar}}{% endblock %}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/child-a.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/base.html" %}
2 | {% block header %}
3 | <h1>child-a header</h1>
4 | <<{{block.super}}>>
5 | {% endblock %}
6 |
7 | {% block footer %}
8 | <p>footer</p>
9 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/child-b.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/child-a.html" %}
2 | {% block header %}
3 | B header
4 | {{block.super}}
5 | {% endblock %}
6 |
7 | {% block content %}
8 | Some content
9 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/child-c.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/include-head.html" %}
2 | {% block my-script %}<script src="my/C/script" />{% endblock %}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/child-d.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/include-head.html" %}
2 | {% block my-script %}<script src="my/D/script" />{% endblock %}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/child.html:
--------------------------------------------------------------------------------
1 | {%ifequal greeting name%} {{greeting}} {{name}} {%endifequal%}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/foo.html:
--------------------------------------------------------------------------------
1 | Hello, {{name}}!
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/home.html:
--------------------------------------------------------------------------------
1 | {% block home %}
2 | <h1>Hello {{user}}</h1>
3 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include-head.html:
--------------------------------------------------------------------------------
1 | {% include "templates/inheritance/include/head.html" %}
2 | <body>my-body</body>
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include-in-block.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/another-parent.html" %}
2 |
3 | {% block content %}
4 | {% include "templates/inheritance/include/snippet.html" %}
5 | {% endblock %}
6 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include-snippet.html:
--------------------------------------------------------------------------------
1 | base tempate {% include "templates/inheritance/include/snippet.html" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/another-grandparent.html:
--------------------------------------------------------------------------------
1 | foo {% include "templates/inheritance/include/parent.html" with my-variable="default-value" my-other-variable="other-default-value" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/another-parent.html:
--------------------------------------------------------------------------------
1 | foo {% include "templates/inheritance/include/child.html" with my-variable="default-value" my-other-variable="another-default-value"%}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/child.html:
--------------------------------------------------------------------------------
1 | baz {{ my-variable }} {{ my-other-variable }}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/grandparent.html:
--------------------------------------------------------------------------------
1 | foo {% with my-variable="some-value" my-other-variable="some-other-value"%}{% include "templates/inheritance/include/parent.html" %}{% endwith %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/head.html:
--------------------------------------------------------------------------------
1 | <head>{% block my-script %}{% endblock %}</head>
2 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/parent.html:
--------------------------------------------------------------------------------
1 | bar {% include "templates/inheritance/include/child.html" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/include/snippet.html:
--------------------------------------------------------------------------------
1 | hello
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/inherit-a.html:
--------------------------------------------------------------------------------
1 | start a
2 | {% block a %}{% endblock %}
3 | stop a
4 |
5 | {% block content %}{% endblock %}
6 |
7 | {% include "templates/inheritance/foo.html" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/inherit-b.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/inherit-a.html" %}
2 | {% block a %}
3 | start b
4 | {% block b %}{% endblock %}
5 | stop b
6 | {% endblock %}
7 |
8 | {% block content %}content{% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/inherit-c.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/inherit-b.html" %}
2 |
3 | {% block b %}
4 | start c
5 | stop c
6 | {% endblock %}
7 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/parent.html:
--------------------------------------------------------------------------------
1 | {% include "templates/inheritance/child.html" with name = "Jane Doe" greeting="Hello!" %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/register.html:
--------------------------------------------------------------------------------
1 | {% block register %}
2 | <form action="/register" method="POST">
3 | <label for="id">user id</label>
4 | <input id="id" name="id" type="text"></input>
5 | <input pass="pass" name="pass" type="text"></input>
6 | <input type="submit" value="register">
7 | </form>
8 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/super-a.html:
--------------------------------------------------------------------------------
1 | <html>
2 | <head></head>
3 | <body>
4 | {% block hello %}
5 | Hello
6 | {% endblock %}
7 | </body>
8 | </html>
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/super-b.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/super-a.html" %}
2 | {% block hello %}
3 | {{ block.super }} World
4 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/inheritance/super-c.html:
--------------------------------------------------------------------------------
1 | {% extends "templates/inheritance/super-b.html" %}
2 | {% block hello %}
3 | {{ block.super }}Cruel World
4 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/my-include-child.html:
--------------------------------------------------------------------------------
1 | {{ foo }}{{ bar }}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/my-include.html:
--------------------------------------------------------------------------------
1 | main template {% include "templates/my-include-child.html" %} body
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/nested-for.html:
--------------------------------------------------------------------------------
1 | <html>
2 | <body>
3 | <ul>
4 | {% for user in users %}
5 | <li>
6 | {% for i in user %}
7 | {{i.name}}
8 | {% endfor %}
9 | </li>
10 | {% endfor %}
11 | </ul>
12 | </body>
13 | </html>
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/no_tag.html:
--------------------------------------------------------------------------------
1 | {
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/numerics.html:
--------------------------------------------------------------------------------
1 | {% for p in ps %}
2 | {% if p.a > p.b %}
3 | {% endif %}
4 | {% endfor %}
5 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/raw.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/babashka/babashka/6e11a192afdf0269a78957e3c0d49da9956d3b5f/test-resources/lib_tests/templates/raw.html
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/safe.html:
--------------------------------------------------------------------------------
1 | {% safe %}{% block foo %}{% if bar %}{{unsafe}}{% endif %}{% endblock %}{% endsafe %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/snippet.html:
--------------------------------------------------------------------------------
1 | {{url}} - {{gridid}}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/tags-test.html:
--------------------------------------------------------------------------------
1 | {% with total=business.employees|count %}{{ total }}{% endwith %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/validation-test.html:
--------------------------------------------------------------------------------
1 | {% extends "app/views/templates/base.html" %}
2 | {% block body %}
3 | <div class="container-fluid">
4 | <div class="centered-form">
5 | <form action="{{context}}/login" class="form-signin" method="POST">
6 | <h3 class="form-signin-heading">{{title|upper}}</h3>
7 | {% if formid|str|date %}<input type="hidden" id="formid" name="formid" value="{{formid}}" />{% endif %}
8 | <input class="input-block-level" id="userid" name="userid" placeholder="T-id" type="text">
9 | <input class="input-block-level" id="pass" name="pass" placeholder="Password" type="password">
10 | <input class="btn btn-primary" type="submit" value="Sign in">
11 | </form>
12 | </div>
13 | </div>
14 | {% endblock %}
--------------------------------------------------------------------------------
/test-resources/lib_tests/templates/verbatim.html:
--------------------------------------------------------------------------------
1 | {% verbatim %}
2 | <p class="name">{%=file.name%}</p>
3 | {% endverbatim %}
4 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/test_check/smoke_test.clj:
--------------------------------------------------------------------------------
1 | (ns test-check.smoke-test)
2 |
3 | (require '[clojure.test :as t]
4 | '[clojure.test.check :as tc]
5 | '[clojure.test.check.generators :as gen]
6 | '[clojure.test.check.properties :as prop])
7 |
8 | (def property
9 | (prop/for-all [v (gen/vector gen/small-integer)]
10 | (let [s (sort v)]
11 | (and (= (count v) (count s))
12 | (or (empty? s)
13 | (apply <= s))))))
14 |
15 | ;; test our property
16 | (t/deftest smoke-test
17 | (t/is (= {:result true, :pass? true, :num-tests 100}
18 | (select-keys (tc/quick-check 100 property)
19 | [:result :pass? :num-tests]))))
20 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/testdoc/style/code_first_test.clj:
--------------------------------------------------------------------------------
1 | (ns testdoc.style.code-first-test
2 | (:require
3 | [clojure.string :as str]
4 | [clojure.test :as t]
5 | [testdoc.style.code-first :as sut]))
6 |
7 | (defn- lines
8 | [ls]
9 | (str/join "\n" ls))
10 |
11 | (t/deftest parse-doc-test
12 | (t/are [expected in] (= expected (sut/parse-doc (lines in)))
13 | '[[a b]], ["a" ";; => b"]
14 | '[[(a b) c]], ["(a" "b)" ";; => c"]
15 | '[[(a b) c]], ["head" "(a" "b)" ";; => c"]
16 | '[[a b] [c d]], ["a" ";; => b" "c" ";; => d"]
17 | '[], ["a"]
18 | '[[a b]], ["a" ";; => b" "c"]
19 | '[[a b]], ["a" ";; => b" ";; => c"]
20 | '[[a (b c)]], ["a" ";; => [b" ";; => c]"]))
21 |
22 | (t/deftest parse-doc-with-meta-test
23 | (let [ret (sut/parse-doc (lines ["" "a" ";; => 6" "c" ";; => :d"]))]
24 | (t/is (= '[[a 6] [c :d]] ret))
25 | (t/is (= 2 (-> ret first meta :testdoc.string/line)))
26 | (t/is (= 4 (-> ret second meta :testdoc.string/line)))))
27 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/testdoc/style/repl_test.clj:
--------------------------------------------------------------------------------
1 | (ns testdoc.style.repl-test
2 | (:require
3 | [clojure.string :as str]
4 | [clojure.test :as t]
5 | [testdoc.style.repl :as sut]))
6 |
7 | (defn- lines
8 | [ls]
9 | (str/join "\n" ls))
10 |
11 | (t/deftest parse-doc-test
12 | (t/are [expected in] (= expected (sut/parse-doc (lines in)))
13 | '[[a b]], ["=> a" "b"]
14 | '[[(a b) c]], ["=> (a" "=> b)" "c"]
15 | '[[a b] [c d]], ["=> a" "b" "=> c" "d"]
16 | '[], ["=> a"]
17 | '[[a b]], ["=> a" "b" "=> c"]
18 | '[[a b]], ["=> a" "b" "c"]
19 | '[[a (b c)]], ["=> a" "[b" "c]"]))
20 |
21 | (t/deftest parse-doc-with-meta-test
22 | (let [ret (sut/parse-doc (lines ["" "=> a" "6" "=> c" ":d"]))]
23 | (t/is (= '[[a 6] [c :d]] ret))
24 | (t/is (= 2 (-> ret first meta :testdoc.string/line)))
25 | (t/is (= 4 (-> ret second meta :testdoc.string/line)))))
26 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/vault/client/secret-fixture-logical.edn:
--------------------------------------------------------------------------------
1 | {"identities" {:batman "Bruce Wayne"
2 | :captain-marvel "Carol Danvers"}}
3 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/vault/secrets/secret-fixture-kvv2.edn:
--------------------------------------------------------------------------------
1 | {"mount/data/identities"
2 | {:data {:batman "Bruce Wayne"
3 | :captain-marvel "Carol Danvers"}}
4 | "mount/metadata/identities"
5 | {:created_time "2018-03-22T02:24:06.945319214Z"
6 | :current_version 1
7 | :max_versions 0
8 | :oldest_version 0
9 | :updated_time "2018-03-22T02:36:43.986212308Z"
10 | :versions {:1 {:created_time "2018-03-22T02:24:06.945319214Z"
11 | :deletion_time ""
12 | :destroyed false}}}}
13 |
--------------------------------------------------------------------------------
/test-resources/lib_tests/version_clj/via_use_test.clj:
--------------------------------------------------------------------------------
1 | (ns version-clj.via-use-test
2 | "Babashka was failing when loading version-clj via `use` and `require`->`:refer`.
3 | The unit tests transcribed from version-clj address the require->refer case.
4 | This set of tests spot-check that loading via use works for version-clj."
5 | (:require [clojure.test :refer [deftest is]]))
6 |
7 | (use 'version-clj.core)
8 |
9 | ;; BB-TEST-PATCH: This test doesn't exist upstream
10 | (deftest sanity-test
11 | (is (= [[1 0 0] ["snapshot"]] (version->seq "1.0.0-SNAPSHOT")))
12 | (is (= 0 (version-compare "1.0" "1.0.0")))
13 | (is (= -1 (version-compare "1.0-alpha5" "1.0-alpha14")))
14 | (is (= 1 (version-compare "1.0-alpha14" "1.0-alpha5"))) )
15 |
--------------------------------------------------------------------------------
/test-resources/line_number_test_test.clj:
--------------------------------------------------------------------------------
1 | (ns line-number-test-test
2 | (:require [clojure.test :refer [is deftest run-tests]]))
3 |
4 | (deftest test-is
5 | (is false))
6 |
7 | (run-tests 'line-number-test-test)
8 |
--------------------------------------------------------------------------------
/test-resources/local-dep/deps.edn:
--------------------------------------------------------------------------------
1 | {:paths ["src"]}
2 |
--------------------------------------------------------------------------------
/test-resources/local-dep/src/local_dep.clj:
--------------------------------------------------------------------------------
1 | (ns local-dep)
2 |
3 | (def local-dep-var :foo)
4 |
--------------------------------------------------------------------------------
/test-resources/pod:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | dir=$(dirname "$0")
4 |
5 | export BABASHKA_POD=true
6 |
7 | if [[ $BABASHKA_TEST_ENV == "native" ]]; then
8 | exec "${dir}"/../bb "${dir}"/pod.clj
9 | else
10 | exec clojure -M:test-pod
11 | fi
12 |
--------------------------------------------------------------------------------
/test-resources/pod_tests/bootleg.clj:
--------------------------------------------------------------------------------
1 | (ns pod-tests.bootleg
2 | (:require [pod.retrogradeorbit.bootleg.utils :as utils]))
3 |
4 | (defn -main [& args]
5 | (-> [:div
6 | [:p "Test"]]
7 | (utils/convert-to :html)))
8 |
--------------------------------------------------------------------------------
/test-resources/pod_tests/local.clj:
--------------------------------------------------------------------------------
1 | (ns pod-tests.local
2 | (:require [pod.test-pod :as pod]))
3 |
4 | (defn -main [& args]
5 | (println (pod/add-sync 40 2)))
6 |
--------------------------------------------------------------------------------
/test-resources/posix-file-attributes.txt:
--------------------------------------------------------------------------------
1 | 42
2 |
--------------------------------------------------------------------------------
/test-resources/script_with_overlapping_opts.clj:
--------------------------------------------------------------------------------
1 | (prn *command-line-args*)
2 |
--------------------------------------------------------------------------------
/test-resources/symlink-adjacent-bb:
--------------------------------------------------------------------------------
1 | adjacent_bb/medley.bb
--------------------------------------------------------------------------------
/test-resources/task_scripts/tasks.clj:
--------------------------------------------------------------------------------
1 | (ns tasks
2 | "This is task ns docstring.")
3 |
4 | (defn -main
5 | "Main docstring"
6 | [& args]
7 | args)
8 |
9 | (defn foo
10 | "Foo docstring"
11 | []
12 | :foo)
13 |
--------------------------------------------------------------------------------
/test-resources/task_test_scripts/task_test.clj:
--------------------------------------------------------------------------------
1 | (ns task-test)
2 |
3 | (defn task-test-fn []
4 | :task-test-fn)
5 |
--------------------------------------------------------------------------------
/test-resources/test.csv:
--------------------------------------------------------------------------------
1 | Adult,87727
2 | Elderly,43914
3 | Child,33411
4 | Adolescent,29849
5 | Infant,15238
6 | Newborn,10050
7 | In Utero,1198
8 |
--------------------------------------------------------------------------------
/test-resources/text_normalizer_test.clj:
--------------------------------------------------------------------------------
1 | (import '[java.text Normalizer Normalizer$Form])
2 |
3 | (defn normalize [text]
4 | (Normalizer/normalize text Normalizer$Form/NFC))
5 |
6 | (def s (str "cafe" \u0301))
7 |
8 | (assert (> (count s) (count (normalize s))))
9 |
--------------------------------------------------------------------------------
/test-resources/unicode_test.clj:
--------------------------------------------------------------------------------
1 | (prn "λ⚙️中文")
2 | "λ⚙️中文"
3 |
4 |
--------------------------------------------------------------------------------
/test/babashka/agent_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.agent-test
2 | (:require
3 | [babashka.test-utils :as test-utils]
4 | [clojure.edn :as edn]
5 | [clojure.test :as t :refer [deftest is]]))
6 |
7 | (deftest agent-binding-conveyance-test
8 | (let [prog
9 | "(def ^:dynamic *foo* 1) (def a (agent nil)) (binding [*foo* 2] (send-off a (fn [_] *foo*))) (await a) @a"]
10 | (is (= 2 (edn/read-string (test-utils/bb nil prog))))))
11 |
--------------------------------------------------------------------------------
/test/babashka/cheshire_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.cheshire-test
2 | (:require
3 | [babashka.test-utils :as test-utils]
4 | [cheshire.core :as json]
5 | [clojure.test :as test :refer [deftest is]]))
6 |
7 | (deftest cheshire-encode-test
8 | (is (instance? java.time.Instant
9 | (java.time.Instant/parse
10 | (:created-at
11 | (json/parse-string
12 | (test-utils/bb "-e" "(require '[cheshire.core :as c]
13 | '[cheshire.generate :as cg]
14 | '[clojure.walk :as walk])
15 | (import (java.time Instant))
16 |
17 | (cg/add-encoder Instant
18 | (fn [obj writer]
19 | (cg/encode-str (str obj) writer)))
20 |
21 | (def data {:created-at (Instant/now)})
22 |
23 | (println (c/generate-string data))")
24 | true))))))
25 |
--------------------------------------------------------------------------------
/test/babashka/classes_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.classes-test
2 | (:require [babashka.test-utils :as tu]
3 | [clojure.edn :as edn]
4 | [clojure.test :as t :refer [deftest is testing]]))
5 |
6 | (defn bb
7 | [& args]
8 | (edn/read-string (apply tu/bb nil (map pr-str args))))
9 |
10 | (deftest all-classes-test
11 | (is (true? (bb '(let [classes (babashka.classes/all-classes)] (and (seq classes) (every? class? classes)))))))
12 |
--------------------------------------------------------------------------------
/test/babashka/file_var_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.file-var-test
2 | (:require
3 | [babashka.test-utils :as tu]
4 | [clojure.java.io :as io]
5 | [clojure.string :as str]
6 | [clojure.test :as t :refer [deftest is testing]]))
7 |
8 | (defn bb [input & args]
9 | (apply tu/bb (when (some? input) (str input)) (map str args)))
10 |
11 | (deftest file-var-test
12 | (let [[f1 f2 f3 f4]
13 | (str/split (bb nil "--prn" "--classpath" "test/babashka/scripts"
14 | "test/babashka/scripts/file_var.bb")
15 | #"\n")]
16 | (is (str/ends-with? f1 "file_var_classpath.bb"))
17 | (is (str/ends-with? f2 "loaded_by_file_var.bb"))
18 | (is (str/ends-with? f3 "file_var.bb"))
19 | (is (str/ends-with? f4 "file_var.bb")))
20 | (testing "file var uses absolute path"
21 | (is (str/includes?
22 | (bb nil "--prn" (io/file "test" ".." "test"
23 | "babashka" "scripts" "simple_file_var.bb"))
24 | ".."))))
25 |
--------------------------------------------------------------------------------
/test/babashka/http_connection_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.http-connection-test
2 | (:require
3 | [babashka.test-utils :as tu]
4 | [clojure.string :as str]
5 | [clojure.test :as t :refer [deftest is]]))
6 |
7 | (defn bb [& args]
8 | (apply tu/bb nil (map str args)))
9 |
10 | (deftest ^:flaky open-connection-test
11 | (is (try (= "\"1\"" (str/trim (bb "-e" "
12 | (require '[cheshire.core :as json])
13 | (let [conn ^java.net.HttpURLConnection (.openConnection (java.net.URL. \"https://postman-echo.com/get?foo=1\"))]
14 | (.setConnectTimeout conn 1000)
15 | (.setRequestProperty conn \"Content-Type\" \"application/json\") ;; nonsensical, but to test if this method exists
16 | (.connect conn)
17 | (let [is (.getInputStream conn)
18 | err (.getErrorStream conn)
19 | response (json/decode (slurp is) true)]
20 | (-> response :args :foo)))
21 | ")))
22 | (catch Exception e
23 | (str/includes? (str e) "timed out")))))
24 |
--------------------------------------------------------------------------------
/test/babashka/impl/clojure/java/browse_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.java.browse-test
2 | #_(:require
3 | [babashka.test-utils :refer [bb]]
4 | [cheshire.core :as json]
5 | [clojure.test :refer [deftest is]]
6 | [org.httpkit.server :as http]))
7 |
8 | (def ^:dynamic *http-port* 1234)
9 |
10 | #_(deftest browse-url-test
11 | (let [p (promise)
12 | stop-server (http/run-server (fn [{:keys [query-string]}]
13 | (let [params (apply hash-map (mapcat #(.split % "=") (.split query-string "&")))]
14 | (deliver p params)
15 | {:status 200
16 | :content-type "application/json"
17 | :body (json/encode params)}))
18 | {:port *http-port*})]
19 | (try
20 | (bb nil
21 | (str "(clojure.java.browse/browse-url \"http://localhost:" *http-port* "?arg1=v1&arg2=v2\")"))
22 | (is (= {"arg1" "v1"
23 | "arg2" "v2"}
24 | (deref p 5000 ::timeout)))
25 | (finally (stop-server :timeout 1000)))))
26 |
--------------------------------------------------------------------------------
/test/babashka/impl/clojure/java/io_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.java.io-test
2 | (:require [babashka.test-utils :as test-utils]
3 | [clojure.edn :as edn]
4 | [clojure.test :as t :refer [deftest is]]))
5 |
6 | (defn bb [& args]
7 | (edn/read-string
8 | {:readers *data-readers*
9 | :eof nil}
10 | (apply test-utils/bb nil (map str args))))
11 |
12 | (deftest nio-coercion-test
13 | (is (true? (bb "
14 | (require '[clojure.java.io :as io])
15 |
16 | (extend-protocol io/Coercions
17 | java.nio.file.Path
18 | (as-file [this] (.toFile this))
19 | (as-url [this] (.. this (toFile) (toURL))))
20 |
21 | (def path (.toPath (io/file \".\")))
22 | ;; ^ this is a java.nio.file.Path
23 |
24 | (.exists (io/file path)) ;; true
25 | "))))
26 |
27 | (deftest string-as-file-test
28 | (is (true? (bb "
29 | (require '[clojure.java.io :as io])
30 |
31 | (instance? java.io.File (io/as-file \".\"))
32 | "))))
33 |
34 | (deftest string-as-url-test
35 | (is (true? (bb "
36 | (require '[clojure.java.io :as io])
37 |
38 | (let [url (io/as-url \"https://github.com/babashka/babashka\")]
39 | (and (= \"https\" (.getProtocol url))
40 | (= \"github.com\" (.getHost url))))
41 | "))))
42 |
--------------------------------------------------------------------------------
/test/babashka/impl/clojure/java/shell_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.java.shell-test
2 | (:require [babashka.main :as main]
3 | [babashka.test-utils :as test-utils]
4 | [clojure.string :as str]
5 | [clojure.test :as t :refer [deftest is testing]]))
6 |
7 |
8 | (deftest ^:skip-windows with-sh-env-test
9 | (is (= "\"BAR\""
10 | (str/trim (test-utils/bb nil "
11 | (-> (shell/with-sh-env {:FOO \"BAR\"}
12 | (shell/sh \"bash\" \"-c\" \"echo $FOO\"))
13 | :out
14 | str/trim)"))))
15 | (is (str/includes? (str/trim (test-utils/bb nil "
16 | (-> (shell/with-sh-dir \"logo\"
17 | (shell/sh \"ls\"))
18 | :out)"))
19 | "icon.svg")))
20 |
21 | (deftest ^:windows-only win-with-sh-env-test
22 | (when main/windows?
23 | (is (= "\"BAR\""
24 | (str/trim (test-utils/bb nil "
25 | (-> (shell/with-sh-env {:FOO \"BAR\"}
26 | (shell/sh \"cmd\" \"/c\" \"echo %FOO%\"))
27 | :out
28 | str/trim)"))))
29 | (is (str/includes? (str/trim (test-utils/bb nil "
30 | (-> (shell/with-sh-dir \"logo\"
31 | (shell/sh \"cmd\" \"/c\" \"dir\"))
32 | :out)"))
33 | "icon.svg"))))
34 |
--------------------------------------------------------------------------------
/test/babashka/impl/clojure/main_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.clojure.main-test
2 | (:require [babashka.test-utils :as tu]
3 | [clojure.edn :as edn]
4 | [clojure.test :as t :refer [deftest is testing]]))
5 |
6 | (def bb
7 | (comp edn/read-string tu/bb))
8 |
9 | (deftest with-read-known-test
10 | (testing ":unknown gets set to true"
11 | (is (true? (bb nil (pr-str '(binding [*read-eval* :unknown]
12 | (clojure.main/with-read-known *read-eval*)))))))
13 | (testing "other values don't change"
14 | (t/are [read-eval-value]
15 | (= read-eval-value
16 | (bb nil (str "(binding [*read-eval* " read-eval-value "]"
17 | " (clojure.main/with-read-known *read-eval*))")))
18 | false true 5)))
19 |
--------------------------------------------------------------------------------
/test/babashka/impl/server_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.server-test
2 | (:require [babashka.test-utils :as tu]
3 | [clojure.edn :as edn]
4 | [clojure.test :as t :refer [deftest is testing]]))
5 |
6 | (def bb
7 | (comp edn/read-string tu/bb))
8 |
9 | (deftest repl-read-test
10 | (testing "arbitrary values can be read"
11 | (t/are [input result]
12 | (= result (bb input "(let [request-exit (Object.)]
13 | (loop [acc []]
14 | (let [v (clojure.core.server/repl-read nil request-exit)]
15 | (if (= v request-exit)
16 | acc
17 | (recur (conj acc v))))))"))
18 | "abc" '[abc]
19 | "123 456" [123 456]
20 | "(nil ns/symbol (true))\n (+ 1 2 3)" '[(nil ns/symbol (true)) (+ 1 2 3)])))
21 |
--------------------------------------------------------------------------------
/test/babashka/impl/tasks_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.impl.tasks-test
2 | (:require [babashka.impl.tasks :as sut]
3 | [clojure.test :as t]))
4 |
5 | (t/deftest target-order-test
6 | (t/is (= '[quux bar foo]
7 | (sut/target-order
8 | {'foo {:depends ['bar 'quux]}
9 | 'bar {:depends ['quux]}}
10 | 'foo))))
11 |
12 | (t/deftest key-order-test
13 | (let [edn "{:tasks
14 | {;; Development tasks
15 | repl {:doc \"Starts an nrepl session with a reveal window\"
16 | :task (clojure \"-M:reveal-nrepl\")}
17 |
18 | ;; Testing
19 | watch-tests {:doc \"Watch tests and run on change\"
20 | :task (clojure \"-M:test -m kaocha.runner --watch\")}
21 | ;test
22 | #_{:doc \"Runs tests\"
23 | :task (clojure \"-M:test -m kaocha.runner\")}
24 | }}"]
25 | (t/is (= '[repl watch-tests] (sut/key-order edn)))))
26 |
--------------------------------------------------------------------------------
/test/babashka/java_security_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.java-security-test
2 | (:require
3 | [babashka.test-utils :as test-utils]
4 | [clojure.edn :as edn]
5 | [clojure.test :as test :refer [deftest is]]))
6 |
7 | (defn bb [expr]
8 | (edn/read-string (apply test-utils/bb nil [(str expr)])))
9 |
10 | (defn signature [algo]
11 | (clojure.walk/postwalk-replace {::algo algo}
12 | '(defn signature [^String s]
13 | (let [algorithm (java.security.MessageDigest/getInstance ::algo)
14 | digest (.digest algorithm (.getBytes s))
15 | size (get {"SHA-256" 64} ::algo 32)]
16 | (format (str "%0" size "x") (java.math.BigInteger. 1 digest))))))
17 |
18 | (deftest java-security-test
19 | (is (= "49f68a5c8493ec2c0bf489821c21fc3b" (bb (list 'do (signature "MD5") '(signature "hi")))))
20 | (is (= "c22b5f9178342609428d6f51b2c5af4c0bde6a42" (bb (list 'do (signature "SHA-1") '(signature "hi")))))
21 | (is (= "8f434346648f6b96df89dda901c5176b10a6d83961dd3c1ac88b59b2dc327aa4" (bb (list 'do (signature "SHA-256") '(signature "hi")))))
22 | (is (= "035afb1672de25549287fa4f6c108c1269c2a1d2390bf069520a95d1fec25e85" (bb (list 'do (signature "SHA-256") '(signature "654321f5fab07590a9e77e19ac4ccf53c8ab05f232b197432b62f2ec0677651bfc4c04"))))))
23 |
--------------------------------------------------------------------------------
/test/babashka/pprint_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.pprint-test
2 | (:require
3 | [babashka.test-utils :as test-utils]
4 | [clojure.string :as str]
5 | [clojure.test :as test :refer [deftest is]]))
6 |
7 | (defn bb [& args]
8 | (str/trim (apply test-utils/bb (map str args))))
9 |
10 | (deftest print-length-test
11 | (is (= "(0 1 2 3 4 5 6 7 8 9 ...)"
12 | (bb "-e" "(set! *print-length* 10) (clojure.pprint/pprint (range 20))"))))
13 |
14 | (deftest print-namespaced-map-test
15 | (test/testing
16 | "Testing disabling of printing namespace maps..."
17 | (is (= "{:a/x 1, :a/y 2, :a/z {:b/x 10, :b/y 20}}"
18 | (bb "-e" "(binding [*print-namespace-maps* false] (clojure.pprint/pprint {:a/x 1 :a/y 2 :a/z {:b/x 10 :b/y 20}}))"))))
19 | (test/testing
20 | "Testing manually enabling printing namespace maps..."
21 | (is (= "#:a{:x 1, :y 2, :z #:b{:x 10, :y 20}}"
22 | (bb "-e" "(binding [*print-namespace-maps* true] (clojure.pprint/pprint {:a/x 1 :a/y 2 :a/z {:b/x 10 :b/y 20}}))")))))
23 |
--------------------------------------------------------------------------------
/test/babashka/profile.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.profile
2 | (:require [babashka.main :as main]))
3 |
4 | (comment)
5 |
6 | ;; clojure -A:profile -e "(prn (loop [val 0 cnt 1000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val)))"
7 |
8 | (require '[clj-async-profiler.core :as prof])
9 |
10 | (defn -main [& options]
11 | (prof/profile (apply main/main options))
12 | (shutdown-agents))
13 |
--------------------------------------------------------------------------------
/test/babashka/sci_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.sci-test
2 | (:require
3 | [babashka.test-utils :as tu]
4 | [clojure.edn :as edn]
5 | [clojure.test :as t :refer [deftest is]]))
6 |
7 | (deftest sci-test
8 | (is (= 1 (edn/read-string
9 | (tu/bb nil "-e" "
10 | (ns foo)
11 | (require '[sci.core :as sci])
12 | (def x 1)
13 | (def ctx (sci/init {:namespaces {'foo (sci/copy-ns foo (sci/create-ns 'foo))}}))
14 | (sci/eval-string* ctx \"foo/x\")")))))
15 |
--------------------------------------------------------------------------------
/test/babashka/scripts/System.bb:
--------------------------------------------------------------------------------
1 | [(System/getProperty "user.dir")
2 | (System/getProperty "foo" "bar")
3 | (or (System/getenv "HOME") (System/getenv "HOMEPATH"))
4 | (System/getProperties)
5 | (System/getenv)]
6 |
--------------------------------------------------------------------------------
/test/babashka/scripts/check_var_names.bb:
--------------------------------------------------------------------------------
1 | (require '[clojure.string :as str])
2 | (let [ns-maps (->> (all-ns)
3 | (map (fn [nmspc] [(ns-name nmspc) (ns-publics nmspc)]))
4 | (into {})) ; a map of { ns-name {symbol var, ...}}
5 | ns-maps (update ns-maps 'user #(dissoc % '*input*))] ; *input* is a special case that we'll skip over
6 | (->>
7 | (for [[ns-nm _] ns-maps
8 | [sym vr] (ns-maps ns-nm)
9 | :let [{var-meta-ns :ns, var-meta-name :name} (meta vr)
10 | var-meta-ns-name (some-> var-meta-ns ns-name)]]
11 | ; build a seq of maps containing the ns/symbol from the ns and the ns/symbol from the var's metadata
12 | {:actual-ns ns-nm :actual-ns-symbol sym :var-meta-ns var-meta-ns-name :var-meta-name var-meta-name})
13 | ; and remove the matches
14 | (remove #(and (= (:actual-ns %) (:var-meta-ns %)) (= (:actual-ns-symbol %) (:var-meta-name %))))))
15 |
--------------------------------------------------------------------------------
/test/babashka/scripts/csv.bb:
--------------------------------------------------------------------------------
1 | (with-open [reader (io/reader (io/file "test-resources" "test.csv"))]
2 | (doall
3 | (csv/read-csv reader)))
4 |
--------------------------------------------------------------------------------
/test/babashka/scripts/divide_by_zero.bb:
--------------------------------------------------------------------------------
1 | (defn foo []
2 | (/ 1 0))
3 |
4 | (defn bar []
5 | (foo))
6 |
7 | (bar)
8 |
--------------------------------------------------------------------------------
/test/babashka/scripts/error.bb:
--------------------------------------------------------------------------------
1 | (/ 1 0)
2 |
--------------------------------------------------------------------------------
/test/babashka/scripts/file_var.bb:
--------------------------------------------------------------------------------
1 | (ns file-var
2 | (:require [clojure.java.io :as io]))
3 |
4 | (require '[file-var-classpath])
5 | (load-file (io/file "test" "babashka" "scripts" "loaded_by_file_var.bb"))
6 | (println *file*)
7 | (defn foo [])
8 | (println (:file (meta #'foo)))
9 |
--------------------------------------------------------------------------------
/test/babashka/scripts/file_var_classpath.bb:
--------------------------------------------------------------------------------
1 | (println *file*)
2 |
--------------------------------------------------------------------------------
/test/babashka/scripts/interrupt_handler.bb:
--------------------------------------------------------------------------------
1 | (require '[babashka.signal :as signal])
2 |
3 | (signal/add-interrupt-handler! :quit (fn [k] (println "bye1" k)))
4 | (signal/add-interrupt-handler! :quit2 (fn [k] (println "bye2" k)))
5 |
6 | (System/exit 0)
7 |
--------------------------------------------------------------------------------
/test/babashka/scripts/kill_child_processes.bb:
--------------------------------------------------------------------------------
1 | (ns killing-me-softly
2 | (:refer-clojure :exclude [descendants]))
3 |
4 | (import 'java.util.List)
5 |
6 | (set! *warn-on-reflection* true)
7 |
8 | (defn start-spawning [& args]
9 | (let [depth (or (System/getenv "DEPTH") "0")
10 | depth (Integer/parseInt depth)]
11 | (when-not (= 4 depth) ;; process at depth 4 dies immediately
12 | (let [pb (doto (ProcessBuilder. ^List args)
13 | (.inheritIO))
14 | _ (.put (.environment pb) "DEPTH"
15 | (str (inc depth)))
16 | proc (.start pb)]
17 | (if (= 0 depth) ;; the top process
18 | (do
19 | (Thread/sleep 500)
20 | (run! (fn [^java.lang.ProcessHandle handle]
21 | (prn (.pid handle))
22 | (.destroy handle))
23 | (let [handle (.toHandle proc)]
24 | (cons handle (iterator-seq (.iterator (.descendants handle)))))))
25 | (Thread/sleep 100000000))))))
26 |
27 | (start-spawning "./bb" *file*)
28 |
--------------------------------------------------------------------------------
/test/babashka/scripts/loaded_by_file_var.bb:
--------------------------------------------------------------------------------
1 | (ns loaded-by-file-var)
2 |
3 | (println *file*)
4 |
--------------------------------------------------------------------------------
/test/babashka/scripts/simple_file_var.bb:
--------------------------------------------------------------------------------
1 | [*file* (System/getProperty "babashka.file")]
2 |
--------------------------------------------------------------------------------
/test/babashka/scripts/socket_server.bb:
--------------------------------------------------------------------------------
1 | (require '[babashka.wait :as wait])
2 |
3 | (defn socket-loop [^java.net.ServerSocket server]
4 | (with-open [listener server]
5 | (loop []
6 | (with-open [socket (.accept listener)]
7 | (let [input-stream (.getInputStream socket)]
8 | (print (slurp input-stream))
9 | (flush)))
10 | (recur))))
11 |
12 | (defn start-server! [port]
13 | (let [server (java.net.ServerSocket. port)]
14 | (future (socket-loop server))
15 | server))
16 |
17 | (defn stop-server! [^java.net.ServerSocket server]
18 | (.close server))
19 |
20 | (let [server (start-server! 1777)]
21 | (prn (wait/wait-for-port "127.0.0.1" 1777))
22 | (stop-server! server))
23 |
--------------------------------------------------------------------------------
/test/babashka/scripts/tools.cli.bb:
--------------------------------------------------------------------------------
1 | (require '[clojure.tools.cli :refer [parse-opts]])
2 |
3 | (def cli-options
4 | [["-p" "--port PORT" "Port number"
5 | :default 80
6 | :parse-fn #(Integer/parseInt %)
7 | :validate [#(< 0 % 0x10000) "Must be a number between 0 and 65536"]]])
8 |
9 | (defn -main [& args]
10 | (let [{:keys [:options :summary]} (parse-opts args cli-options)
11 | port (:port options)]
12 | (case port
13 | 8080 {:result 8080}
14 | summary)))
15 |
16 | (-main "-p" "8080")
17 |
--------------------------------------------------------------------------------
/test/babashka/shutdown_hook_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.shutdown-hook-test
2 | {:no-doc true}
3 | #_(:import [java.nio.charset Charset])
4 | #_(:require [babashka.test-utils :as tu]
5 | [clojure.java.io :as io]
6 | [clojure.test :refer [deftest is]]))
7 |
8 | #_(defn- stream-to-string
9 | ([in] (stream-to-string in (.name (Charset/defaultCharset))))
10 | ([in enc]
11 | (with-open [bout (java.io.StringWriter.)]
12 | (io/copy in bout :encoding enc)
13 | (.toString bout))))
14 |
15 | #_(deftest shutdown-hook-test
16 |
17 | (let [script "(-> (Runtime/getRuntime) (.addShutdownHook (Thread. #(println \"bye\"))))"
18 | pb (ProcessBuilder. (if tu/jvm?
19 | ["lein" "bb" "-e" script]
20 | ["./bb" "-e" script]))
21 | process (.start pb)
22 | output (.getInputStream process)]
23 | (when-let [s (not-empty (stream-to-string (.getErrorStream process)))]
24 | (prn "ERROR:" s))
25 | (is (= "bye\n" (stream-to-string output)))))
26 |
--------------------------------------------------------------------------------
/test/babashka/transit_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.transit-test
2 | (:require
3 | [babashka.test-utils :as test-utils]
4 | [clojure.java.io :as io]
5 | [clojure.test :as t :refer [deftest is]]))
6 |
7 | (defn bb [& args]
8 | (apply test-utils/bb nil (map str args)))
9 |
10 | (deftest transit-test
11 | (is (= "\"foo\"\n{:a [1 2]}\n"
12 | (bb (format "(load-file \"%s\")"
13 | (test-utils/escape-file-paths (.getPath (io/file "test-resources" "babashka" "transit.clj"))))))))
14 |
--------------------------------------------------------------------------------
/test/babashka/udp_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.udp-test
2 | (:require [babashka.test-utils :as tu]
3 | [clojure.test :refer [deftest is]])
4 | (:import [java.io StringWriter]
5 | [java.net DatagramPacket DatagramSocket]))
6 |
7 | (set! *warn-on-reflection* true)
8 |
9 | (deftest udp-test
10 | (let [server (DatagramSocket. 8125)
11 | sw (StringWriter.)
12 | fut (future
13 | (let [buf (byte-array 1024)
14 | packet (DatagramPacket. buf 1024)
15 | _ (.receive server packet)
16 | non-zero-bytes (filter #(not (zero? %)) (.getData packet))
17 | non-zero-bytes (byte-array non-zero-bytes)]
18 | (binding [*out* sw]
19 | (println (String. non-zero-bytes "UTF-8")))))]
20 | (while (not (realized? fut))
21 | (tu/bb nil
22 | "-e" "(load-file (io/file \"test-resources\" \"babashka\" \"statsd.clj\"))"
23 | "-e" "(require '[statsd-client :as c])"
24 | "-e" "(c/increment :foo)"))
25 | (is (= ":foo:1|c\n" (tu/normalize (str sw))))))
26 |
--------------------------------------------------------------------------------
/test/babashka/yaml_test.clj:
--------------------------------------------------------------------------------
1 | (ns babashka.yaml-test
2 | (:require [babashka.test-utils :as test-utils]
3 | [clojure.string :as str]
4 | [clojure.test :refer [deftest is testing]]))
5 |
6 | (def simple-yaml-str "topic: [point 1, point 2]")
7 |
8 | (deftest yaml-edn-read-test
9 | (let [parsed-edn (test-utils/bb nil (str "(yaml/parse-string \"" simple-yaml-str "\")"))
10 | emitted-yaml (test-utils/bb parsed-edn "(yaml/generate-string *input*)")]
11 | (is (every? #(str/includes? emitted-yaml %) ["topic:" "point 1" "point 2"]))))
12 |
13 | (def round-trip-prog
14 | (str "(yaml/generate-string (read-string (pr-str (yaml/parse-string \"" simple-yaml-str "\"))))"))
15 |
16 | (deftest yaml-data-readers-test
17 | (let [emitted-yaml (test-utils/bb nil round-trip-prog)]
18 | (is (every? #(str/includes? emitted-yaml %) ["topic:" "point 1" "point 2"]))))
19 |
--------------------------------------------------------------------------------