Paste #5015: Untitled Paste

Date: 2014/06/02 10:29:07 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


"STest":
    #
    # A script that runs the tests set up in the script name provided
    #
    # The script in question requires That the file path be pre-determined so its not much use
    # unless everything is already under 1 yaml file.
    #
    type: task
    definitions: script_name
    script:
    #I would like to do....
    #- define path <script.file_path>
    - define path "scripts/Dropbox/Sync List/Server Utility Scripts/Debug Utilities.yml"
    - yaml load:%path% id:UT
    - announce "<blue>Loaded yaml ids<&co> <yellow><yaml.list>" to_console

    - define number_of_tests <yaml[UT].list_keys[%script_name%.scripttest].size>
    - announce "<blue>Starting <green>%number_of_tests% <blue>tests." to_console
    - repeat %number_of_tests% {
        - define path "scripttest.test_%value%"
        - if <s@%script_name%.container_type> == procedure {
            - inject %script_name% "path:%path%.setup"
            - inject %script_name% "path:%path%.test"
            - inject %script_name% "path:%path%.teardown"
            - define scripts_expected_return <s@%script_name%.constant[%path%.expected]>
            - if <def[scripts_real_return]> == %scripts_expected_return% {
                - define script_name %script_name%
                - define test_results "<proc[Append Right].context[]>"
                - define test_names
                - announce "<gold>Script was successful" to_console
                - announce "<blue>Scripts Return<&co> <gold><def[scripts_real_return]>" to_console
                - announce "<blue>Expected Value<&co> <gold><def[scripts_expected_return]>" to_console
                } else {
                - announce "<red>Script failed"
                }
            }



        - if <s@%script_name%.constant[type]> == task {
            - announce "Testing a task"
            - run %script_name% path:script2
            }
        }


    - yaml unload id:UT



# the test script I was using for the script test features. Its functional, and yet unpolished.
#
"x5":
    #
    # A script for testing out an idea for denizen automated script tests
    #
    scripttest:
        test_1:
            input: 1
            expected: 5
            setup:
            - define scripts_input "<s@<script.name>.constant[scripttest.test_1.input]>"
            test:
            - define scripts_real_return <proc[<script.name>].context[%scripts_input%]>
            teardown:
            - announce Tearing_down_script
            - flag server delete_me !

    type: procedure
    definitions: number
    script:
    - determine <math:%number%*5>