Procházet zdrojové kódy

[ci fw JavaScript/nodejs Java/gemini] (#3479)

Nate před 7 roky
rodič
revize
a47533c0fb
3 změnil soubory, kde provedl 79 přidání a 89 odebrání
  1. 4 9
      .travis.yml
  2. 2 0
      frameworks/C/duda/README.md
  3. 73 80
      toolset/travis/travis_diff.py

+ 4 - 9
.travis.yml

@@ -64,9 +64,7 @@ env:
      - "TESTDIR=Groovy/hot"
      - "TESTDIR=Haskell/snap"
      - "TESTDIR=Haskell/wai"
-     # Separating these tests b/c of travis timeout
-     - 'TEST="yesod yesod-mongodb-raw"'
-     - "TEST=yesod-postgres"
+     - "TESTDIR=Haskell/yesod"
      - "TESTDIR=Haskell/servant"
      - "TESTDIR=Haskell/spock"
      - "TESTDIR=Java/act"
@@ -200,13 +198,13 @@ before_script:
 
   # Runs travis_diff, printing the output to the terminal, and searches for travis-diff-continue
   # to determine if the suite should be installed and the current $TESTDIR test should run.
-  - export CONTINUE_TEST=`./toolset/travis/travis_diff.py | tee /dev/tty | grep -q "travis-diff-continue" && echo 1`
+  - export RUN_TESTS=`./toolset/travis/travis_diff.py | tee /dev/tty | grep -oP "travis-run-tests \K(.*)"`
 
   # travis_setup.sh runs all the same commands you would run if you were setting up
   # a development environment via:
   # http://frameworkbenchmarks.readthedocs.io/en/latest/Development/Installation-Guide/
   # it also stops a few conflicting services
-  - if [ $CONTINUE_TEST ]; then source ./toolset/travis/travis_setup.sh; else echo 'Skipping travis_setup.sh'; fi
+  - if [ "$RUN_TESTS" ]; then source ./toolset/travis/travis_setup.sh; else echo 'Skipping travis_setup.sh'; fi
 
 script:
 
@@ -214,10 +212,7 @@ script:
   # we'd like to try and do the diffing before travis_clean & setup.
   # This will run the tests exactly as you would in your own vm:
   # ./toolset/run-tests.py --mode verify --test (all the valid tests for this framework)
-  - if [[ $CONTINUE_TEST && "$TESTDIR" ]]; then tfb --mode verify --test-dir $TESTDIR; else echo 'Skipping test verification.'; fi
-  - if [[ $CONTINUE_TEST && "$TESTLANG" ]]; then tfb --mode verify --test-lang $TESTLANG; else echo 'Skipping test verification.'; fi
-  - if [[ $CONTINUE_TEST && "$TEST" ]]; then tfb --mode verify --test $TEST; else echo 'Skipping test verification.'; fi
-  # - tfb --mode verify --test
+  - if [ "$RUN_TESTS" ]; then tfb --mode verify --test-dir $RUN_TESTS; else echo 'Skipping test verification.'; fi
 
 cache:
   directories:

+ 2 - 0
frameworks/C/duda/README.md

@@ -25,3 +25,5 @@ Most of tests that are related to database query are pending and will be availab
 ## Contact
 
 Eduardo Silva <[email protected]>
+
+

+ 73 - 80
toolset/travis/travis_diff.py

@@ -26,21 +26,10 @@ def get_docker_changes(changes_output):
                        re.M)))
 
 
-def fw_found_in_changes(changes_output):
-    if os.getenv("TESTLANG"):
-        return re.search(
-            r"frameworks/" + re.escape(os.getenv("TESTLANG")) + "/",
-            changes_output, re.M)
-    elif os.getenv("TESTDIR"):
-        return re.search(
-            r"frameworks/" + re.escape(os.getenv("TESTDIR")) + "/",
-            changes_output, re.M)
-    elif os.getenv("TEST"):
-        for test in os.getenv("TEST").split(" "):
-            if re.search(
-                  r"frameworks/.+/" + re.escape(os.getenv("TEST")) + "/",
-                  changes_output, re.M):
-                return True
+def fw_found_in_changes(test, changes_output):
+    return re.search(
+        r"frameworks/" + test + "/",
+        changes_output, re.M)
 
 
 # Cleans up diffing and grep output and into an array of strings
@@ -48,9 +37,11 @@ def clean_output(output):
     return os.linesep.join([s for s in output.splitlines() if s])
 
 
-def quit_diffing(should_test_run):
-    if should_test_run:
-        print("travis-diff-continue")
+def quit_diffing():
+    if len(run_tests):
+        print("travis-run-tests {!s}".format(" ".join(set(run_tests))))
+    else:
+        print("No tests to run.")
     exit(0)
 
 
@@ -109,41 +100,40 @@ last_commit_msg = subprocess.check_output(
 print("Parsing commit message for travis commands: {!s}"
       .format(last_commit_msg))
 
+test_dirs = []
+run_tests = []
+
+# Break the test env variable down into test directories
+if os.getenv("TESTLANG"):
+    test_dirs = map(lambda x: os.getenv("TESTLANG") + '/' + x,
+                    os.listdir("frameworks/" + os.getenv("TESTLANG")))
+elif os.getenv("TESTDIR"):
+    test_dirs = os.getenv("TESTDIR").split(' ')
+
 # Forced full run
 if re.search(r'\[ci run-all\]', last_commit_msg, re.M):
     print("All tests have been forced to run from the commit message.")
-    quit_diffing(True)
+    run_tests = test_dirs
+    quit_diffing()
 
-# TODO: Fix to work with new TEST env var
 # Forced *fw-only* specific tests
-if re.search(r'\[ci fw-only.+\]', last_commit_msg, re.M):
-    if os.getenv("TESTDIR") and re.search(
-            r'\[ci fw-only(.?)+ ' + re.escape(os.getenv("TESTDIR")) +
-            '( .+\]|])', last_commit_msg, re.M):
-        print("This test has been forced to run from the commit message.")
-        quit_diffing(True)
-    elif os.getenv("TESTLANG") and re.search(
-            r'\[ci fw-only(.?)+ ' + re.escape(os.getenv("TESTLANG")) +
-            '/', last_commit_msg, re.M):
-        print("This test has been forced to run from the commit message.")
-        quit_diffing(True)
-    else:
-        print("Skipping this test from the commit message.")
-        quit_diffing(False)
+if re.search(r'\[ci fw-only .+\]', last_commit_msg, re.M):
+    tests = re.findall(r'\[ci fw-only (.+)\]', last_commit_msg, re.M)[0].strip().split(' ')
+    for test in tests:
+        if test in test_dirs:
+            print("{!s} has been forced to run from the commit message.".format(test))
+            run_tests.append(test)
+
+    # quit here because we're using "only"
+    quit_diffing()
 
-# TODO: Fix to work with TESTLANG and TEST
-# Forced framework run
+# Forced framework run in addition to other tests
 if re.search(r'\[ci fw .+\]', last_commit_msg, re.M):
-    if os.getenv("TESTDIR") and re.search(
-            r'\[ci fw(.?)+ ' + re.escape(os.getenv("TESTDIR")) + '( .+\]|\])',
-            last_commit_msg, re.M):
-        print('This test has been forced to run from the commit message.')
-        quit_diffing(True)
-    elif os.getenv("TESTLANG") and re.search(
-            r'\[ci fw(.?)+ ' + re.escape(os.getenv("TESTLANG")) +
-            '/', last_commit_msg, re.M):
-        print("This test has been forced to run from the commit message.")
-        quit_diffing(True)
+    tests = re.findall(r'\[ci fw (.+)\]', last_commit_msg, re.M)[0].strip().split(' ')
+    for test in tests:
+        if test in test_dirs:
+            print("{!s} has been forced to run from the commit message.".format(test))
+            run_tests.append(test)
 
 
 # TODO: any changes in the toolset folder will generate a full run.
@@ -156,37 +146,40 @@ if re.search(r'\[ci fw .+\]', last_commit_msg, re.M):
 
 if re.search(r'^toolset/(?!(travis/|setup/|continuous/))', changes, re.M) is not None:
     print("Found changes to core toolset. Running all tests.")
-    quit_diffing(True)
-
-if fw_found_in_changes(changes):
-    print("Found changes that affect this framework. Running test.")
-    quit_diffing(True)
-
-# Determine what has been changed based on initial diffing output
-docker_changes = get_docker_changes(changes)
-
-# For each of these, find the files that depend on them, if we find more
-# docker FROM dependencies add it to the bottom of the list, if it isn't
-# already there.
-i = 0
-while i <= len(docker_changes) - 1:
-
-    # Generates output of files that contain a FROM import for this dependency
-    more_changes = subprocess.check_output([
-        'bash', '-c', 'grep -RP "FROM tfb/' +
-                      re.escape(docker_changes[i].replace('.dockerfile', ''))
-                      + '(:|$)" . || echo ""'
-    ])
-    print("more_changes: {!s}".format(more_changes))
-    if fw_found_in_changes(more_changes):
-        print("Found changes that affect this framework. Running test.")
-        quit_diffing(True)
-
-    # Preserves the order of the list, so we can continue with this loop
-    docker_changes.extend(
-        Set(get_docker_changes(more_changes)) - Set(docker_changes))
-    i += 1
-
-# If we get here, there was nothing found
-print("Did not find any changes that affect this framework.")
-quit_diffing(False)
+    run_tests = test_dirs
+    quit_diffing()
+
+for test in test_dirs:
+    if fw_found_in_changes(test, changes):
+        print("Found changes that affect {!s}".format(test))
+        run_tests.append(test)
+        continue
+
+    # Determine what has been changed based on initial diffing output
+    docker_changes = get_docker_changes(changes)
+
+    # For each of these, find the files that depend on them, if we find more
+    # docker FROM dependencies add it to the bottom of the list, if it isn't
+    # already there.
+    i = 0
+    found = False
+    while i <= len(docker_changes) - 1 and not found:
+
+        # Generates output of files that contain a FROM import for this dependency
+        more_changes = subprocess.check_output([
+            'bash', '-c', 'grep -RP "FROM tfb/' +
+                          re.escape(docker_changes[i].replace('.dockerfile', ''))
+                          + '(:|$)" . || echo ""'
+        ])
+        print("more_changes: {!s}".format(more_changes))
+        if fw_found_in_changes(test, more_changes):
+            print("Found changes that affect {!s}".format(test))
+            run_tests.append(test)
+            found = True
+
+        # Preserves the order of the list, so we can continue with this loop
+        docker_changes.extend(
+            Set(get_docker_changes(more_changes)) - Set(docker_changes))
+        i += 1
+
+quit_diffing()