Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3681288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:40:24+00:00 2026-05-19T03:40:24+00:00

Hi I’d like to get some ideas and feedback as to how you would

  • 0

Hi
I’d like to get some ideas and feedback as to how you would tackle the task of parsing this file.
I basically need the name and status of each subtests between “Starting Test” and “Finished Test”
The issue is that sometimes there is no “Finished” and it goes straight to start due to a test crash.

I started my script going line by line trying to tackle all the scenarios but the logic started to get complex and convoluted so I couldn’t help but think there must be a smarter approach to this.
Any ideas, code, pseudocode would be greatly appreciated.

    myfile.log
****Starting test of test1
Message: Total Tests: 5
Log 23w4arg
Log 3958300
Message: PASS : test1SubTest1(): Pass
Log 23w4arg
Log efasf0
Message: PASS : test1SubTest2(): Pass
Log eafsarg
Log 3asf0
Message: FAIL: test1SubTest3(): Pass
Log 23asffg
Log 3fsaf00
Message: PASS : test1SubTest4(): Pass
Log 23fsafg
Log 3ag300
Message: PASS : test1SubTest5(): Pass
Message: Totals: 4 passed, 1 failed, 0 skipped
****Finished testing test1
Log 3ag3aw0
Log 3ag340
****Starting test of test2
Message: Total Tests: 3
Log 23w4arg
Log 3958300
Message: PASS : test2SubTest1(): Pass
Log 23w4arg
Log efasf0
Message: PASS : test2SubTest2(): Pass
Log 3ag340
****Starting test of test3
Log 234rg
Log 394w300
Message: PASS : test3SubTest1(): Pass
Log 23w4gdg
Log esdsf0
Message: PASS : test3SubTest2(): Pass
Log eafjhg
Log 3hj0
Message: FAIL: test3SubTest3(): Pass
Message: Totals: 2 passed, 0 failed, 0 skipped
****Finished testing test3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:40:25+00:00Added an answer on May 19, 2026 at 3:40 am
        <?php
    
    $file = "log.txt";
    $fh = fopen($file, "r");
    $contents = fread($fh, filesize($file));
    $lines = explode("\n", $contents);
    foreach($lines as $l) {
            $startStr = "****Starting test of ";
            $l = trim($l);
            if(stristr($l, $startStr)) {
                    $curTest = str_replace($startStr, "", $l);
                    echo "$curTest info:\n";
            }
            if(substr($l, 0, 7)=='Message') {
                    if(stristr($l, "Total Tests")) {
                            echo "$l\n";
                    }
                    else {
                            // Test result
                            $infoArr = explode(":", $l);
                            echo "$infoArr[2] completed with result $infoArr[1]\n";
                    }
            }
    
    }
    
    ?>
    
    
    Produces:
    test1 info:
    Message: Total Tests: 5
     test1SubTest1() completed with result  PASS 
     test1SubTest2() completed with result  PASS 
     test1SubTest3() completed with result  FAIL
     test1SubTest4() completed with result  PASS 
     test1SubTest5() completed with result  PASS 
     4 passed, 1 failed, 0 skipped completed with result  Totals
    test2 info:
    Message: Total Tests: 3
     test2SubTest1() completed with result  PASS 
     test2SubTest2() completed with result  PASS 
    test3 info:
     test3SubTest1() completed with result  PASS 
     test3SubTest2() completed with result  PASS 
     test3SubTest3() completed with result  FAIL
     2 passed, 0 failed, 0 skipped completed with result  Totals
    

    I would add in some checking for failed tests and stuff, but this should be enough to get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I would like to run a str_replace or preg_replace which looks for certain words
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm parsing an XML file, the creators of it stuck in a bunch social

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.