+++ /dev/null
-#!/bin/bash
-java com.ReasoningTechnology."Mosaic".Mosaic
+++ /dev/null
-<configuration>
-
- <!-- File Appender -->
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <!-- Log file path -->
- <file>test_log.txt</file>
- <append>true</append>
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <!-- Root Logger -->
- <root level="info">
- <appender-ref ref="FILE" />
- </root>
-
-</configuration>
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
-public class Mosaic_Logger {
+public class Mosaic_Logger{
- private static final Logger LOGGER = LoggerFactory.getLogger(Mosaic_Logger.class);
- private static final DateTimeFormatter ISO_UTC_FORMATTER =
- DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC);
+ private static final Logger LOGGER = LoggerFactory.getLogger(Mosaic_Logger.class);
+ private static final DateTimeFormatter ISO_UTC_FORMATTER =
+ DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC);
- // Formats and logs an output related to a specific test
- public static void output(String test_name, String stream, String output_data) {
- String timestamp = iso_utc_time();
- String formatted_log = String.format(
- "\n%s -----------------------------------------------------------\n" +
- "Test: %s\n" +
- "Stream: %s\n" +
- "Output:\n%s\n",
- timestamp, test_name, stream, output_data
- );
+ // Formats and logs an output related to a specific test
+ public static void output(String test_name, String stream, String output_data){
+ String timestamp = iso_utc_time();
+ String formatted_log = String.format(
+ "\n%s -----------------------------------------------------------\n" +
+ "Test: %s\n" +
+ "Stream: %s\n" +
+ "Output:\n%s\n",
+ timestamp, test_name, stream, output_data
+ );
- LOGGER.info(formatted_log);
- }
+ LOGGER.info(formatted_log);
+ }
- // Logs a general message for a test
- public static void message(String test_name, String message) {
- String timestamp = iso_utc_time();
- String formatted_log = String.format(
- "\n%s -----------------------------------------------------------\n" +
- "Test: %s\n" +
- "Message:\n%s\n",
- timestamp, test_name, message
- );
+ // Logs a general message for a test
+ public static void message(String test_name, String message){
+ String timestamp = iso_utc_time();
+ String formatted_log = String.format(
+ "\n%s -----------------------------------------------------------\n" +
+ "Test: %s\n" +
+ "Message:\n%s\n",
+ timestamp, test_name, message
+ );
- LOGGER.info(formatted_log);
- }
+ LOGGER.info(formatted_log);
+ }
- // Logs an error with stack trace
- public static void error(String test_name, String message, Throwable error) {
- String timestamp = iso_utc_time();
- StringBuilder stack_trace = new StringBuilder();
- for (StackTraceElement element : error.getStackTrace()) {
- stack_trace.append(element.toString()).append("\n");
- }
+ public static void error(String test_name, String message, Throwable error){
+ String timestamp = iso_utc_time();
+ String formatted_log = String.format(
+ "\n%s -----------------------------------------------------------\n" +
+ "Test: %s\n" +
+ "Message:\n%s\n" +
+ "Error:\n",
+ timestamp, test_name, message
+ );
- String formatted_log = String.format(
- "\n%s -----------------------------------------------------------\n" +
- "Test: %s\n" +
- "Message:\n%s\n" +
- "Error:\n%s\n",
- timestamp, test_name, message, stack_trace
- );
+ // Pass the Throwable 'error' as the last argument to LOGGER.error.
+ // This automatically logs the stack trace at the ERROR level.
+ LOGGER.error(formatted_log, error);
+ }
- LOGGER.error(formatted_log);
+ /*
+ // Logs an error with stack trace
+ public static void error(String test_name, String message, Throwable error){
+ String timestamp = iso_utc_time();
+ StringBuilder stack_trace = new StringBuilder();
+ for (StackTraceElement element : error.getStackTrace()){
+ stack_trace.append(element.toString()).append("\n");
}
- // Utility to fetch the current time in ISO UTC format
- private static String iso_utc_time() {
- return ISO_UTC_FORMATTER.format(Instant.now());
- }
+ String formatted_log = String.format(
+ "\n%s -----------------------------------------------------------\n" +
+ "Test: %s\n" +
+ "Message:\n%s\n" +
+ "Error:\n%s\n",
+ timestamp, test_name, message, stack_trace
+ );
+
+ LOGGER.error(formatted_log);
+ }
+ */
+
+ // Utility to fetch the current time in ISO UTC format
+ private static String iso_utc_time(){
+ return ISO_UTC_FORMATTER.format(Instant.now());
+ }
}
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.time.format.DateTimeFormatter;
import java.util.function.Predicate;
+
public class Mosaic_Util{
// Linear search with a predicate
return Instant.now().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT);
}
- public static Object make_all_public_proxy( Class<?> class_metadata ) {
+ public static Object make_all_public_proxy(Class<?> class_metadata) {
try {
// Validate that the class implements at least one interface
- if( class_metadata.getInterfaces().length == 0 ) {
- throw new IllegalArgumentException(
- "The class " + class_metadata.getName() + " does not implement any interfaces."
- );
- }
-
- Object proxy = Proxy.newProxyInstance(
- class_metadata.getClassLoader()
- ,class_metadata.getInterfaces()
- ,(proxy_object ,method ,args) -> {
- // Ensure the target method is accessible
- Method target_method = class_metadata.getDeclaredMethod(
- method.getName()
- ,method.getParameterTypes()
- );
- target_method.setAccessible( true );
-
- // Create an instance of the target class
- Object real_instance = class_metadata.getDeclaredConstructor().newInstance();
-
- // Invoke the target method
- return target_method.invoke( real_instance ,args );
- }
- );
-
- return proxy;
-
- } catch( Throwable e ) {
- // Log the error to assist with debugging
- Mosaic_Logger.message( "make_all_public_proxy" ,"Failed to create proxy: " + e.getMessage() );
- throw new RuntimeException(
- "Failed to create proxy for class: " + class_metadata.getName() ,e
- );
+ Class<?>[] interfaces = class_metadata.getInterfaces();
+ if(interfaces.length == 0){
+ throw new IllegalArgumentException
+ (
+ "The class " + class_metadata.getName() + " does not implement any interfaces."
+ );}
+
+ // Create a Lookup for the target class that gives us access to private members
+ MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(class_metadata, MethodHandles.lookup());
+
+ InvocationHandler handler = (proxy_object, method, args) -> {
+ // Find the corresponding method in the target class
+ Method target_method = class_metadata.getDeclaredMethod(method.getName(), method.getParameterTypes());
+
+ // Convert the reflective method into a MethodHandle
+ MethodHandle mh = lookup.unreflect(target_method);
+
+ // Create an instance of the target class
+ Constructor<?> ctor = class_metadata.getDeclaredConstructor();
+ MethodHandle ctorHandle = lookup.unreflectConstructor(ctor);
+ Object real_instance = ctorHandle.invoke();
+
+ // Invoke the target method via the MethodHandle
+ if (args == null) {
+ args = new Object[0];
+ }
+
+
+ // replaces former return code:
+ Object result;
+ if (args == null || args.length == 0) {
+ // No arguments, just the instance
+ result = mh.invokeWithArguments(real_instance);
+ } else {
+ // One argument for the instance + all method arguments
+ Object[] callArgs = new Object[args.length + 1];
+ callArgs[0] = real_instance;
+ System.arraycopy(args, 0, callArgs, 1, args.length);
+ result = mh.invokeWithArguments(callArgs);
+ }
+ return result;
+
+ // former return code
+ // return mh.invokeWithArguments(real_instance, args);
+
+ };
+
+ // Create the proxy
+ return Proxy.newProxyInstance
+ (
+ class_metadata.getClassLoader(),
+ interfaces,
+ handler
+ );
+
+ } catch (Throwable e) {
+ Mosaic_Logger.message("make_all_public_proxy", "Failed to create proxy: " + e.getMessage());
+ throw new RuntimeException("Failed to create proxy for class: " + class_metadata.getName(), e);
}
}
+
}
--- /dev/null
+<configuration>
+
+ <!-- File Appender -->
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <!-- Log file path -->
+ <file>log/test_log.txt</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Root Logger -->
+ <root level="info">
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration>
+++ /dev/null
-#!/usr/bin/env bash
-script_afp=$(realpath "${BASH_SOURCE[0]}")
-# remove all files created by make's call to `javac`
-
-# 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
-
-# remove files
- set -x
- cd "$REPO_HOME"/developer
- 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=$(bash_wrapper_list)
-
-# remove files
-
- set -x
- cd "$REPO_HOME"/developer
- rm -r scratchpad/com/ReasoningTechnology/"$PROJECT"
- rm jvm/"$PROJECT".jar
- rm bash/{$wrapper}
- set +x
-
-echo "$(script_fn) done."
+++ /dev/null
-#!/usr/bin/env bash
-script_afp=$(realpath "${BASH_SOURCE[0]}")
-# remove files made by `make` and by `release`
-
-# 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
-
-# things to clean
-
- release_dir="$REPO_HOME"/release
- wrapper=$(bash_wrapper_list)
-
-# remove files
- set -x
- cd "$REPO_HOME"/developer
- rm -r scratchpad/com/ReasoningTechnology/"$PROJECT"
- rm jvm/"$PROJECT".jar
- rm bash/{$wrapper}
- rm -f "$release_dir"/"$PROJECT".jar
- rm -f "$release_dir"/{$wrapper}
- set +x
-
-echo "$(script_fn) done."
-
+++ /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."
:"$PATH"
-# for the developers ad hoc testing
+# Developed sources always come from javac🖉.
+# Everything else comes from scratchpad.
+# Run `make` to compile sources to the scratchpad
+# Run `release` to put the third party tools (that are included with the release) on the scratchpad.
#
export CLASSPATH=\
"$JAVA_HOME"/lib\
-:"$REPO_HOME"/developer/config\
+:"$REPO_HOME"/developer/log\
:"$REPO_HOME"/developer/scratchpad\
-:"$LOGGER_FACADE"\
-:"$LOGGER"\
+:$LOGGER_FACADE\
+:$LOGGER_CLASSIC\
+:$LOGGER_CORE\
:"$CLASSPATH"
export SOURCEPATH=\
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# This script links the sources into the scratchpad directory tree according to the package directory hiearchy.
+
+# 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."
--- /dev/null
+#!/bin/env bash
+script_afp=$(realpath "${BASH_SOURCE[0]}")
+
+# This script expands Mosaic third party projects onto the scratchpad. This is done before releasing or running local ad hoc tests, so that the third party tools will be present.
+
+# 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
+
+ echo "Expanding .jar files to be included with Mosaic into scratchpad."
+
+ third_party_jars=(
+ "$LOGGER_FACADE"
+ "$LOGGER_CLASSIC"
+ "$LOGGER_CORE"
+ )
+
+ pushd scratchpad >& /dev/null
+
+ for jar in "${third_party_jars[@]}"; do
+ if [ -f "$jar" ]; then
+ echo "including $jar"
+ jar -xf "$jar"
+ else
+ echo "Warning: JAR file not found: $jar"
+ fi
+ done
+
+ # we are not currently using modules
+ rm -rf module-info.class
+
+
+
+echo "$(script_fp) done."
#!/usr/bin/env bash
script_afp=$(realpath "${BASH_SOURCE[0]}")
+# before running this script, gather everything needed for the release on the scratchpad
+
# input guards
if [ -z "$REPO_HOME" ]; then
# Inform the user
echo "The pwd for this script is `pwd`."
- echo "Expanding .jar files to be included with Mosaic into scratchpad."
- echo "Gathering all the contents of scrathpad into jvm/\$PROJECT.jar"
- echo "Will copy jvm/\$PROJECT.jar and other files for release to ../release"
- echo "..."
# Function to copy and set permissions
fi
}
-# script local environment
-
- release_dir="$REPO_HOME/release"
- bash_dir="$REPO_HOME/developer/bash"
- project_jar_fp="$REPO_HOME/developer/jvm/"$PROJECT".jar"
- wrapper=$(bash_wrapper_list)
+# scratchpad --> .jar file
- mkdir -p "$release_dir"
mkdir -p jvm
+ jar_file=$(realpath jvm/"$PROJECT".jar)
-# third party tools to be included
-
- third_party_jars=(
- "$LOGGER_FACADE"
- "$LOGGER"
- )
+ pushd scratchpad
- for jar in "${third_party_jars[@]}"; do
- if [ -f "$jar" ]; then
- set -x
- jar -xf "$jar" -C scratchpad
- set +x
- else
- echo "Warning: JAR file not found: $jar"
- fi
- done
-
- jar_file=jvm/"$PROJECT".jar
- set -x
- jar cf $jar_file -C scratchpad .
- set +x
+ echo "scratchpad -> $jar_file"
+ jar cf $jar_file *
if [ $? -ne 0 ]; then
echo "Failed to create $jar_file file."
exit 1
fi
+ popd
+
# move files to the release dir
- install_file "$project_jar_fp" "$release_dir" "ug+r"
+ release_dir="$REPO_HOME/release"
+ bash_dir="$REPO_HOME/developer/bash"
+ wrapper=$(bash_wrapper_list)
+
+ install_file "$jar_file" "$release_dir" "ug+r"
for wrapper in $wrapper; do
install_file "$bash_dir"/"$wrapper" "$release_dir" "ug+r+x"
fi
source tool_shared/bespoke🖉/env
-source tool🖉/env
+source tool🖉/env $@
+++ /dev/null
-<configuration>
-
- <!-- File Appender -->
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <!-- Log file path -->
- <file>test_log.txt</file>
- <append>true</append>
- <encoder>
- <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <!-- Root Logger -->
- <root level="info">
- <appender-ref ref="FILE" />
- </root>
-
-</configuration>
--- /dev/null
+This shows all tests passing.
+
+Tests named `test_failure_<X>` should fail. We need to know that the `TestBench`
+can fail tests, so this is part of testing the `TestBench`.
+
+Staring the environment:
+
+2024-11-08T07:41:48Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer§
+> bash
+
+2024-11-08T07:41:51Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer§
+> cd Mosaic
+
+2024-11-08T07:41:54Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic§
+> . env_tester
+REPO_HOME /var/user_data/Thomas-developer/Mosaic
+PROJECT Mosaic
+ENV tool_shared/bespoke/env
+ENV tester/tool/env
+
+2024-11-08T07:42:04Z[Mosaic_tester]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> emacs &
+
+Running the tests:
+
+2024-11-08T09:58:40Z[Mosaic_tester]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> clean_build_directories
++ cd /var/user_data/Thomas-developer/Mosaic/tester
++ rm -r scratchpad/Test0.class scratchpad/Test_IO.class 'scratchpad/Test_MockClass_0$TestSuite.class' scratchpad/Test_MockClass_0.class scratchpad/Test_Testbench.class scratchpad/Test_Util.class
++ rm jvm/Test_Mosaic.jar
++ rm shell/Test0 shell/Test_IO shell/test_log.txt shell/Test_MockClass_0 shell/Test_Testbench shell/Test_Util
++ set +x
+clean_build_directories done.
+
+2024-11-08T09:58:46Z[Mosaic_tester]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> make
+Compiling files...
++ cd /var/user_data/Thomas-developer/Mosaic/tester
++ javac -g -d scratchpad javac/Test0.java javac/Test_IO.java javac/Test_MockClass_0.java javac/Test_Testbench.java javac/Test_Util.java
++ jar cf jvm/Test_Mosaic.jar -C scratchpad .
++ set +x
+Creating shell wrappers...
+tester/tool/make done.
+
+2024-11-08T09:58:50Z[Mosaic_tester]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> run_tests
+Running Test0...Test0 passed
+Running Test_Util...Test_Util passed
+Running Test_IO...Test_IO passed
+Running Test_Testbench...Expected output: Structural problem message for dummy_invalid_return_method.
+Structural problem: dummy_invalid_return_method does not return Boolean.
+Test_Testbench Total tests run: 3
+Test_Testbench Total tests passed: 3
+Test_Testbench Total tests failed: 0
+
+Running Test_MockClass_0...Test failed: 'test_failure_0' reported failure.
+Structural problem: test_failure_1 does not return Boolean.
+Error: test_failure_1 has an invalid structure.
+Test failed: 'test_failure_2' threw an exception: java.lang.reflect.InvocationTargetException
+Test failed: 'test_failure_3' produced extraneous stdout.
+Test failed: 'test_failure_4' produced extraneous stderr.
+Total tests run: 9
+Total tests passed: 4
+Total tests failed: 5
+
+2024-11-08T09:58:55Z[Mosaic_tester]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+>
--- /dev/null
+2024-12-13T02:40:40Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> run_tests
+test_list: Test_Logger Test0 Test_Util Test_IO Test_Testbench Test_MockClass_0 Test_Util_proxy
+
+... Running Test_Logger
+Test passed: 'smoke_test_logging'
+
+... Running Test0
+Test0 passed
+
+... Running Test_Util
+Test_Util passed
+
+... Running Test_IO
+Test_IO passed
+
+... Running Test_Testbench
+Expected output: Structural problem message for dummy_invalid_return_method.
+Structural problem: dummy_invalid_return_method does not return Boolean.
+Test_Testbench Total tests run: 3
+Test_Testbench Total tests passed: 3
+Test_Testbench Total tests failed: 0
+
+... Running Test_MockClass_0
+Test failed: 'test_failure_0' reported failure.
+Structural problem: test_failure_1 does not return Boolean.
+Error: test_failure_1 has an invalid structure.
+Test failed: 'test_failure_2' threw an exception: java.lang.reflect.InvocationTargetException
+Test failed: 'test_failure_3' produced extraneous stdout.
+Test failed: 'test_failure_4' produced extraneous stderr.
+Total tests run: 9
+Total tests passed: 4
+Total tests failed: 5
+
+... Running Test_Util_proxy
+Total tests run: 3
+Total tests passed: 3
+Total tests failed: 0
+
+2024-12-13T02:40:46Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+> cat log/log.txt
+2024-12-13T02:40:45.582Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.580717856Z -----------------------------------------------------------
+Test: smoke_test_logging
+Message:
+This is a smoke test for logging.
+
+2024-12-13T02:40:45.962Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.961627900Z -----------------------------------------------------------
+Test: test_failure_3
+Stream: stdout
+Output:
+Intentional extraneous chars to stdout for testing
+
+
+2024-12-13T02:40:45.963Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.963744794Z -----------------------------------------------------------
+Test: test_failure_4
+Stream: stderr
+Output:
+Intentional extraneous chars to stderr for testing.
+
+
+
+2024-12-13T02:40:52Z[]
+Thomas-developer@Blossac§/var/user_data/Thomas-developer/Mosaic/tester§
+>
--- /dev/null
+import com.ReasoningTechnology.Mosaic.Mosaic_IO;
+import com.ReasoningTechnology.Mosaic.Mosaic_Logger;
+
+public class Test_Logger{
+
+ public class TestSuite{
+ public Boolean smoke_test_logging(Mosaic_IO io){
+ try{
+ Mosaic_Logger logger = new Mosaic_Logger();
+ logger.message("smoke_test_logging", "This is a smoke test for logging.");
+ return true;
+ }catch (Exception e){
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+
+ public static void main(String[] args){
+ TestSuite suite = new Test_Logger().new TestSuite();
+ boolean result = suite.smoke_test_logging(null);
+
+ if(result){
+ System.out.println("Test passed: 'smoke_test_logging'");
+ System.exit(0);
+ }else{
+ System.err.println("Test failed: 'smoke_test_logging'");
+ System.exit(1);
+ }
+ }
+}
--- /dev/null
+2024-12-13T02:40:45.582Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.580717856Z -----------------------------------------------------------
+Test: smoke_test_logging
+Message:
+This is a smoke test for logging.
+
+2024-12-13T02:40:45.962Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.961627900Z -----------------------------------------------------------
+Test: test_failure_3
+Stream: stdout
+Output:
+Intentional extraneous chars to stdout for testing
+
+
+2024-12-13T02:40:45.963Z [main] INFO c.R.Mosaic.Mosaic_Logger -
+2024-12-13T02:40:45.963744794Z -----------------------------------------------------------
+Test: test_failure_4
+Stream: stderr
+Output:
+Intentional extraneous chars to stderr for testing.
+
+
--- /dev/null
+<configuration>
+
+ <!--
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+ -->
+
+ <!-- File Appender -->
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <!-- Log file path -->
+ <file>/var/user_data/Thomas-developer/Mosaic/tester/log/log.txt</file>
+ <append>true</append>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <!-- Root Logger -->
+ <root level="info">
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration>
fi
# space separated list of bash interface wrappers
-echo Test0 Test_Util Test_IO Test_Testbench Test_MockClass_0 Test_Util_proxy
+echo\
+ Test_Logger\
+ Test0\
+ Test_Util\
+ Test_IO\
+ Test_Testbench\
+ Test_MockClass_0\
+ Test_Util_proxy
+
set -x
cd "$REPO_HOME"/tester
rm_na -r scratchpad/*
- rm_na jvm/*
rm_na bash/*
set +x
if $error_not_sourced; then exit 1; fi
if $error_bad_env; then return 1; fi
+#--------------------------------------------------------------------------------
+# arguments
+
+ if [[ -x "$1" ]]; then MODE=$1; else MODE=release; fi
+ export MODE
+ echo "MODE: $MODE"
+
+#--------------------------------------------------------------------------------
+# so we can do testing
+
+export PATH=\
+"$REPO_HOME"/tester/tool🖉/\
+:"$JAVA_HOME"/bin\
+:"$PATH"
+
+# so we can run individual built tests wrappers
+export PATH=\
+"$REPO_HOME"/tester/bash\
+:"$PATH"
#--------------------------------------------------------------------------------
# class/source paths
-# ----
-# Settings to debug to find failing tests on release candidate.
-# See next section for settings for debugging the sources.
+BASE_CLASSPATH="$JAVA_HOME"/lib:"$REPO_HOME"/tester/log
+BASE_SOURCEPATH="$REPO_HOME"/tester/javac🖉
-# note the possible aliasing between the Test_$PROJECT and release classes
-export CLASSPATH=\
-"$JAVA_HOME"/lib\
-:"$REPO_HOME"/tester/config\
-:"$REPO_HOME"/tester/jvm/Test_"$PROJECT".jar\
-:"$REPO_HOME"/release/"$PROJECT".jar\
-:"$CLASSPATH"
-
-# note the developer sources on the scratchpad, if they are even there
-# can be out of sync with those in the release jar
-export SOURCEPATH=\
-"$REPO_HOME"/tester/javac🖉/\
-:"$REPO_HOME"/developer/scratchpad/\
-:"$SOURCEPATH"
+case "$MODE" in
-# ----
-# for debugging developer sources
+# Classes, and other-than-tester sources if present, come from the release candidate. This is the normal MODE for regression testing.
+#
+# Release candidate sources, if present, are for viewing only. If sources are present in the release, but can not be read directly from the jar file, expand the jar file onto the scratchpad and replace that include line with this one:
#
-# export CLASSPATH=\
-# "$JAVA_HOME"/lib\
-# :"$REPO_HOME"/tester/config\
-# :"$REPO_HOME"/tester/jvm/Test_"$PROJECT".jar\
-# :"$REPO_HOME"/developer/scratchpad\
-# :"$LOGGER_FACADE"
-# :"$LOGGER"
-# :"$CLASSPATH"
-
-# developer must `distribute_source` for this to work
-# export SOURCEPATH=\
-# "$REPO_HOME"/tester/javac🖉/\
-# :"$REPO_HOME"/developer/scratchpad\
-# :"$SOURCEPATH"
-
-# ----
-# Another possible configuration is expand the developer release into scratchpad along with the tests. Then everything points at scratcpad. If the developer `distributed_source` to put the sources into the release candidate jar, the sources will be available in the debugger; however, editing them will not effect the developer's version (the origin version) of the sources.
+# :$REPO_HOME/release/scratchpad\
#
-# export CLASSPATH=\
-# "$JAVA_HOME"/lib\
-# :"$REPO_HOME"/tester/config\
-# :"$REPO_HOME"/tester/scratchpad\
-# :"$CLASSPATH"
+ release)
-# developer must `distribute_source` for this to work
-# export SOURCEPATH=\
-# "$REPO_HOME"/tester/javac🖉/\
-# "$REPO_HOME"/tester/scratchpad/\
-# :"$SOURCEPATH"
+export CLASSPATH=\
+"$BASE_CLASSPATH\
+:$REPO_HOME/tester/scratchpad
+:$REPO_HOME/release/${PROJECT}.jar\
+:$CLASSPATH"
-# end of the class/source path settings
-#`--------------------------------------------------------------------------------
+export SOURCEPATH=\
+"$BASE_SOURCEPATH\
+:$REPO_HOME/release/${PROJECT}.jar\
+:$SOURCEPATH"
-# so we can do testing
+ ;;
-export PATH=\
-"$REPO_HOME"/tester/tool🖉/\
-:"$JAVA_HOME"/bin\
-:"$PATH"
+# Classes and other-than-tester sources come from developer/scratchpad. This is the normal MODE for the developer when debugging test failures.
+#
+# While in env_developer, the developer must make the project and gather third party
+# tools and sources into the scratchpad for this to work.
+#
+ developer)
-# so we can run individual built tests wrappers
+export CLASSPATH=\
+"$BASE_CLASSPATH\
+:$REPO_HOME/tester/scratchpad\
+:$REPO_HOME/developer/scratchpad\
+:$CLASSPATH"
+
+export SOURCEPATH=\
+"$BASE_SOURCEPATH\
+:$REPO_HOME/developer/scratchpad\
+:$SOURCEPATH"
+
+ ;;
+
+# Classes and other-than-tester sources come from tester/scratchpad. This MODE gives the tester complete control over what to include in the test environment.
#
-export PATH=\
-"$REPO_HOME"/tester/bash\
-:"$PATH"
+# Tester expands everything to be included into the test environment into the scratchpad.
+#
+# Any changes made to must be exported to the environment the files came from if they are to persist.
+#
+ local)
+
+export CLASSPATH=\
+"$BASE_CLASSPATH
+:$REPO_HOME/tester/scratchpad\
+:$CLASSPATH"
+export SOURCEPATH=\
+"$BASE_SOURCEPATH\
+:$REPO_HOME/tester/scratchpad\
+:$SOURCEPATH"
+
+ ;;
+
+# default
+
+ *)
+ echo "Unknown MODE: $MODE"
+ return 1
+ ;;
+
+ esac
+
+echo CLASSPATH:
+vl echo "$CLASSPATH"
+echo SOURCEPATH:
+vl echo "$SOURCEPATH"
+echo PATH:
+vl echo $PATH
+#--------------------------------------------------------------------------------
# misc
# make .githolder and .gitignore visible
alias ls="ls -a"
-
-# some feedback to show all went well
-
export PROMPT_DECOR="$PROJECT"_tester
export ENV=$(script_fp)
echo ENV "$ENV"
set -x
cd $REPO_HOME/tester
javac -g -d scratchpad javac🖉/*.java
- jar cf jvm/Test_"$PROJECT".jar -C scratchpad .
set +x
echo "Creating bash wrappers..."
# PATH="$REPO_HOME/tool_shared/third_party/idea-IC-243.21565.193/:$PATH"
JAVA_HOME="$REPO_HOME/tool_shared/third_party/jdk-23.0.1"
+
+ # three packages merely to do logging!
LOGGER_FACADE="$REPO_HOME"/tool_shared/third_party/slf4j-api-2.0.9.jar
- LOGGER="$REPO_HOME"/tool_shared/third_party/logback-classic-1.5.12.jar
+ LOGGER_CLASSIC="$REPO_HOME"/tool_shared/third_party/logback-classic-1.4.11.jar
+ LOGGER_CORE="$REPO_HOME"/tool_shared/third_party/logback-core-1.4.11.jar
+
- export PATH JAVA_HOME LOGGER_FACADE LOGGER
+ export PATH JAVA_HOME LOGGER_FACADE LOGGER_CLASSIC LOGGER_CORE
# --------------------------------------------------------------------------------
# the following functions are provided for other scripts to use.
curl -O https://repo1.maven.org/maven2/org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar
-curl -O https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.5.12/logback-classic-1.5.12.jar
+curl -O https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.4.11/logback-classic-1.4.11.jar
+curl -O https://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.4.11/logback-core-1.4.11.jar
+
+#curl -O https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.5.12/logback-classic-1.5.12.jar
+#curl -O https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.5.12/logback-core-1.5.12.jar
+
+
+
add to bespoke🖉/env names for these for use in CLASSPATH