aboutsummaryrefslogtreecommitdiffhomepage
path: root/test-project
diff options
context:
space:
mode:
authorBob Tolbert <bob@eyesopen.com>2025-08-16 16:56:45 -0500
committerCalvin Rose <calsrose@gmail.com>2025-08-19 19:46:52 -0500
commit95049dcec8589c4e62727574fa35e16f2ab5d159 (patch)
treea8fa8c29c347c37b3b63f8d454706d56aa9e26a1 /test-project
parentMissing unquote. (diff)
Brief: add more pre/post steps for janet-pm
1. Adding these extra steps allows more user control of the build process for complicated builds, including pre/post steps for build, install, test and clean. This also fixes #225, so that prebuild is only run before build. 2. Also removes redundant calls to build in the install hook since Janet's core install hook calls build first as well. Having this in spork too resulted in two calls to build when `janet-pm install` was run. 3. Adds local assertf in `janet-pm` for older Janet 4. Fixes existing problem in `janet-pm` where hardcoded syspath at the top-level is not honored when run as `(defn main ...`. This change adds a copy of the hardcoded paths inside defn main in a binscript, if main exists in the input.
Diffstat (limited to 'test-project')
-rw-r--r--test-project/.gitignore3
-rw-r--r--test-project/bin/bin-no-hardcode7
-rw-r--r--test-project/bin/bin-no-main3
-rw-r--r--test-project/bin/bin-with-main7
-rw-r--r--test-project/bin/bin-with-oneline-main5
-rw-r--r--test-project/hello/init.janet2
-rw-r--r--test-project/project.janet64
-rw-r--r--test-project/test/test-hello.janet1
8 files changed, 92 insertions, 0 deletions
diff --git a/test-project/.gitignore b/test-project/.gitignore
new file mode 100644
index 0000000..46a2378
--- /dev/null
+++ b/test-project/.gitignore
@@ -0,0 +1,3 @@
+/build
+/bundle
+/_build
diff --git a/test-project/bin/bin-no-hardcode b/test-project/bin/bin-no-hardcode
new file mode 100644
index 0000000..afc7740
--- /dev/null
+++ b/test-project/bin/bin-no-hardcode
@@ -0,0 +1,7 @@
+#!/usr/bin/env janet
+
+(import spork)
+
+(defn- main
+ [&]
+ (printf "hello")) \ No newline at end of file
diff --git a/test-project/bin/bin-no-main b/test-project/bin/bin-no-main
new file mode 100644
index 0000000..758e8ef
--- /dev/null
+++ b/test-project/bin/bin-no-main
@@ -0,0 +1,3 @@
+#!/usr/bin/env janet
+
+(print "hello") \ No newline at end of file
diff --git a/test-project/bin/bin-with-main b/test-project/bin/bin-with-main
new file mode 100644
index 0000000..afc7740
--- /dev/null
+++ b/test-project/bin/bin-with-main
@@ -0,0 +1,7 @@
+#!/usr/bin/env janet
+
+(import spork)
+
+(defn- main
+ [&]
+ (printf "hello")) \ No newline at end of file
diff --git a/test-project/bin/bin-with-oneline-main b/test-project/bin/bin-with-oneline-main
new file mode 100644
index 0000000..5616f3e
--- /dev/null
+++ b/test-project/bin/bin-with-oneline-main
@@ -0,0 +1,5 @@
+#!/usr/bin/env janet
+
+(import spork)
+
+(defn main [&] (printf "hello")) \ No newline at end of file
diff --git a/test-project/hello/init.janet b/test-project/hello/init.janet
new file mode 100644
index 0000000..bcbc349
--- /dev/null
+++ b/test-project/hello/init.janet
@@ -0,0 +1,2 @@
+(defn hello [arg]
+ (string/format "hello %s" arg)) \ No newline at end of file
diff --git a/test-project/project.janet b/test-project/project.janet
new file mode 100644
index 0000000..dfbf509
--- /dev/null
+++ b/test-project/project.janet
@@ -0,0 +1,64 @@
+(declare-project
+ :name "test-project"
+ :description "Janet project to test pre/post steps"
+ :version "0.0.1"
+ :dependencies [])
+
+(declare-source
+ :source @["hello"])
+
+(declare-binscript
+ :main "bin/bin-no-main"
+ :hardcode-syspath true
+ :is-janet true)
+
+(declare-binscript
+ :main "bin/bin-with-main"
+ :hardcode-syspath true
+ :is-janet true)
+
+(declare-binscript
+ :main "bin/bin-with-oneline-main"
+ :hardcode-syspath true
+ :is-janet true)
+
+(declare-binscript
+ :main "bin/bin-no-hardcode"
+ :hardcode-syspath false
+ :is-janet true)
+
+(task "pre-build" ["pre-build-test"])
+(task "post-build" ["post-build-test"])
+
+(task "pre-check" ["pre-check-test"])
+(task "post-check" ["post-check-test"])
+
+(task "pre-install" ["pre-install-test"])
+(task "post-install" ["post-install-test"])
+
+(task "pre-clean" ["pre-clean-test"])
+(task "post-clean" ["post-clean-test"])
+
+(task "pre-build-test" []
+ (printf "****** pre-build"))
+
+(task "post-build-test" []
+ (printf "****** post-build"))
+
+(task "pre-check-test" []
+ (printf "****** pre-check"))
+
+(task "post-check-test" []
+ (printf "****** post-check"))
+
+(task "pre-install-test" []
+ (printf "****** pre-install"))
+
+(task "post-install-test" []
+ (printf "****** post-install"))
+
+(task "pre-clean-test" []
+ (printf "****** pre-clean"))
+
+(task "post-clean-test" []
+ (printf "****** post-clean"))
diff --git a/test-project/test/test-hello.janet b/test-project/test/test-hello.janet
new file mode 100644
index 0000000..37e0473
--- /dev/null
+++ b/test-project/test/test-hello.janet
@@ -0,0 +1 @@
+(assert true)