[Shell script] searches for function difference sets implemented by shell scripts and shell scripts

Source: Internet
Author: User

[Shell script] searches for function difference sets implemented by shell scripts and shell scripts

Text address

Click follow public account wenyuqinghuai

 

Sharing outline:

1. Background

2. Code Implementation

 

 

1. Background

During the automated testing of the company's tests, some functions with code development are covered, but those functions that have not yet been developed are still relatively slow to search using a function, here we provide a way to quickly find out which functions are not implemented.

The general idea is to use a shell script to implement it:

1) [collection function html]

Obtain the html source code of the url and match a function set sourceWeb. log.

2) run the script to obtain the result]

-- Execute the script sh run. sh, which is used to obtain the function set local_fun.log in the development code and traverse these functions, which are not in the file sourceWeb. put the log in the final result. log -- result. log is the function that has not been added to automated testing.

 

2. Code Implementation

 

The code for the shell script run. sh is as follows. The final result is result. log.

1 #! /Bin/sh 2 # The following multi-line annotation http://www.cnblogs.com/emanlee/p/3749911.html 3: <eof 4 [instructions for use] 5 1) [collection function html] 6 7 will have done the function, because we can get the html source code of the url and match a function set sourceWeb. log 8 9 2) [execute the script to obtain the result] 10 -- execute the script sh run. sh, which is used to obtain the function set local_fun.log in the development code and traverse these functions, which are not in the file sourceWeb. put the log in the final result. log11 -- result. log is the function 12 eof13 14 15 #1 that has not been added to automated testing. obtain the existing function web_fun.log16 function getSourceWebUrl () 17 {#{{ 18 # obtain the matched row 19 grep "function_css_class" sourceWeb. url-rn | awk-F: '{printf $1 + 1 "\ n"}'> 1. num. log20 # obtain the existing functions of the automation system 21 cat 1. num. log | xargs-I {} sed-n' {} P' sourceWeb. url> web_fun.log22 # Delete temporary file 23 rm 1. num. log24 }#}}25 26 #2. obtain the service_fun.log27 function getLocalFunction () 28 {#{{ 29 grep "public function ". /-rn | awk-F: '{printf $3 "\ n"}' | awk '{printf $3 "\ n"}' | awk-f' (''{printf $1" \ n"} '> local_fun.log30 }#}} 31 32 #3. obtain the final result (the result is not added to the automation function. log) 33 function getLast () 34 {#{{ 35 echo ""> lastResult. log36 # echo "@ ----------------- newStart"> lastResult. log37 cat local_fun.log | while read line38 do39 # echo "File: $ {line} "40 grep_res = 'grep $ {line} web_fun.log-rn '41 if [-z" $ grep_res "] 42 then43 echo-e" \ n [0 not added] $ {line} is not added to automation \ n "44 echo-e" $ {line} "> lastResult. log45 else46 echo-e "[1 added] $ {line} added to automation" 47 48 fi49 done50 # sorting deduplication 51 sort lastResult. log | uniq> result. log52 # echo-e "@ ------------------------- newEnd \ n"> lastResult. log53 #}}54 55 #4. delete intermediate file 56 function rmTmpLog () 57 {#{{ 58 # Delete temporary file 59 rm web_fun.log60 rm local_fun.log61 rm lastResult. log62 #}}63 64 echo-e "start \ n" 65 getSourceWebUrl; 66 getLocalFunction; 67 getLast; 68 # Delete intermediate file 69 rmTmpLog; 70 echo-e "end \ n"

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.