_acs-lang__util__replace_temporary_tags_with_lookups (private)

 _acs-lang__util__replace_temporary_tags_with_lookups

Defined in packages/acs-lang/tcl/test/acs-lang-test-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_stub aa_stub (public) aa_unstub aa_unstub (public) _acs-lang__util__replace_temporary_tags_with_lookups _acs-lang__util__replace_temporary_tags_with_lookups _acs-lang__util__replace_temporary_tags_with_lookups->aa_equals _acs-lang__util__replace_temporary_tags_with_lookups->aa_log _acs-lang__util__replace_temporary_tags_with_lookups->aa_log_result _acs-lang__util__replace_temporary_tags_with_lookups->aa_stub _acs-lang__util__replace_temporary_tags_with_lookups->aa_unstub

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    # Peter NOTE: cannot get this test case to work with the rollback code in automated testing
    # and couldn't track down why. I'm threrefor resorting to manual teardown which is fragile and hairy

    # The files involved in the test
    set package_key acs-lang
    set test_dir [lang::test::get_dir]
    set catalog_dir [lang::catalog::package_catalog_dir $package_key]
    set catalog_file "${catalog_dir}/acs-lang.xxx_xx.ISO-8859-1.xml"
    set backup_file_suffix ".orig"
    set catalog_backup_file "${catalog_file}${backup_file_suffix}"
    regexp {^.*(packages/.*)$} $test_dir match test_dir_rel
    set tcl_file "${test_dir_rel}/test-message-tags.tcl"
    set tcl_backup_file "${tcl_file}${backup_file_suffix}"

    # The test messages to use for the catalog file
    array set messages_array [list key_1 text_1 key_2 text_2 key_3 text_3]
    # NOTE: must be kept up-to-date for teardown to work
    set expected_new_keys [list Auto_Key key_1_1]

    # Write the test Tcl file
    set tcl_file_id [open "$::acs::rootdir/$tcl_file" w]
    set new_key_1 "_"
    set new_text_1 "Auto Key"
    set new_key_2 "key_1"
    set new_text_2 "text_1_different"
    set new_key_3 "key_1"
    set new_text_3 "$messages_array(key_1)"
    puts $tcl_file_id "# The following key should be auto-generated and inserted
    # <#  ${new_key_1} ${new_text_1} #>
    #
    # The following key should be made unique and inserted
    # <#${new_key_2} ${new_text_2}#>
    #
    # The following key should not be inserted in the message catalog
    # <#${new_key_3} ${new_text_3}#>"
    close $tcl_file_id

    # Write the catalog file
    lang::catalog::export_to_file $catalog_file [array get messages_array]

    # We need to force the API to export to the test catalog file
    aa_stub lang::catalog::get_catalog_file_path "
        return $catalog_file
    "

    # Replace message tags in the Tcl file and insert into catalog file
    lang::util::replace_temporary_tags_with_lookups $tcl_file

    aa_unstub lang::catalog::get_catalog_file_path

    # Read the contents of the catalog file
    array set catalog_array [lang::catalog::parse [lang::catalog::read_file $catalog_file]]
    array set updated_messages_array $catalog_array(messages)

    # Assert that the old messages are unchanged
    foreach old_message_key [array names messages_array] {
        aa_equals "old key $old_message_key should be unchanged"  $messages_array($old_message_key)  $updated_messages_array($old_message_key)
    }

    # Check that the first new key was autogenerated
    aa_equals "check autogenerated key" $updated_messages_array(Auto_Key) $new_text_1

    # Check that the second new key was made unique and inserted
    aa_equals "check key made unique" $updated_messages_array(${new_key_2}_1) $new_text_2

    # Check that the third key was not inserted
    aa_equals "third key not inserted"   [lindex [array get updated_messages_array $new_key_3] 1]  $messages_array($new_key_3)

    # Check that there are no tags left in the Tcl file
    set tcl_file_id [open "$::acs::rootdir/$tcl_file" r]
    set updated_tcl_contents [read $tcl_file_id]
    close $tcl_file_id
    aa_equals "tags in Tcl file replaced"  [llength [lang::util::get_temporary_tags_indices $updated_tcl_contents]]  0

    # Delete the test message keys
    foreach message_key [concat [array names messages_array] $expected_new_keys] {
        lang::message::unregister $package_key $message_key
    }
    # Delete the catalog files
    file delete -- $catalog_backup_file
    file delete -- $catalog_file

    # Delete the Tcl files
    file delete -- $::acs::rootdir/$tcl_file
    file delete -- $::acs::rootdir/$tcl_backup_file
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "util__replace_temporary_tags_with_lookups (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: