@@ -31,10 +31,11 @@ const (
3131 testDataPath = "../../test"
3232 csDemosPath = testDataPath + "/cs-demos"
3333 demSetPath = csDemosPath + "/set"
34+ demSetPathS2 = csDemosPath + "/s2"
3435 defaultDemPath = csDemosPath + "/default.dem"
3536 retakeDemPath = csDemosPath + "/retake_unknwon_bombsite_index.dem"
3637 unexpectedEndOfDemoPath = csDemosPath + "/unexpected_end_of_demo.dem"
37- s2DemPath = csDemosPath + "/s2.dem"
38+ s2DemPath = demSetPathS2 + "/s2.dem"
3839)
3940
4041var concurrentDemos = flag .Int ("concurrentdemos" , 2 , "The `number` of current demos" )
@@ -217,10 +218,6 @@ func TestS2(t *testing.T) {
217218 _ , err = p .ParseHeader ()
218219 assertions .NoError (err , "error returned by Parser.ParseHeader()" )
219220
220- p .RegisterEventHandler (func (e any ) {
221- fmt .Printf ("%#v\n " , e )
222- })
223-
224221 t .Log ("Parsing to end" )
225222 err = p .ParseToEnd ()
226223 assertions .NoError (err , "error occurred in ParseToEnd()" )
@@ -488,26 +485,20 @@ func runConcurrently(runner func()) {
488485 wg .Wait ()
489486}
490487
491- func TestDemoSet (t * testing.T ) {
492- t .Parallel ()
493-
494- if testing .Short () {
495- t .Skip ("skipping test due to -short flag" )
496- }
497-
498- dems , err := ioutil .ReadDir (demSetPath )
499- assert .NoError (t , err , "failed to list directory %q" , demSetPath )
488+ func testDemoSet (t * testing.T , path string ) {
489+ dems , err := os .ReadDir (path )
490+ assert .NoError (t , err , "failed to list directory %q" , path )
500491
501492 for _ , d := range dems {
502493 name := d .Name ()
503494 if strings .HasSuffix (name , ".dem" ) {
504- t .Logf ("Parsing '%s/%s'\n " , demSetPath , name )
495+ t .Logf ("Parsing '%s/%s'\n " , path , name )
505496 func () {
506- f := openFile (t , fmt .Sprintf ("%s/%s" , demSetPath , name ))
497+ f := openFile (t , fmt .Sprintf ("%s/%s" , path , name ))
507498 defer mustClose (t , f )
508499
509500 defer func () {
510- assert .Nil (t , recover (), "parsing of '%s/%s' panicked" , demSetPath , name )
501+ assert .Nil (t , recover (), "parsing of '%s/%s' panicked" , path , name )
511502 }()
512503
513504 p := demoinfocs .NewParser (f )
@@ -538,12 +529,32 @@ func TestDemoSet(t *testing.T) {
538529 })
539530
540531 err = p .ParseToEnd ()
541- assert .Nil (t , err , "parsing of '%s/%s' failed" , demSetPath , name )
532+ assert .NoError (t , err , "parsing of '%s/%s' failed" , demSetPath , name )
542533 }()
543534 }
544535 }
545536}
546537
538+ func TestDemoSet (t * testing.T ) {
539+ if testing .Short () {
540+ t .Skip ("skipping test due to -short flag" )
541+ }
542+
543+ t .Parallel ()
544+
545+ testDemoSet (t , demSetPath )
546+ }
547+
548+ func TestDemoSetS2 (t * testing.T ) {
549+ if testing .Short () {
550+ t .Skip ("skipping test due to -short flag" )
551+ }
552+
553+ t .Parallel ()
554+
555+ testDemoSet (t , demSetPathS2 )
556+ }
557+
547558func BenchmarkDemoInfoCs (b * testing.B ) {
548559 for i := 0 ; i < b .N ; i ++ {
549560 parseDefaultDemo (b )
0 commit comments