Script Utilities
A ScriptUtilities module is provided in the ./script directory to assist with running scripts and logging the results. This module is treated as separate from SignalingDimension.jl because it includes several dependencies not needed for the functionality in SignalingDimension.jl.
Running Scripts
The scripts require a few dependencies to run. The most stable way to run these scripts goes as follows:
- clone this project's git repo and navigate to the root directory
SignalingDimension.jl/. - From the project root directory, open a Julia REPL by running the
juliacommand. - Enter
Pkgmode by entering]in the Julia REPL. - In
Pkgmode runpkg> develop --local .to import the local version of SignalingDimension.jl. - In
Pkgmode runpkg> activate scriptto load the script dependencies. - Hit backspace to exit
Pkgmode and return to the Julia REPL. - Finally, run the script with
ARGS = ["--arg1", "value1", "--arg2"]; include("./script/path/to/script.jl").
The ARGS array contains string values of positional argument, key-value pairs, and flags that would be passed in the command line. To run the same command from the command line, one could alternatively call $ julia ./script/path/to/script.jl --arg1 value1 --arg2. However, care must be taken to ensure that all dependencies are properly installed.
Printing Test Results
Main.ScriptUtilities.print_test_results — Functionprint_test_results( test_func;
params=[] :: Vector{Any},
stdout=true :: Bool,
dir="./" :: String
) :: BoolPrints the results the test results and meta data to .txt. file or STDOUT. If results are printed to .txt file, then the file name is "test_func_datetime.txt" where "datetime" is a stringified datetime. This method returns a Boolean value which is true if the test passes and false otherwise.
Arguments:
test_func- a generic method that runs a@testset.params- optional keyword argument, which contains the parameters to runtest_func.stdout- optional keyword argument, iftrueprint results toSTDOUTinstead of.txtfile.dir- optional keyword argument, directory to which.txtfile is saved.
Results are printed in the form:
Version : # SignalingDimension.jl version used
Status `~/.julia/dev/SignalingDimension.jl/script/Project.toml`
[96aab1c2] SignalingDimension v0.1.1 [`..`]
Test Completed : 2021-02-26T10:17:26 # Datetime of test completion
Elapsed Time : 16.799114946 # Time elapsed during test
Test Method : verify_maximum_likelihood_facet # Test method used
Test Args : (30) # Arguments used for test method
Test Pass : true # All tests pass
Test Summary: | Pass Total
Testing all maximum likelihood facets of size `(30, 30)` or less. | 406 406Running within a @testset prevents the test results from being properly captured. If this method must be run in a testset, then test_func not contain a testset and instead print results to STDOUT and throw an exception on failure.
Main.ScriptUtilities.capture_test — Functioncapture_test(test_func; params=[] :: Vector{Any}) :: Tuple{Bool, String}Captures the STDOUT and pass staus of the provided test_func. A tuple is returned as (pass, results) where pass is a boolean indicating if the test passedand results is a string containing the STDOUT from test_func.
Arguments:
test_func- a generic method that runs a@testset.params- optional keyword argument, which contains the parameters to runtest_func.
Running within a @testset prevents the test results from being properly captured. If this method must be run in a testset, then test_func not contain a testset and instead print results to STDOUT and throw an exception on failure.