Beispiel #1
0
    def testDigestEnvRotation(self):
        """Rotating characters between key-value pairs must be detected"""
        s1 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={
                              "a": "bc",
                              "cd": "e"
                          })
        s2 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={
                              "a": "bcc",
                              "d": "e"
                          })
        assert s1.getVariantId() != s2.getVariantId()

        s1 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={
                              "a": "bb",
                              "c": "dd",
                              "e": "ff"
                          })
        s2 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={
                              "a": "bbc=dd",
                              "e": "ff"
                          })
        assert s1.getVariantId() != s2.getVariantId()
Beispiel #2
0
    def testDigestEnv(self):
        """Env changes digest"""
        s1 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={"a": "asdf"})

        # different value
        s2 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={"a": "qwer"})
        assert s1.getVariantId() != s2.getVariantId()

        # added entry
        s2 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={
                              "a": "asdf",
                              "b": "qwer"
                          })
        assert s1.getVariantId() != s2.getVariantId()

        # removed entry
        s2 = CheckoutStep(nullPkg,
                          nullFmt,
                          None, ("script", "digest", []),
                          digestEnv={})
        assert s1.getVariantId() != s2.getVariantId()
Beispiel #3
0
    def testDigestTools(self):
        """Tools must influence digest"""
        t1 = Empty()
        t1.step = Empty()
        t1.step.getVariantId = Mock(return_value=b'0123456789abcdef')
        t1.path = "p1"
        t1.libs = []

        s1 = CheckoutStep()
        s1.construct(nullPkg,
                     nullFmt,
                     None, ("script", "digest", []),
                     tools=Env({"a": t1}))

        # tool name has no influence
        s2 = CheckoutStep()
        s2.construct(nullPkg,
                     nullFmt,
                     None, ("script", "digest", []),
                     tools=Env({"zz": t1}))
        assert s1.getVariantId() == s2.getVariantId()

        # step digest change
        t2 = Empty()
        t2.step = Empty()
        t2.step.getVariantId = Mock(return_value=b'0123456789000000')
        t2.path = "p1"
        t2.libs = []

        s2 = CheckoutStep()
        s2.construct(nullPkg,
                     nullFmt,
                     None, ("script", "digest", []),
                     tools=Env({"a": t2}))
        assert s1.getVariantId() != s2.getVariantId()

        # path change
        t2.step.getVariantId = Mock(return_value=b'0123456789abcdef')
        t2.path = "foo"
        t2.libs = []

        s2 = CheckoutStep()
        s2.construct(nullPkg,
                     nullFmt,
                     None, ("script", "digest", []),
                     tools=Env({"a": t2}))
        assert s1.getVariantId() != s2.getVariantId()

        # libs change
        t2.step.getVariantId = Mock(return_value=b'0123456789abcdef')
        t2.path = "p1"
        t2.libs = ["asdf"]

        s2 = CheckoutStep()
        s2.construct(nullPkg,
                     nullFmt,
                     None, ("script", "digest", []),
                     tools=Env({"a": t2}))
        assert s1.getVariantId() != s2.getVariantId()
Beispiel #4
0
 def testDigestFullEnv(self):
     """Full env does not change digest. It is only used for SCMs."""
     s1 = CheckoutStep(nullPkg, nullFmt, None, ("script", "digest", []), {
         "a": "asdf",
         "q": "qwer"
     }, {"a": "asdf"})
     s2 = CheckoutStep(nullPkg, nullFmt, None, ("script", "digest", []), {},
                       {"a": "asdf"})
     assert s1.getVariantId() == s2.getVariantId()
Beispiel #5
0
 def testDigestStable(self):
     """Same input should yield same digest"""
     s1 = CheckoutStep(nullPkg, nullFmt, None, ("script", "digest", []), {
         "a": "asdf",
         "q": "qwer"
     }, {"a": "asdf"})
     s2 = CheckoutStep(nullPkg, nullFmt, None, ("script", "digest", []), {
         "a": "asdf",
         "q": "qwer"
     }, {"a": "asdf"})
     assert s1.getVariantId() == s2.getVariantId()
Beispiel #6
0
 def testDigestScriptChange(self):
     """Script does influnce the digest"""
     s1 = CheckoutStep(nullPkg, nullFmt, None, ("script", []), {
         "a": "asdf",
         "q": "qwer"
     }, {"a": "asdf"})
     s2 = CheckoutStep(nullPkg, nullFmt, None, ("evil", []), {
         "a": "asdf",
         "q": "qwer"
     }, {"a": "asdf"})
     assert s1.getVariantId() != s2.getVariantId()
Beispiel #7
0
 def testDigestEmpyEnv(self):
     """Adding empty entry must be detected"""
     s1 = CheckoutStep(nullPkg,
                       nullFmt,
                       None, ("script", "digest", []),
                       digestEnv={"a": "b"})
     s2 = CheckoutStep(nullPkg,
                       nullFmt,
                       None, ("script", "digest", []),
                       digestEnv={
                           "a": "b",
                           "": ""
                       })
     assert s1.getVariantId() != s2.getVariantId()
Beispiel #8
0
 def testDigestScriptChange(self):
     """Script does influnce the digest"""
     s1 = CheckoutStep()
     s1.construct(nullPkg, nullFmt, None, ("script", "digest", []),
                  Env({
                      "a": "asdf",
                      "q": "qwer"
                  }), Env({"a": "asdf"}))
     s2 = CheckoutStep()
     s2.construct(nullPkg, nullFmt, None, ("evil", "other digest", []),
                  Env({
                      "a": "asdf",
                      "q": "qwer"
                  }), Env({"a": "asdf"}))
     assert s1.getVariantId() != s2.getVariantId()
Beispiel #9
0
 def testStereotype(self):
     """Check that the CheckoutStep identifies itself correctly"""
     s = CheckoutStep()
     s.construct(nullPkg, nullFmt)
     assert s.isCheckoutStep() == True
     assert s.isBuildStep() == False
     assert s.isPackageStep() == False
Beispiel #10
0
 def testTrivialInvalid(self):
     """Trivial steps are invalid"""
     s = CheckoutStep(nullPkg, nullFmt)
     assert s.isValid() == False
Beispiel #11
0
 def testTrivialDeterministic(self):
     """Trivial steps are deterministic"""
     s = CheckoutStep(nullPkg, nullFmt)
     assert s.isDeterministic()