From: Thomas Walker Lynch Date: Fri, 13 Dec 2024 02:46:19 +0000 (+0000) Subject: -> classical logging, updates proxy approach X-Git-Url: https://git.reasoningtechnology.com/style/rt_dark_doc.css?a=commitdiff_plain;h=931d5d4501c09f6d685355ddc53627a13f08fa85;p=Mosaic -> classical logging, updates proxy approach --- diff --git a/developer/bash/Mosaic b/developer/bash/Mosaic deleted file mode 100755 index ba5b241..0000000 --- a/developer/bash/Mosaic +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -java com.ReasoningTechnology."Mosaic".Mosaic diff --git a/developer/config/logback.xml b/developer/config/logback.xml deleted file mode 100644 index 3472b66..0000000 --- a/developer/config/logback.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - test_log.txt - true - - %d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - diff --git "a/developer/javac\360\237\226\211/Mosaic_Logger.java" "b/developer/javac\360\237\226\211/Mosaic_Logger.java" index 50d1f92..014d732 100644 --- "a/developer/javac\360\237\226\211/Mosaic_Logger.java" +++ "b/developer/javac\360\237\226\211/Mosaic_Logger.java" @@ -7,60 +7,77 @@ import java.time.Instant; 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()); + } } diff --git "a/developer/javac\360\237\226\211/Mosaic_Util.java" "b/developer/javac\360\237\226\211/Mosaic_Util.java" index ede4fca..1cccc82 100644 --- "a/developer/javac\360\237\226\211/Mosaic_Util.java" +++ "b/developer/javac\360\237\226\211/Mosaic_Util.java" @@ -9,6 +9,7 @@ import java.lang.invoke.MethodHandle; 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; @@ -17,6 +18,7 @@ import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.function.Predicate; + public class Mosaic_Util{ // Linear search with a predicate @@ -57,43 +59,69 @@ public class Mosaic_Util{ 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); } } + } diff --git a/developer/log/logback.xml b/developer/log/logback.xml new file mode 100644 index 0000000..606405d --- /dev/null +++ b/developer/log/logback.xml @@ -0,0 +1,18 @@ + + + + + + log/test_log.txt + true + + %d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + diff --git "a/developer/tool\360\237\226\211/clean_javac_output" "b/developer/tool\360\237\226\211/clean_javac_output" deleted file mode 100755 index 82835c7..0000000 --- "a/developer/tool\360\237\226\211/clean_javac_output" +++ /dev/null @@ -1,18 +0,0 @@ -#!/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." diff --git "a/developer/tool\360\237\226\211/clean_make_output" "b/developer/tool\360\237\226\211/clean_make_output" deleted file mode 100755 index 094552b..0000000 --- "a/developer/tool\360\237\226\211/clean_make_output" +++ /dev/null @@ -1,26 +0,0 @@ -#!/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." diff --git "a/developer/tool\360\237\226\211/clean_release" "b/developer/tool\360\237\226\211/clean_release" deleted file mode 100755 index 8744730..0000000 --- "a/developer/tool\360\237\226\211/clean_release" +++ /dev/null @@ -1,29 +0,0 @@ -#!/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." - diff --git "a/developer/tool\360\237\226\211/distribute_source" "b/developer/tool\360\237\226\211/distribute_source" deleted file mode 100755 index ca5c9eb..0000000 --- "a/developer/tool\360\237\226\211/distribute_source" +++ /dev/null @@ -1,32 +0,0 @@ -#!/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." diff --git "a/developer/tool\360\237\226\211/env" "b/developer/tool\360\237\226\211/env" index 728e0cd..48704b0 100644 --- "a/developer/tool\360\237\226\211/env" +++ "b/developer/tool\360\237\226\211/env" @@ -25,14 +25,18 @@ export PATH=\ :"$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=\ diff --git "a/developer/tool\360\237\226\211/gather_source_links" "b/developer/tool\360\237\226\211/gather_source_links" new file mode 100755 index 0000000..689db3b --- /dev/null +++ "b/developer/tool\360\237\226\211/gather_source_links" @@ -0,0 +1,32 @@ +#!/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." diff --git "a/developer/tool\360\237\226\211/gather_third_party" "b/developer/tool\360\237\226\211/gather_third_party" new file mode 100755 index 0000000..e2c9bd9 --- /dev/null +++ "b/developer/tool\360\237\226\211/gather_third_party" @@ -0,0 +1,42 @@ +#!/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." diff --git "a/developer/tool\360\237\226\211/release" "b/developer/tool\360\237\226\211/release" index b798889..c8c32fe 100755 --- "a/developer/tool\360\237\226\211/release" +++ "b/developer/tool\360\237\226\211/release" @@ -1,6 +1,8 @@ #!/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 @@ -25,10 +27,6 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") # 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 @@ -52,45 +50,29 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") 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" diff --git "a/env_administrator\360\237\226\211" "b/env_administrator\360\237\226\211" index 2f09f8a..2ff06ed 100644 --- "a/env_administrator\360\237\226\211" +++ "b/env_administrator\360\237\226\211" @@ -6,5 +6,5 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then fi source tool_shared/bespoke🖉/env -source tool🖉/env +source tool🖉/env $@ diff --git a/release/Mosaic.jar b/release/Mosaic.jar index 1e2f3fd..aecf83c 100644 Binary files a/release/Mosaic.jar and b/release/Mosaic.jar differ diff --git a/tester/config/logback.xml b/tester/config/logback.xml deleted file mode 100644 index 3472b66..0000000 --- a/tester/config/logback.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - test_log.txt - true - - %d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - diff --git "a/tester/document\360\237\226\211/#build_run_transcript_v1.1.txt#" "b/tester/document\360\237\226\211/#build_run_transcript_v1.1.txt#" new file mode 100644 index 0000000..6bfa707 --- /dev/null +++ "b/tester/document\360\237\226\211/#build_run_transcript_v1.1.txt#" @@ -0,0 +1,75 @@ +This shows all tests passing. + +Tests named `test_failure_` 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§ +> diff --git "a/tester/document\360\237\226\211/build_run_transctipt_v1_2024-12-13.txt" "b/tester/document\360\237\226\211/build_run_transctipt_v1_2024-12-13.txt" new file mode 100644 index 0000000..829315a --- /dev/null +++ "b/tester/document\360\237\226\211/build_run_transctipt_v1_2024-12-13.txt" @@ -0,0 +1,69 @@ +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§ +> diff --git "a/tester/javac\360\237\226\211/Test_Logger.java" "b/tester/javac\360\237\226\211/Test_Logger.java" new file mode 100644 index 0000000..7c8f6e0 --- /dev/null +++ "b/tester/javac\360\237\226\211/Test_Logger.java" @@ -0,0 +1,31 @@ +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); + } + } +} diff --git a/tester/jvm/.githolder b/tester/jvm/.githolder deleted file mode 100644 index e69de29..0000000 diff --git a/tester/jvm/Test_Mosaic.jar b/tester/jvm/Test_Mosaic.jar deleted file mode 100644 index 7e5744d..0000000 Binary files a/tester/jvm/Test_Mosaic.jar and /dev/null differ diff --git a/tester/log/log.txt b/tester/log/log.txt new file mode 100644 index 0000000..4885307 --- /dev/null +++ b/tester/log/log.txt @@ -0,0 +1,22 @@ +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. + + diff --git a/tester/log/logback.xml b/tester/log/logback.xml new file mode 100644 index 0000000..80b0fef --- /dev/null +++ b/tester/log/logback.xml @@ -0,0 +1,22 @@ + + + + + + + + /var/user_data/Thomas-developer/Mosaic/tester/log/log.txt + true + + %d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + diff --git "a/tester/tool\360\237\226\211/bash_wrapper_list" "b/tester/tool\360\237\226\211/bash_wrapper_list" index d578290..8d272b6 100755 --- "a/tester/tool\360\237\226\211/bash_wrapper_list" +++ "b/tester/tool\360\237\226\211/bash_wrapper_list" @@ -9,4 +9,12 @@ if [ "$ENV" != "$env_must_be" ]; then 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 + diff --git "a/tester/tool\360\237\226\211/clean_build_directories" "b/tester/tool\360\237\226\211/clean_build_directories" index 7c5a59b..885904a 100755 --- "a/tester/tool\360\237\226\211/clean_build_directories" +++ "b/tester/tool\360\237\226\211/clean_build_directories" @@ -12,7 +12,6 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") set -x cd "$REPO_HOME"/tester rm_na -r scratchpad/* - rm_na jvm/* rm_na bash/* set +x diff --git "a/tester/tool\360\237\226\211/env" "b/tester/tool\360\237\226\211/env" index a5995d6..f9626b5 100644 --- "a/tester/tool\360\237\226\211/env" +++ "b/tester/tool\360\237\226\211/env" @@ -17,87 +17,117 @@ script_afp=$(realpath "${BASH_SOURCE[0]}") 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" diff --git "a/tester/tool\360\237\226\211/make" "b/tester/tool\360\237\226\211/make" index 9f86f68..d31e153 100755 --- "a/tester/tool\360\237\226\211/make" +++ "b/tester/tool\360\237\226\211/make" @@ -14,7 +14,6 @@ echo "Compiling files..." 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..." diff --git "a/tool_shared/bespoke\360\237\226\211/env" "b/tool_shared/bespoke\360\237\226\211/env" index 78d4452..df75b2f 100644 --- "a/tool_shared/bespoke\360\237\226\211/env" +++ "b/tool_shared/bespoke\360\237\226\211/env" @@ -42,10 +42,14 @@ fi # 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. diff --git "a/tool_shared/document\360\237\226\211/install.txt" "b/tool_shared/document\360\237\226\211/install.txt" index ffdb55e..3b662a8 100644 --- "a/tool_shared/document\360\237\226\211/install.txt" +++ "b/tool_shared/document\360\237\226\211/install.txt" @@ -59,7 +59,14 @@ Logging 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