]> git.itanic.dy.fi Git - emerge-timer/blobdiff - emerge-timer.py
Add a simulation mode setting
[emerge-timer] / emerge-timer.py
index 5c07b6a61f8c7f527751ae487b0f9e4ba1d905ec..b37d9a063672384fb9fcb7bf281197e70c98706b 100755 (executable)
@@ -464,7 +464,8 @@ Options:
 \t-p, --pretended  Calculate compile time from piped 'emerge -p' output
 \t-h, --help \t Show this helpscreen
 \t-q, --quiet \t Be less verbose
-\t--no-color \t Use colorless output"""
+\t--no-color \t Use colorless output
+\t--simulate \t Do a simulation run"""
 
     print usage
 
@@ -476,7 +477,7 @@ if __name__ == "__main__":
     # Set the default mode as "package"
     mode = "package"
     input_package = None
-
+    simulation = False
 
     for arg in sys.argv[1:]:
 
@@ -496,10 +497,52 @@ if __name__ == "__main__":
             green_start = ""
             color_stop = ""
 
+        if arg == "--simulate":
+            simulation = True
+
 
     if len(sys.argv) > 1:
         input_package = sys.argv[1]
     else:
         usage()
 
-    main(mode, input_package)
+    if simulation == True:
+
+        print(red_start + "\n" + '*'*25 + "\n" + "THIS IS A SIMULATION RUN\n"
+              + '*'*25 + "\n")
+
+        print("Beginning 'package' mode check")
+
+        print("Checking for one emerge\n" + color_stop)
+
+        LOGFILE = "simulate/fake_emerge.log"
+        PORTDIR = "simulate/"
+
+        main("package", "first_fake_package")
+
+        print(red_start + "\nChecking for three emerges\n" + color_stop)
+
+        main("package", "second_fake_package")
+
+        print(red_start + "\n'package' mode check complete\n")
+
+        print(30*'*')
+
+        print("\nBeginning 'current' mode check")
+        print("Current emerge with no emerge process\n" + color_stop)
+
+        main("current", None)
+
+        print(red_start + "\nCurrent emerge with emerge processes\n" + color_stop)
+
+        PACKAGES.append(package("test-group/second_fake_package", "2.9-r2"))
+        PACKAGES.append(package("test-group/first_fake_package", "1.10.2-r1"))
+
+        main("current", None)
+
+        print(red_start + "\n" + '*'*20 + "\n" + "SIMULATION FINISHED\n" +
+              '*'*20 + color_stop)
+
+
+    else:
+        main(mode, input_package)