## Always a good idea to use these when working with files
- `_fp`: Refers to a file path. The part after the last slash is a file name.
+
+- `_afp`: Refers to an absolute file path.
- `_dp`: Refers to a directory path. By convention, the value ends in a slash.
+- `_adp`: Refers to an absolute directory path.
+
- `_fn`: Refers to a file name. Value has no slashes.
- `_dn`: Refers to a directory name. Value has no slashes.
+++ /dev/null
---------------------------------------------------------------------------------
-javac/LabelList.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.ArrayList;
-
- public class LabelList extends ArrayList<Label> {}
-
---------------------------------------------------------------------------------
-javac/Node.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.Map;
-
- public interface Node extends Map<Label ,Object>{}
-
---------------------------------------------------------------------------------
-javac/NodeList.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.ArrayList;
-
- public interface NodeList extends ArrayList<Node> {}
-
---------------------------------------------------------------------------------
-javac/Production.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.function.Function;
-
- public interface Production extends Function<Label ,Node>{}
-
---------------------------------------------------------------------------------
-javac/ProductionList.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.ArrayList;
-
-public class ProductionList extends ArrayList<Production> {}
-
---------------------------------------------------------------------------------
-javac/TokenSet.java:
-package com.ReasoningTechnology.Ariadne;
-import java.util.HashSet;
-
-public class TokenSet extends HashSet<Token>{}
-
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# Removes all files found in the build directories. It asks no questions as to
-# how or why the files got there. Be especially careful with the 'shell' directory
-# if you added scripts to it for release with the project they will be deleted.
-# consider adding a `shell-leaf` directory instead of adding scripts to `shell`.
+# how or why the files got there. Be especially careful with the 'shell'
+# directory if you have authored scripts for release, add a `shell-leaf`
+# directory instead of putting them in `shell`.
# input guards
env_must_be="developer/tool/env"
# remove files
set -x
cd "$REPO_HOME"/developer
- rm -r scratch_pad/*
+ rm -r scratchpad/*
rm jvm/*
rm shell/*
set +x
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove all files created by make's call to `javac`
# input guards
# remove files
set -x
cd "$REPO_HOME"/developer
- rm -r scratch_pad/com/ReasoningTechnology/Ariadne
+ rm -r scratchpad/com/ReasoningTechnology/"$PROJECT"
set +x
echo "$(script_fn) done."
--- /dev/null
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+# remove all files made by `make`
+
+# input guards
+
+ env_must_be="developer/tool/env"
+ if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+ fi
+
+# wrappers to clean (this list space separated list will grow)
+
+ wrapper=$(shell_wrapper_list)
+
+# remove files
+
+ set -x
+ cd "$REPO_HOME"/developer
+ rm -r scratchpad/com/ReasoningTechnology/"$PROJECT"
+ rm jvm/"$PROJECT".jar
+ rm shell/{$wrapper}
+ set +x
+
+echo "$(script_fn) done."
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove files made by `make` and by `release`
# input guards
# things to clean
release_dir="$REPO_HOME"/release
- wrapper=build
+ wrapper=$(shell_wrapper_list)
# remove files
set -x
cd "$REPO_HOME"/developer
- rm -r scratch_pad/com/ReasoningTechnology/Ariadne
- rm jvm/Ariadne.jar
+ rm -r scratchpad/com/ReasoningTechnology/"$PROJECT"
+ rm jvm/"$PROJECT".jar
rm shell/{$wrapper}
- rm -f "$release_dir"/Ariadne.jar
+ rm -f "$release_dir"/"$PROJECT".jar
rm -f "$release_dir"/{$wrapper}
set +x
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# This script links the sources into the directory tree in parallel to the package.
+
+# Input guards
+
+ env_must_be="developer/tool/env"
+ if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+ fi
+
+ cd "$REPO_HOME"/developer
+
+# Link sources into the package tree
+
+ package_tree="scratchpad/com/ReasoningTechnology/$PROJECT"
+ mkdir -p "$package_tree"
+ echo "Package: $package_tree"
+
+ echo -n "Linking:"
+ for source_file in javac/*.java; do
+ echo -n " $(basename "$source_file")"
+ link_target="$package_tree/$(basename "$source_file")"
+ if [ ! -L "$link_target" ]; then
+ ln -s "$(realpath --relative-to="$package_tree" "$source_file")" "$link_target"
+ fi
+ done
+ echo "."
+
+echo "$(script_fp) done."
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
env_must_be="tool_shared/bespoke/env"
+ error=false
if [ "$ENV" != "$env_must_be" ]; then
echo "$(script_fp):: error: must be run in the $env_must_be environment"
- exit 1
+ error=true
fi
-
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
- echo "$script_name:: This script must be sourced, not executed."
- exit 1
+ echo "$script_afp:: This script must be sourced, not executed."
+ error=true
fi
+ if $error; then exit 1; fi
# so we can do the build
export CLASSPATH=\
"$REPO_HOME"/developer/jvm\
-:"$REPO_HOME"/developer/jvm/Ariadne.jar\
+:"$REPO_HOME"/developer/jvm/"$PROJECT".jar\
:"$JAVA_HOME"/lib\
:"$CLASSPATH"
# some feedback to show all went well
- export PROJECT="$PROJECT"_developer
+ export PROMPT_DECOR="$PROJECT"_developer
export ENV=$(script_fp)
echo ENV "$ENV"
cd "$REPO_HOME"/developer/
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
echo "Compiling files..."
set -x
- javac -d scratch_pad javac/*.java
+ javac -g -d scratchpad javac/*.java
set +x
if [ $? -ne 0 ]; then
echo "Compilation failed."
echo "Creating JAR file..."
set -x
- jar_file=jvm/Ariadne.jar
+ jar_file=jvm/"$PROJECT".jar
mkdir -p jvm
- jar cf $jar_file -C scratch_pad .
+ jar cf $jar_file -C scratchpad .
set +x
if [ $? -eq 0 ]; then
echo "JAR file created successfully: $jar_file"
echo "Creating shell wrappers..."
mkdir -p shell
# wrapper is a space separated list
- wrapper=build
+ wrapper=$(shell_wrapper_list)
for file in $wrapper;do
cat > shell/$file << EOL
#!/bin/bash
-java com/ReasoningTechnology/Ariadne/$file
+java com.ReasoningTechnology."$PROJECT".$file
EOL
chmod +x shell/$file
done
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
release_dir="$REPO_HOME/release"
shell_dir="$REPO_HOME/developer/shell"
- Ariadne_jar_fp="$REPO_HOME/developer/jvm/Ariadne.jar"
- wrapper=build
+ project_jar_fp="$REPO_HOME/developer/jvm/"$PROJECT".jar"
+ wrapper=$(shell_wrapper_list)
if [ ! -d "$release_dir" ]; then
echo "Starting release process..."
# Install the JAR file
- install_file "$Ariadne_jar_fp" "$release_dir" "ug+r"
+ install_file "$project_jar_fp" "$release_dir" "ug+r"
# Install shell wrappers
for wrapper in $wrapper; do
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+
+ env_must_be="developer/tool/env"
+ if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+ fi
+
+ cd "$REPO_HOME"/developer
+
+# list of classes that have main calls and get shell wrappers
+echo Mosaic
--- /dev/null
+
+Bash is inconsistent about returning the name of the running script in
+all scenarios (sourced, executed directly, from with in a function called
+by another function).
+
+1.
+
+BASH_SOURCE[0] was used because $0 did not work with sourced scripts (a
+fact that is leveraged for detecting when in a sourced script).
+
+2.
+
+However, this did not work in all scenarios:
+
+ read -r -d '' script_afp_string <<'EOF'
+ realpath "${BASH_SOURCE[0]}" 2>/dev/null
+ EOF
+
+ script_afp(){
+ eval "$script_afp_string"
+ }
+
+ export script_afp_string
+ export -f script_afp
+
+When `script_afp` was exported, used in another file, and used within a function
+in that other file, it reported `environment` for the script name at
+BASH_SOURCE[0]. In various call scenarios the actual script name appears at
+BASH_SOURCE[1] or even at BASH_SOURCE[2].
+
+3.
+
+As a stable alternative to having a script_afp function, place this line
+at the top of scripts that use the `script_XX` functions, or at the top
+of all scripts:
+
+ script_afp=realpath "${BASH_SOURCE[0]}"
+
+Then use $script_afp as a string within other functions. It will have stable
+value no matter the call structure.
body {
font-family: 'Noto Sans JP', Arial, sans-serif;
- background-color: hsl(0, 0%, 10%);
+ background-color: hsl(0, 0%, 0%);
color: hsl(42, 100%, 80%);
padding: 2rem;
margin: 0;
<h2>Reference</h2>
<ul>
- <li>Ariadne/<span class="description">aka REPO_HOME, top level owned by the project administrator.</span></li>
+ <li>Mosaic/<span class="description">aka REPO_HOME, top level owned by the project administrator.</span></li>
<ul>
<li>developer/ <span class="description">Workspace for the developer. Has the source code, build scripts, and development-specific tools.</span></li>
<ul>
<li>document/ <span class="description">Documentation on developing and building the project.</span></li>
<li>javac/ <span class="description">Java source files for compilation.</span></li>
<li>jvm/ <span class="description">Compiled Java bytecode files for the project, typically a jar for a Java project.</span></li>
- <li>scratch_pad/ <span class="description">Temporary storage typically for intermediate files created during build.</span></li>
+ <li>scratchpad/ <span class="description">Temporary storage typically for intermediate files created during build.</span></li>
<li>shell/ <span class="description">Shell scripts intended to be part of the project release. (These are not tools.)</span></li>
<li>tool/ <span class="description">Tools created by the developer, used for development tasks.</span></li>
</ul>
<li>document/ <span class="description">General documentation about the project.</span></li>
<li>release/ <span class="description">Release candidate for testing. Becomes the release on the release branch.</span></li>
- <li>scratch_pad/ <span class="description">Temporary storage for project administration tasks.</span></li>
+ <li>scratchpad/ <span class="description">Temporary storage for project administration tasks.</span></li>
<li>tester/ <span class="description">Workspace for the tester. Has the test bench, tests, and test scripts.</span></li>
<ul>
<li>document/ <span class="description">Test-specific documentation.</span></li>
- <li>test0/ <span class="description">Test case 0 environment and associated scripts.</span></li>
- <li>test1/ <span class="description">Test case 1 environment and associated scripts.</span></li>
- <li>test2/ <span class="description">Test case 2 environment and associated scripts.</span></li>
+ <li>javac/ <span class="description">The tests of the test bench sources.</span></li>
<li>tool/ <span class="description">Tools needed for testing and managing the test environment.</span></li>
</ul>
<li>tool/ <span class="description">Project administration specific tools.</span></li>
<p>When attempting to apply the <code>is-for</code> property in practice it
became apparent that using this sole property was insufficient. Consider
- the directories <code>deprecated/</code> and <code>scratch_pad/</code>. There is no
- <em>Mr. Deprecated</em> or <em>Mr. Scratch_Pad</em> who the contained
+ the directories <code>deprecated/</code> and <code>scratchpad/</code>. There is no
+ <em>Mr. Deprecated</em> or <em>Mr. Scratchpad</em> who the contained
files are for. (And this conclusion is not for the lack of trying. Even
mythological beings did not suffice as agents.) Rather than being for an
agent, the files collected in such a directory have in common a state of
being that was imposed upon them by decree. Perhaps the developer, has
decreed that a file is now deprecated, or a build script has decreed that
- it is a scratch_pad file. Such decrees are typically more dynamic than the
+ it is a scratchpad file. Such decrees are typically more dynamic than the
relationship properties. Also, these properties are disconnected from the
contents of the file. When, for example, a file has the property of being
for the java compiler, we gain some information about its contents. In the
#### 2. Developer
-2.1. From the Ariadne directory, run `> source env_developer` to set up the
+2.1. From the Mosaic directory, run `> source env_developer` to set up the
developer environment.
2.2. Use `> make` to build the project, and `> release` to copy relevant files
to `$REPO_HOME/release` for testing.
#### 3. Tester
-3.1. From the Ariadne directory, run `> source env_tester` to set up the tester
+3.1. From the Mosaic directory, run `> source env_tester` to set up the tester
environment.
3.2. Use `> make` to build the tests, and `> shell/test_<name>` to run a test.
Alternatively, you can cd into one of the test directories, source the
4.1. The release candidate is located in the `$REPO_HOME/release` directory and
has passed testing.
-4.2. Check that the program `$REPO_HOME/tool_shared/bespoke/release` outputs the
+4.2. Check that the program `$REPO_HOME/tool_shared/bespoke/version` outputs the
correct information. If necessary, modify it.
4.3. A new branch is created in the project for the release, named
`release_v<n>.0`, where `v<n>.0` is the version number from the `version`
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+ echo "$script_afp:: This script must be sourced, not executed."
+ exit 1
+fi
-script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
-export REPO_HOME="${script_path%}/"
-echo REPO_HOME "$REPO_HOME"
+source tool_shared/bespoke/env
-cd "$REPO_HOME"
-source tool/env
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+ echo "$script_afp:: This script must be sourced, not executed."
+ exit 1
+fi
-script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
-export REPO_HOME="${script_path%}/"
-echo REPO_HOME "$REPO_HOME"
-
-cd "$REPO_HOME"
source tool_shared/bespoke/env
source developer/tool/env
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+ echo "$script_afp:: This script must be sourced, not executed."
+ exit 1
+fi
-script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
-export REPO_HOME="${script_path%}/"
-echo REPO_HOME "$REPO_HOME"
-
-cd "$REPO_HOME"
source tool_shared/bespoke/env
source tester/tool/env
+++ /dev/null
-
-javac/TestBench is the non-project specific part of the test bench. (It does not
-belong here, rather it should be its own project.)
-
-javac/TestBenchAriadne Has the project specific tests.
-
-
--- /dev/null
+About `jdb`
+
+1. setting the environment
+
+ The environment should be set before running the IDE. For example,
+
+ > cd Mosaic
+ > source env_tester
+ > emacs &
+
+ (I use emacs as my IDE. You might be using a different tool.)
+
+2. location of the executable
+
+ Provided that the project administrator installed it, jdb is located in the
+ third_party tools directory. In the tester environment the variable
+ `JAVA_HOME` should hold the jdb directory path, and this should already
+ be in the `PATH`. For example:
+
+ > echo $ENV
+ tester/tool/env
+
+ > echo $JAVA_HOME
+ /var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11
+
+ > which jdb
+ /var/user_data/Thomas-developer/Mosaic/tool_shared/third_party/jdk-11/bin/jdb
+
+3. invocation from a shell command:
+
+ jdb -sourcepath $SOURCEPATH <class_name>
+
+ The `SOURCEPATH` is assigned a value in `tester/tool/env`. In some versions
+ of jdb there is no space between `-sourcepath` and the `$SOURCDEPATH`.
+
+ jdb will read CLASSPATH from the environment. In contrast jdb will not read
+ `SOURCEPATH` from the environment. It must be passed as an argument.
+
+ There is a `run_jdb` script in the `tool` directory.
+
+4. invocation inside of Emacs
+
+ The file `tool_shared/bespoke/emacs.el` holds a definition for the `jdbx`
+ command. This command will read the SOURCEPATH from the environment and run
+ jdb in Emacs.
+
+ That file also holds the definition for a listener to the jdb `sourcepath`
+ command.
+
+
+
+
+
+
public class TestBench{
+ /* --------------------------------------------------------------------------------
+ Static Data
+ */
+
+ private static PrintStream original_out;
+ private static PrintStream original_err;
+ private static InputStream original_in;
+
+ private static ByteArrayOutputStream out_content;
+ private static ByteArrayOutputStream err_content;
+ private static InputStream in_content;
+
+ /* --------------------------------------------------------------------------------
+ Test utility methods
+ */
+
// typically used to gather results before a return
public static boolean all(boolean[] conditions){
for( boolean condition : conditions ){
return true;
}
- public static void flush_stdin() throws IOException{
- while(System.in.available() > 0){
- System.in.read();
- }
- }
-
- public static void set_test_input(String input_data){
- ByteArrayInputStream test_in = new ByteArrayInputStream(input_data.getBytes());
- System.setIn(test_in);
- }
-
- public static void log_output(String test_name ,String stream ,String output_data) throws IOException{
- // Only log if there is actual content to log
- if(output_data != null && !output_data.isEmpty()){
- try(FileWriter log_writer = new FileWriter("test_log.txt" ,true)){ // Append mode
- log_writer.write("Test: " + test_name + "\n");
- log_writer.write("Stream: " + stream + "\n");
- log_writer.write("Output:\n" + output_data + "\n");
- log_writer.write("----------------------------------------\n");
- }
+ /* --------------------------------------------------------------------------------
+ Test run helpers
+ */
+ public static void log_output(String test_name ,String stream ,String output_data){
+ try(FileWriter log_writer = new FileWriter("test_log.txt" ,true)){ // Append mode
+ log_writer.write("Test: " + test_name + "\n");
+ log_writer.write("Stream: " + stream + "\n");
+ log_writer.write("Output:\n" + output_data + "\n");
+ log_writer.write("----------------------------------------\n");
+ } catch(IOException e) {
+ System.err.println("Error writing to log for test: " + test_name + ", stream: " + stream);
+ e.printStackTrace(System.err);
}
}
return true;
}
+
+ public static void flush_stdin() throws IOException{
+ while(System.in.available() > 0){
+ System.in.read();
+ }
+ }
+
+ public static void set_test_input(String input_data){
+ ByteArrayInputStream test_in = new ByteArrayInputStream(input_data.getBytes());
+ System.setIn(test_in);
+ }
- public static void run(Object test_suite ,String[] stdin_array){
+
+ public static void run(Object test_suite){
int failed_test = 0;
int passed_test = 0;
continue;
}
+ PrintStream original_out = null;
+ PrintStream original_err = null;
+ InputStream original_in = null;
+
+ ByteArrayOutputStream out_content = null;
+ ByteArrayOutputStream err_content = null;
+ ByteArrayInputStream in_content = null;
+
try{
// Redirect the I/O channels so the tests can manipulate them as data.
- PrintStream original_out = System.out;
- PrintStream original_err = System.err;
- InputStream original_in = System.in;
+ original_out = System.out;
+ original_err = System.err;
+ original_in = System.in;
- ByteArrayOutputStream out_content = new ByteArrayOutputStream();
- ByteArrayOutputStream err_content = new ByteArrayOutputStream();
- ByteArrayInputStream in_content = new ByteArrayInputStream(String.join("\n" ,stdin_array).getBytes());
+ out_content = new ByteArrayOutputStream();
+ err_content = new ByteArrayOutputStream();
+ in_content = new ByteArrayInputStream();
System.setOut(new PrintStream(out_content));
System.setErr(new PrintStream(err_content));
System.setIn(original_in);
// Report the error
- System.out.println("TestBench:: when redirecting i/o in preparation for running test \'" + test.getName() + "\' ,test bench itself throws error: " + e.toString());
+ System.out.println("TestBench:: when redirecting i/o in preparation for running test \'" + method.getName() + "\' ,test bench itself throws error: " + e.toString());
failed_test++;
continue;
}
// Capture detritus
- Exception exception_string = "";
+ String exception_string = "";
String stdout_string = "";
String stderr_string = "";
fail_exception = true;
// We keep it to report it
- exception = e;
+ exception_string = e.toString();
} finally{
System.setIn(original_in);
}
+ // Report the test result.
if(
fail_reported
|| fail_exception
}
- // Report summary of results
+ // Summarize all the test results
System.out.println("Total tests run: " + (passed_test + failed_test));
System.out.println("Total tests passed: " + passed_test);
System.out.println("Total tests failed: " + failed_test);
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
-# Caveat: the 'shell' directory is for built wrapper functions. `clean_build_directories` will
-# remove all the files in this directory. For bespoke scripts used by the tester, put
-# them in the `tool` directory.
+# Caveat: the 'shell' directory is for built wrapper
+# functions. `clean_build_directories` will remove all the files in this
+# directory. For bespoke scripts used by the tester, put them in the `tool`
+# directory.
# input guards
env_must_be="tester/tool/env"
# remove files
set -x
cd "$REPO_HOME"/tester
- rm -r scratch_pad/*
+ rm -r scratchpad/*
rm jvm/*
rm shell/*
set +x
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
env_must_be="tool_shared/bespoke/env"
+ error=false
if [ "$ENV" != "$env_must_be" ]; then
echo "$(script_fp):: error: must be run in the $env_must_be environment"
- exit 1
+ error=true
fi
-
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
- echo "$script_name:: This script must be sourced, not executed."
- exit 1
+ echo "$script_afp:: This script must be sourced, not executed."
+ error=true
fi
+ if $error; then exit 1; fi
# so we can do testing
export CLASSPATH=\
"$JAVA_HOME"/lib\
-:"$REPO_HOME"/release/Ariadne.jar\
-:"$REPO_HOME"/tester/jvm/TestBench.jar\
-:"$REPO_HOME"/tester/jvm/TestBenchAriadne.jar\
+:"$REPO_HOME"/release/"$PROJECT".jar\
+:"$REPO_HOME"/tester/jvm/Test_"$PROJECT".jar\
:"$CLASSPATH"
+export SOURCEPATH=\
+"$REPO_HOME"/tester/javac/\
+:"$REPO_HOME"/developer/scratchpad/\
+
+
# misc
# make .githolder and .gitignore visible
# some feedback to show all went well
- export PROJECT="$PROJECT"_tester
+ export PROMPT_DECOR="$PROJECT"_tester
export ENV=$(script_fp)
echo ENV "$ENV"
cd "$REPO_HOME"/tester/
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# input guards
set -x
cd $REPO_HOME/tester
- javac -d scratch_pad javac/*.java
- jar cf jvm/TestBenchAriadne.jar -C scratch_pad .
+ javac -g -d scratchpad javac/*.java
+ jar cf jvm/Test_"$PROJECT".jar -C scratchpad .
set +x
echo "Creating shell wrappers..."
mkdir -p shell
# wrapper is a space separated list
- wrapper=TestTestBench
+ wrapper=$(shell_wrapper_list)
for file in $wrapper;do
cat > shell/$file << EOL
#!/bin/env bash
-java com.ReasoningTechnology.Ariadne.TestBench.$file
+java $file
EOL
chmod +x shell/$file
done
+++ /dev/null
-#!/bin/env bash
-
-# input guards
-
- env_must_be="tester/tool/env"
- if [ "$ENV" != "$env_must_be" ]; then
- echo "$(script_fp):: error: must be run in the $env_must_be environment"
- exit 1
- fi
-
-echo "Compiling files..."
-
- set -x
- cd $REPO_HOME/tester
- javac -d scratch_pad javac/TestBench.java javac/TestTestBench.java
- jar cf jvm/TestBench.jar -C scratch_pad com/ReasoningTechnology/TestBench
- set +x
-
-echo "Creating shell wrappers..."
- mkdir -p shell
- # wrapper is a space separated list
- wrapper=TestTestBench
- for file in $wrapper;do
- cat > shell/$file << EOL
-#!/bin/env bash
-java com.ReasoningTechnology.TestBench.$file
-EOL
- chmod +x shell/$file
- done
-
-echo "$(script_fp) done."
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+env_must_be="tester/tool/env"
+if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+fi
+
+jdb -sourcepath "$SOURCEPATH" "$@"
+
--- /dev/null
+#!/bin/env bash
+
+# Ensure REPO_HOME is set
+if [ -z "$REPO_HOME" ]; then
+ echo "Error: REPO_HOME is not set."
+ exit 1
+fi
+
+# Navigate to the shell directory
+cd "$REPO_HOME/tester/shell" || exit
+
+# Get the list of test scripts in the specific order from shell_wrapper_list
+test_list=$(shell_wrapper_list)
+
+# Execute each test in the specified order
+for file in $test_list; do
+ if [[ -x "$file" && ! -d "$file" ]]; then
+ echo -n "Running $file..."
+ ./"$file"
+ else
+ echo "Skipping $file (not executable or is a directory)"
+ fi
+done
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+env_must_be="tester/tool/env"
+if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ exit 1
+fi
+
+# space separated list of shell interface wrappers
+echo Test0 Test_Util Test_IO Test_TestBench Test_MockClass
+
#!/usr/bin/env bash
-
-script_name=$(basename ${BASH_SOURCE[0]})
-if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
- echo "$script_name must be sourced, not executed. Exiting."
- exit 1
-fi
-
-if [ -z "$ENV_BASE" ]; then
- script_path="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
- source "${script_path}/env_base"
-fi
-
-ENV_PM=true
-
-PROJECT="$PROJECT"_administrator
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# input guards
+
+ env_must_be="tool_shared/bespoke/env"
+ error=false
+ if [ "$ENV" != "$env_must_be" ]; then
+ echo "$(script_fp):: error: must be run in the $env_must_be environment"
+ error=true
+ fi
+ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+ echo "$script_afp:: This script must be sourced, not executed."
+ error=true
+ fi
+ if $error; then exit 1; fi
export PATH=\
-"$REPO_HOME"/tool\
+"$REPO_HOME"/tool_shared/bespoke/\
:"$PATH"
-# no sneaky hidden files
+# expose sneaky hidden files
alias ls="ls -a"
-export ENV_PM=true
-echo "$script_name done."
+# some feedback to show all went well
+ export PROMPT_DECOR="$PROJECT"_administrator
+ export ENV=$(script_fp)
+ echo ENV "$ENV"
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# Check if at least one file is provided
if [ $# -eq 0 ]; then
- echo "Usage: $0 <filename1> [filename2] ..."
+ echo "Usage: $(script_fp) <filename1> [filename2] ..."
exit 1
fi
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# cp subtree at <source> under file path <destination>, and make all the copied
# files read-only. The intended use case is for moving files to a `deprecated`
# directory. This helps prevent subsequent accidental editing.
-SCRIPT_NAME=$(basename "$0")
if [ "$#" -lt 2 ]; then
- echo "Usage: $SCRIPT_NAME <source> <destination>"
+ echo "Usage: $script_afp <source> <destination>"
exit 1
fi
SRC="$1"
--- /dev/null
+
+; The first time Emacs encounters a link to a source file, Emacs asks if it should follow it.
+; This might suppress that initial question and follow the link.
+; (setq find-file-visit-truename t)
+
+(defun jdbx ()
+ "Set gud-jdb-sourcepath from the environment and run jdb with the correct source path."
+ (interactive)
+ (let*
+ (
+ (sourcepath (getenv "SOURCEPATH"))
+ )
+ (if
+ sourcepath
+ (setq gud-jdb-sourcepath (split-string sourcepath ":" t))
+ (message "Warning: SOURCEPATH is not set. `jdb` will run without source path information.")
+ )
+ (let
+ (
+ (class-name (read-string "Enter the class to debug: " "Test_Util"))
+ )
+ (jdb (concat "jdb -sourcepath"
+ (if
+ sourcepath
+ (mapconcat 'identity gud-jdb-sourcepath ":") ""
+ )
+ " "
+ class-name
+ )
+ ))))
+
+(defun monitor-jdb-sourcepath (output)
+ "Monitor the jdb output for `sourcepath ARG` commands and update `gud-jdb-sourcepath` with each path in ARG."
+ (when
+ (string-match "sourcepath \\(.+\\)" output)
+ (let*
+ (
+ (new-paths (match-string 1 output))
+ (paths-list (split-string new-paths ":" t))
+ )
+ ;; Add each path in paths-list to gud-jdb-sourcepath if not already present
+ (dolist
+ (path paths-list)
+ (unless
+ (member path gud-jdb-sourcepath)
+ (setq gud-jdb-sourcepath (append gud-jdb-sourcepath (list path)))
+ )
+ )
+ (message "Updated gud-jdb-sourcepath: %s" gud-jdb-sourcepath)))
+ output)
+
+(add-hook 'gud-filter-functions 'monitor-jdb-sourcepath)
#!/usr/bin/env bash
-# environment shared by entire project
-# number one task, establish REPO_HOME
-# this is specific to this script being in the .../tools_shared/env directory
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
+ echo "$script_afp:: This script must be sourced, not executed."
+ exit 1
+fi
- export PROJECT=$(basename "$REPO_HOME")
+# --------------------------------------------------------------------------------
+# project definition
- ## set the shell prompt to show the project
- PPS1="\n[$PROJECT]\n\u@\h§$(pwd)§\n> "
- PPS2=">> "
+# actual absolute director path for this script file
-# some useful functions for environment scripts
-
- ## path to script file
- script_fp() {
- eval "
- local script_dp=\$(dirname \$(realpath \${BASH_SOURCE[1]}))
- echo \$(realpath --relative-to=\"$REPO_HOME\" \"\$script_dp\")/\$(script_fn)
- "
+ script_adp(){
+ dirname "$script_afp"
}
- ## path to script directory
- script_dp() {
- eval "
- local script_dp=\$(dirname \$(realpath \${BASH_SOURCE[1]}))
- echo \$(realpath --relative-to=\"$REPO_HOME\" \"\$script_dp\")
- "
- }
+# assume this script is located $REPO_HOME/tools_shared/bespoke and work backwards
+# to get $REPO_HOME, etc.
- ## an env script will be in workspace/tool/env, so
- workspace(){
- eval "echo \$(dirname \$(script_dp))"
- }
+ REPO_HOME=$(dirname "$(dirname "$(script_adp)")")
+ echo REPO_HOME "$REPO_HOME"
- ## script's filename
- script_fn() {
- eval "echo \$(basename \${BASH_SOURCE[1]})"
- }
+ PROJECT=$(basename "$REPO_HOME")
+ echo PROJECT "$PROJECT"
- export -f script_fp script_dp script_fn workspace
+ # set the prompt decoration to the name of the project
+ PROMPT_DECOR=$PROJECT
-# note to the programs which environment they are running.
+# --------------------------------------------------------------------------------
+# The project administrator sets up the following tools for all roles to use:
+#
+ export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11"
- export ENV=$(script_fp)
+# --------------------------------------------------------------------------------
+# the following functions are provided for other scripts to use.
+# at the top of files that make use of these functions put the following line:
+# script_afp=$(realpath "${BASH_SOURCE[0]}")
+#
-# The project administrator setup these tools and environment settings for all
-# on the project to use:
+ ## script's filename
+ script_fn(){
+ basename "$script_afp"
+ }
-export JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-11"
+ ## script's dirpath relative to $REPO_HOME
+ script_fp(){
+ realpath --relative-to="${REPO_HOME}" "$script_afp"
+ }
-# some feedback to show all went well
+ ## script's dirpath relative to $REPO_HOME
+ script_dp(){
+ dirname "$(script_fp)"
+ }
-echo ENV "$ENV"
-echo PROJECT "$PROJECT"
+# --------------------------------------------------------------------------------
+# Exports
+# Bash has no 'closure' hence when exporting a function, one must also export all the pieces.
+# do not export script_afp
+ export REPO_HOME PROJECT PROMPT_DECOR
+ export -f script_adp script_fn script_dp script_fp
+ export ENV=$(script_fp)
+ echo ENV "$ENV"
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# try both running and sourcing this test
+
+echo
+echo "--------------------------------------------------------------------------------"
+echo "from within test_shared/bespoke/test_env:"
+echo
+echo "REPO_HOME:" "$REPO_HOME"
+echo "PROJECT:" "$PROJECT"
+echo "script_afp:" "$script_afp"
+echo "script_adp:" "$(script_adp)"
+echo "script_fn:" "$(script_fn)"
+echo "script_fp:" "$(script_fp)"
+echo "script_dp:" "$(script_dp)"
+echo "ENV:" "$ENV"
+echo "-----------------------"
+echo "the BASH_SOURCE stack:"
+
+ top_index=$(( ${#BASH_SOURCE[@]} - 1 ))
+ for (( i=0; i<=top_index; i++ )); do
+ echo "$i: ${BASH_SOURCE[$i]}"
+ done
#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# 0.1 pulled groovy files from GQL_to_Cypher build.gradle
# 0.2 conversion to Java
# 0.3 refactored, split into smaller pieces, made into package
-echo 0.3
+echo v0.3
#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# vl 'vertical list'
# Check if the command is provided
-#!/bin/bash
+#!/usr/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
# remove all files in the release directory
set -e